vkGetBufferMemoryRequirements2 returns results that causes access violation

When I call vkGetBufferMemoryRequirements2, it returns a struct with all zeros. When I go to read that struct, however, I get an access violation. I know it is filled with all zeros because that what the Visual Studio debugger tells me.
Here is the code that causes the issue:

       VkBuffer testBuffer;

       VkBufferCreateInfo bufferInfo{};
       bufferInfo.size = 1024;
       bufferInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
       bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;

       VkMemoryRequirements memReq{};
       vkCreateBuffer(Engine::device, &bufferInfo, nullptr, &testBuffer);
       VkBufferMemoryRequirementsInfo2 memReqInfo = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2 };
       memReqInfo.buffer = testBuffer;

       VkMemoryDedicatedRequirements memDedicatedReq = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS };

       VkMemoryRequirements2 memReq2 = { VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2 };
       //memReq2.pNext = &memDedicatedReq;

       vkGetBufferMemoryRequirements2(Engine::device, &memReqInfo, &memReq2);

       memReq = memReq2.memoryRequirements;

If I place memReq = memReq2.memoryRequirements above vkGetBufferMemoryRequirements2, it reads the struct just fine without an access violation. However, when it is under that function, I get an access violation when executing that line of code. I am on Vulkan SDK version, and my GPU (Intel UHD Graphics 600) has a vulkan version of 1.3.215. How can I stop the access violation and have vkGetBufferMemoryRequirments return meaningful values?

Seems you used wrong Vulkan version, per StackOverflow…

Yep, in my VkApplicationInfo struct, I put VK_VERSION_1_3, but it should’ve been VK_API_VERSION_1_3.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.