glslang
glslang copied to clipboard
The layout offset for structure member is wrong when there is a unsized array.
Hi , I found that the offset (16) for position2 was assigned at fixBlockUniformOffsets when parse the declare Block. I know that the member size for position01 can't confirm when parse the declare Block. Should glslang fix this value after parse?
#version 430 core
layout(std430) coherent buffer Buffer {
coherent vec4 position01[]; //
vec4 position2[3]; // offset is 16, actually the offset is 32
} g_buffer;
void main() {
switch (gl_VertexID) {
case 0: gl_Position = g_buffer.position01[0]; break;
case 1: gl_Position = g_buffer.position01[1]; break;
case 2: gl_Position = g_buffer.position2[gl_VertexID - 2]; break;
}
}
The language in 4.1.9 Arrays is a little ambiguous, but it seems possible that this is allowed.
@ZhiqianXia Do you have a shader from a running GLSL app that does this?
@gnl21 Do you think this shader is valid by the GLSL spec?
@greg-lunarg I find this shader from CTS test.
glcts.exe --deqp-case=KHR-GL45.shader_storage_buffer_object.basic-syntax
@ZhiqianXia That is pretty strong evidence that someone thinks this is valid :) I am presuming that at least one driver passes this test. That would be even stronger evidence.
I will try to get to this sooner than later. If you wish to attempt a fix sooner, let me know.