KhronosGroup / Vulkan-ValidationLayers

Vulkan Validation Layers (VVL)
https://vulkan.lunarg.com/doc/sdk/latest/linux/khronos_validation_layer.html
Other
774 stars 407 forks source link

Incorrect best practice warning when using `vkGetDevice{Buffer/Image}MemoryRequirements` #4730

Closed fendevel closed 1 year ago

fendevel commented 2 years ago

Describe the Issue

Validation layers report UNASSIGNED-BestPractices-vkBindBufferMemory-requirements-not-retrieved and UNASSIGNED-BestPractices-vkBindImageMemory-requirements-not-retrieved if you bind device memory with memory requirements queried using vkGetDeviceBufferMemoryRequirements or vkGetDeviceImageMemoryRequirements. These functions are provided by Vulkan 1.3 as alternatives to vkGetBufferMemoryRequirements and vkGetImageMemoryRequirements.

Valid Usage ID UNASSIGNED-BestPractices-vkBindImageMemory-requirements-not-retrieved(WARN / SPEC): msgNum: 1185611228 - Validation Warning: [ UNASSIGNED-BestPractices-vkBindImageMemory-requirements-not-retrieved ] Object 0: handle = 0x1ed20d4d200, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x46aafddc | vkBindImageMemory(): Binding memory to VkImage 0x1ed23c955c0[] but vkGetImageMemoryRequirements() has not been called on that image.

spencer-lunarg commented 2 years ago

I agree that vkGetDeviceImageMemoryRequirements (and vkGetDeviceBufferMemoryRequirements) should be enough to prevent the best practice warning here. The tricky part will be finding a good way to essentially tracking every call and saving the VkImageCreateInfo to pair with the VkMemoryRequirements values. Assuming we can hash it, but still have to worry about how many times an application might call vkGetDeviceImageMemoryRequirements

To be honest, I also question how useful of a best practice warning this really is for developers. I guess not sure how often people are just guessing the size and memoryType for memory allocations

fendevel commented 2 years ago

Yeah it may end up being better to check the inputs for the memory binding function and emitting a warning based on that than to track which functions were called where + associated data. Looking for specific function calls probably really isn't that useful.

juan-lunarg commented 1 year ago

This will be fixed in the upcoming SDK release.