@@ -51,8 +51,6 @@ import vulkan_hpp;
5151 #define LOGI (...) ((void )__android_log_print(ANDROID_LOG_INFO, " VulkanTutorial" , __VA_ARGS__))
5252 #define LOGW (...) ((void )__android_log_print(ANDROID_LOG_WARN, " VulkanTutorial" , __VA_ARGS__))
5353 #define LOGE (...) ((void )__android_log_print(ANDROID_LOG_ERROR, " VulkanTutorial" , __VA_ARGS__))
54- #define LOG_INFO (msg ) LOGI(" %s" , msg)
55- #define LOG_ERROR (msg ) LOGE(" %s" , msg)
5654#else
5755 // Define AAssetManager type for non-Android platforms
5856 typedef void AssetManagerType;
@@ -64,8 +62,6 @@ import vulkan_hpp;
6462 #define LOGI (...) printf(__VA_ARGS__); printf(" \n " )
6563 #define LOGW (...) printf(__VA_ARGS__); printf(" \n " )
6664 #define LOGE (...) fprintf(stderr, __VA_ARGS__); fprintf(stderr, " \n " )
67- #define LOG_INFO (msg ) std::cout << msg << std::endl
68- #define LOG_ERROR (msg ) std::cerr << msg << std::endl
6965#endif
7066
7167#define GLM_FORCE_RADIANS
@@ -291,7 +287,6 @@ class VulkanApplication {
291287 std::vector<vk::raii::Semaphore> presentCompleteSemaphore;
292288 std::vector<vk::raii::Semaphore> renderFinishedSemaphore;
293289 std::vector<vk::raii::Fence> inFlightFences;
294- uint32_t semaphoreIndex = 0 ;
295290 uint32_t currentFrame = 0 ;
296291
297292 bool framebufferResized = false ;
@@ -404,15 +399,15 @@ class VulkanApplication {
404399 };
405400
406401 instance = vk::raii::Instance (context, createInfo);
407- LOG_INFO (" Vulkan instance created" );
402+ LOGI (" Vulkan instance created" );
408403 }
409404
410405 void setupDebugMessenger () {
411406 // Debug messenger setup is disabled for now to avoid compatibility issues
412407 // This is a simplified approach to get the code compiling
413408 if (!enableValidationLayers) return ;
414409
415- LOG_INFO (" Debug messenger setup skipped for compatibility" );
410+ LOGI (" Debug messenger setup skipped for compatibility" );
416411 }
417412
418413 void createSurface () {
@@ -502,23 +497,15 @@ class VulkanApplication {
502497 &profileProperties,
503498 &supported
504499 );
505- result = vk_result == VK_SUCCESS ;
500+ result = vk_result == static_cast < int >(vk::Result::eSuccess) ;
506501#endif
507502
508503 if (result && supported == VK_TRUE) {
509504 appInfo.profileSupported = true ;
510505 appInfo.profile = profileProperties;
511- #if PLATFORM_ANDROID
512- LOG_INFO ((" Device supports Vulkan profile: " + std::string (profileProperties.name )).c_str ());
513- #else
514- LOG_INFO (" Device supports Vulkan profile: " + std::string (profileProperties.profileName ));
515- #endif
506+ LOGI (" Device supports Vulkan profile: %s" , profileProperties.profileName );
516507 } else {
517- #if PLATFORM_ANDROID
518- LOG_INFO ((" Device does not support Vulkan profile: " + std::string (profileProperties.name )).c_str ());
519- #else
520- LOG_INFO (" Device does not support Vulkan profile: " + std::string (profileProperties.profileName ));
521- #endif
508+ LOGI (" Device does not support Vulkan profile: %s" , profileProperties.profileName );
522509 }
523510 } else {
524511 throw std::runtime_error (" failed to find a suitable GPU!" );
@@ -796,13 +783,10 @@ class VulkanApplication {
796783 // Determine the Vulkan format from KTX format
797784 vk::Format textureFormat;
798785
799- if (TEXTURE_PATH.find (" viking_room.ktx2" ) != std::string::npos) {
800- textureFormat = vk::Format::eR8G8B8A8Unorm;
801- }
802786 // Check if the KTX texture has a format
803- else if (kTexture ->classId == ktxTexture2_c) {
787+ if (kTexture ->classId == ktxTexture2_c) {
804788 // For KTX2 files, we can get the format directly
805- ktxTexture2 * ktx2 = reinterpret_cast <ktxTexture2*>(kTexture );
789+ auto * ktx2 = reinterpret_cast <ktxTexture2*>(kTexture );
806790 textureFormat = static_cast <vk::Format>(ktx2->vkFormat );
807791 if (textureFormat == vk::Format::eUndefined) {
808792 // If the format is undefined, fall back to a reasonable default
@@ -1325,7 +1309,7 @@ class VulkanApplication {
13251309 void drawFrame () {
13261310 while ( vk::Result::eTimeout == device.waitForFences ( *inFlightFences[currentFrame], vk::True, UINT64_MAX ) )
13271311 ;
1328- auto [result, imageIndex] = swapChain.acquireNextImage ( UINT64_MAX, *presentCompleteSemaphore[semaphoreIndex ], nullptr );
1312+ auto [result, imageIndex] = swapChain.acquireNextImage ( UINT64_MAX, *presentCompleteSemaphore[currentFrame ], nullptr );
13291313
13301314 if (result == vk::Result::eErrorOutOfDateKHR) {
13311315 recreateSwapChain ();
@@ -1341,7 +1325,7 @@ class VulkanApplication {
13411325 recordCommandBuffer (imageIndex);
13421326
13431327 vk::PipelineStageFlags waitDestinationStageMask ( vk::PipelineStageFlagBits::eColorAttachmentOutput );
1344- const vk::SubmitInfo submitInfo{ .waitSemaphoreCount = 1 , .pWaitSemaphores = &*presentCompleteSemaphore[semaphoreIndex ],
1328+ const vk::SubmitInfo submitInfo{ .waitSemaphoreCount = 1 , .pWaitSemaphores = &*presentCompleteSemaphore[currentFrame ],
13451329 .pWaitDstStageMask = &waitDestinationStageMask, .commandBufferCount = 1 , .pCommandBuffers = &*commandBuffers[currentFrame],
13461330 .signalSemaphoreCount = 1 , .pSignalSemaphores = &*renderFinishedSemaphore[imageIndex] };
13471331 graphicsQueue.submit (submitInfo, *inFlightFences[currentFrame]);
@@ -1356,7 +1340,6 @@ class VulkanApplication {
13561340 } else if (result != vk::Result::eSuccess) {
13571341 throw std::runtime_error (" failed to present swap chain image!" );
13581342 }
1359- semaphoreIndex = (semaphoreIndex + 1 ) % presentCompleteSemaphore.size ();
13601343 currentFrame = (currentFrame + 1 ) % MAX_FRAMES_IN_FLIGHT;
13611344 }
13621345
@@ -1475,7 +1458,7 @@ int main() {
14751458 VulkanApplication app;
14761459 app.run ();
14771460 } catch (const std::exception& e) {
1478- LOG_ERROR ( e.what ());
1461+ LOGE ( " %s " , e.what ());
14791462 return EXIT_FAILURE;
14801463 }
14811464 return EXIT_SUCCESS;
0 commit comments