I need to index into a texture array using indices which are not dynamically uniform. This works fine on NVIDIA chips but you can see the artifacts on AMD due to the wavefront problem. This means, a lot of pixel invocations get the wrong index value. I know you fix this by using NonUniformResourceIndex in hlsl. Is there an equivalent for Vulkan glsl?
This is the shader code for reference. As you can see, index is an arbitrary value for each pixel and is not dynamically uniform. I fix this for hlsl by using NonUniformResourceIndex(index)
layout(set = 0, binding = 0) uniform sampler textureSampler;
layout(set = 0, binding = 1) uniform texture2D albedoMaps[256];
layout(location = 0) out vec4 oColor;
void main()
{
uint index = calculate_arbitrary_texture_index();
vec2 texCoord = calculate_texcoord();
vec4 albedo = texture(sampler2D(albedoMaps[index], textureSampler), texCoord);
oColor = albedo;
}
Thank you
↧