KhronosGroup / Vulkan-ValidationLayers

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

False positives in VUID-VkMemoryToImageCopyEXT-pRegions-09062 with block compressed textures #8946

Open dragooahou opened 2 days ago

dragooahou commented 2 days ago

Environment:

Describe the Issue

The the size of the memory copied from the host computed in VUID-VkMemoryToImageCopyEXT-pRegions-09062 with block compressed texture format is wrong and often falsely report overlapping memory region.

Some formats I tested with 4096 x 4096 and 2048 x 2048 2D textures: VK_FORMAT_BC1_RGBA_UNORM_BLOCK: the computed size is 8 times bigger than it should be VK_FORMAT_BC7_UNORM_BLOCK: the computed size is 16 times bigger than it should be

vkuFormatElementSize is used but it returns the block size in bytes which is not equal to the texel size in bytes with block compressed formats. I think vkuFormatTexelSize should be used instead of vkuFormatElementSize.

spencer-lunarg commented 1 day ago

@dragooahou can you paste the error message here. Curious what is displaying. Basically I am need some more information in order to write a test to reproduce it

dragooahou commented 1 day ago

VK_FORMAT_BC1_RGBA_UNORM_BLOCK 4096x4096 2D texture, no mipmap

VUID-VkMemoryToImageCopyEXT-pRegions-09062(ERROR / SPEC): msgNum: 1844923578 - Validation Error: [ VUID-VkMemoryToImageCopyEXT-pRegions-09062 ] Object 0: handle = 0x7e2aa900000002cc, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x6df74cba | vkCopyMemoryToImageEXT(): pCopyMemoryToImageInfo->pRegions[0].pHostPointer points to memory spanning 00000288F58B0040 through 00000288FD8B0040, which overlaps with image memorymapped 00000288F78E0000 through 00000288FB8E0000.
The Vulkan spec states: The union of all source regions, and the union of all destination regions, specified by the elements of pRegions, must not overlap in memory (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkMemoryToImageCopyEXT-pRegions-09062)
    Objects: 1
       [0]  0x7e2aa900000002cc, type: 10, name: NULL

Here the memory span of pHostPointer is reported to be 134,217,728 bytes long but it should be 8,388,608 bytes long for this texture (there is an error in my previous message, it is 16 time bigger).

I have a scene which needs to load about 400 textures. This is processed by 14 worker threads that are creating textures and uploading data to the device with vkCopyMemoryToImageEXT all at the same time. The workers are also loading meshes at the same time by creating buffers and mapping them directly. I reproduce it everytime but at a random rate, I got the error message between 10 and 60 times everytime. I guess it depends on where textures end up mapped in host memory.

I forgot to mention that vkCopyMemoryToImageEXT works as expected and the textures are successfully loaded.