PacktPublishing / Mastering-Graphics-Programming-with-Vulkan

MIT License
514 stars 65 forks source link

Update VMA includes to specify vulkan version 1.1 #12

Closed darby-anderson closed 1 year ago

darby-anderson commented 1 year ago

First, thank you for writing this book. It creates an excellent bridge from beginner Vulkan programming to expert.

I had trouble linking VMA on my laptop (which runs only Vulkan 1.2) and realized it was due to VMA using 1.3 functions including vkGetDeviceBufferMemoryRequirements. I was able to link correctly after defining VMA_VULKAN_VERSION to be 1.1 before including "vk_mem_alloc.h".

Not sure if this pull request is helpful to the project, but thought I would offer it up nonetheless.

theWatchmen commented 1 year ago

Hi, thanks for letting us know! I will test this with Vulkan 1.3 to make sure all chapters still work correctly. I will probably move this to the CMake file/VS Solution so that we don't have to touch these many files.

darby-anderson commented 1 year ago

Great, that definitely makes the most sense! I'll go ahead close this request now.

theWatchmen commented 1 year ago

While looking into this I noticed this in the VMA header:

#if !defined(VMA_VULKAN_VERSION)
    #if defined(VK_VERSION_1_3)
        #define VMA_VULKAN_VERSION 1003000
    #elif defined(VK_VERSION_1_2)
        #define VMA_VULKAN_VERSION 1002000
    #elif defined(VK_VERSION_1_1)
        #define VMA_VULKAN_VERSION 1001000
    #else
        #define VMA_VULKAN_VERSION 1000000
    #endif
#endif

Have you the 1.3 version of the SDK installed? If so, VMA will try to use 1.3 features. You could try and install the 1.2 SDK and see if that solves the issue.

darby-anderson commented 1 year ago

You are absolutely correct. I had the 1.3 version of the SDK installed. I downgraded to version 1.2 and the program ran correctly without any need to define VMA_VULKAN_IMPLEMENTATION. Thank you so much for your help!