Skip to content

Using 'ktxTexture_VkUpload' with an image layout of 'VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL' causes an validation error. #1092

@Link459

Description

@Link459

When calling ktxTexture_VkUploadEx_WithSuballocator the validation layers complain with an error like this:

 vkCmdPipelineBarrier(): pImageMemoryBarriers[0].dstAccessMask (VK_ACCESS_SHADER_READ_BIT) is not supported by stage mask (VK_PIPELINE_STAGE_ALL_COMMANDS_BIT). The Vulkan spec states: For each element of pImageMemoryBarriers, if its srcQueueFamilyIndex and dstQueueFamilyIndex members are equal, or if its dstQueueFamilyIndex is the queue family index that was used to create the command pool that commandBuffer was allocated from, then its dstAccessMask member must only contain access flags that are supported by one or more of the pipeline stages in dstStageMask, as specified in the table of supported access types (https://docs.vulkan.org/spec/latest/chapters/synchronization.html#VUID-vkCmdPipelineBarrier-pImageMemoryBarriers-02820) 

Looking at the code it seems to be caused by these lines in setImageLayout in vkloader.c
https://github.com/KhronosGroup/KTX-Software/blob/main/lib/src/vkloader.c#L1772-L1781
When checking with the specification it is said that VK_ACCESS_SHADER_READ_BIT as an access type is not compatible with a stage of VK_PIPELINE_STAGE_ALL_COMMANDS_BIT in a pipeline barrier.
One way to fix it is to use VK_ACCESS_MEMORY_READ_BIT instead which supports all stage flags. I have changed that line to use VK_ACCESS_SHADER_READ_BIT and it does indeed fix the validation error. Another option would be using a different pipeline stage but I could see that being less favorable as the user would have to choose one or use the default which wouldn't work for all use cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions