AnsweredAssumed Answered

Nonuniform array access

Question asked by ptatar on Jan 23, 2019
Latest reply on Jan 24, 2019 by elstaci


I have question releted to nonuniform access to array of uniforms.


#version 450


layout(set = 0, binding = 0, std140) uniform _Global


    vec4 vfuniforms[48];

} _31;



layout(location = 0) in vec4 pos;

layout(location = 1) in uint vbatch;



void main()


    float _129 = float(vbatch * 2u);

    vec4 _152 = vec4(0.0, 0.0, 0.0, 1.0);

    _152.x = dot(pos, _31.vfuniforms[uint(_129 + 0.100000001490116119384765625)]);

    vec4 _154 = _152;

    _154.y = dot(pos, _31.vfuniforms[uint(_129 + 1.10000002384185791015625)]);

    gl_Position = _154;


It works fine on NVIDIA graphics card for both dx and vk. But on my Vega56 it works only for dx implementation and fail for vk implementation (for both dxc and shaderc). On Vk it renders some weird things. I can make it work by changing indices used to access vfuniforms for example (because I know that for my data it's only 2 possible values).


    _152.x = dot(pos, _31.vfuniforms[0]);

    vec4 _154 = _152;

    _154.y = dot(pos, _31.vfuniforms[1]);

Is this not supported feature on AMD GPU or it should work fine and I should blame my code for it or maybe I should do something more to make it work? I'm quite new to vulkan so I hope it's not dumb question.