5 Replies Latest reply on Feb 7, 2017 9:15 AM by invertedantimatter

    Alignment problem in OpenGL compute shaders


      I'm attempting to apply a matrix multiply to a batch of matrices by using a compute shader.  After troubleshooting various things, I found what was causing bad output.


      #version 430
      layout(local_size_x = 4, local_size_y = 4, local_size_z = 16) in;
      layout(binding = 0) uniform viewLayout { mat4 eye; };
      layout(std430, binding = 1) buffer inputLayout { mat4 src[]; };
      layout(std430, binding = 2) buffer outputLayout { mat4 dst[]; };
      void main(void)

        uint itm = (gl_WorkGroupID.z << 4) + gl_LocalInvocationID.z;
        uint col = gl_LocalInvocationID.y;
        uint row = gl_LocalInvocationID.x;
        dst[itm][col][row] = row;

      The variable dst (in bold) produces the following output for the first 16 floats


      However, if I change it to vec4 dst[][4],




      Can anyone help me understand why mat4 is treated like it is 5 floats wide instead of 4?