被描述符集错误搞糊涂了

Confused by descriptor set errors

我正在研究一种模块化的方式来指定额外的制服和采样器(例如描述符集)以供 Vulkan 着色器(使用泛型等)使用,但我收到多个验证错误并且我无法破译它们的含义或者要检查哪个 Vulkan calls/data。

我看不出我在哪里触发了不匹配或者为什么全局描述符需要 (none) 组件类型。

UNASSIGNED-CoreValidation-Shader-DescriptorTypeMismatch(ERROR / SPEC): msgNum: 0 - Type mismatch on descriptor slot 0.0 (expected `VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT`) but descriptor of type VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
    Objects: 1
        [0] 0, type: 0, name: NULL
UNASSIGNED-CoreValidation-DrawState-DescriptorSetNotUpdated(ERROR / SPEC): msgNum: 0 - Descriptor set 0x52 bound as set #0 encountered the following validation error at vkCmdDrawIndexed() time: Descriptor in binding #0 at global descriptor index 0 requires (none) component type, but bound descriptor format is VK_FORMAT_R8G8B8A8_UNORM.
    Objects: 1
        [0] 0x52, type: 23, name: NULL
...
UNASSIGNED-CoreValidation-DrawState-DescriptorSetNotUpdated(ERROR / SPEC): msgNum: 0 - Descriptor set 0xa4 bound as set #0 encountered the following validation error at vkCmdDrawIndexed() time: Descriptor in binding #0 at global descriptor index 0 requires (none) component type, but bound descriptor format is VK_FORMAT_R8G8B8A8_UNORM.
    Objects: 1
        [0] 0xa4, type: 23, name: NULL
UNASSIGNED-CoreValidation-Shader-DescriptorTypeMismatch(ERROR / SPEC): msgNum: 0 - Type mismatch on descriptor slot 0.0 (expected `VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT`) but descriptor of type VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER

您的着色器接口与您当前绑定的描述符集中的描述符类型不同,设置为集合 0,绑定 0。

着色器需要某种统一缓冲区,但您提供的是组合图像采样器。

也许您混淆了顶点着色器和片段着色器。

UNASSIGNED-CoreValidation-DrawState-DescriptorSetNotUpdated(ERROR / SPEC): msgNum: 0 - Descriptor set 0x52 bound as set #0 encountered the following validation error at vkCmdDrawIndexed() time: Descriptor in binding #0 at global descriptor index 0 requires (none) component type, but bound descriptor format is VK_FORMAT_R8G8B8A8_UNORM.

您要么提供图像描述符,其格式符合预期的格式,例如一个缓冲区描述符,或者你 运行 进入了一个已知的验证层错误,该错误描述为 here.

在大型代码库中跟踪验证层错误可能有点棘手,因此如果您不确定如何修复它们,我建议 运行 您的应用程序通过 RenderDoc,检查发生该层错误时的管道状态,或者只是逐步通过验证层本身。使用例如Visual Studio 的 locals watch window 将帮助您找到触发这些消息的 Vulkan 对象。