我试图写一个计算着色器,光线跟踪的图像,像素的yz平面样本的权利,从图像A,那些在左边的图像B。
我不想对两个图像都进行采样,因此我尝试通过以下操作使用非统一访问:texture(textures[nonuniformEXT(sampler_id)], vec2(0.5));
并在着色器中启用相关扩展。这将触发以下验证层错误:
Message: Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-01091 ] Object 0: handle = 0x55a1c21315d0, name = Logical device: AMD RADV RAVEN2, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xa7bb8db6 | vkCreateShaderModule(): The SPIR-V Capability (SampledImageArrayNonUniformIndexing) was declared, but none of the requirements were met to use it. The Vulkan spec states: If pCode declares any of the capabilities listed in the SPIR-V Environment appendix, one of the corresponding requirements must be satisfied (https://vulkan.lunarg.com/doc/view/1.2.182.0/linux/1.2-extensions/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-01091)
如果我读了docs,这似乎是一个硬件功能,但有人说,如果创建正确的扩展对象,我仍然可以有非统一访问。但我不完全确定如何做到这一点。
1条答案
按热度按时间6yt4nkrj1#
您必须在创建设备时启用该功能。
您可以通过调用vkGetPhysicalDeviceFeatures2存档并沿着
pNext
链一直到VkPhysicalDeviceVulkan12Features2存档,然后检查shaderSampledImageArrayNonUniformIndexing
成员是否指向VK_TRUE
,来检查是否支持该功能。之后,当使用vkCreateDevicearchive创建设备时,在
pCreateInfo
结构中,在pNext
链中,您必须将shaderSampledImageArrayNonUniformIndexing
设置为VK_TRUE
的VkPhysicalDeviceVulkan12Featuresarchive。