glslang icon indicating copy to clipboard operation
glslang copied to clipboard

The layout offset for structure member is wrong when there is a unsized array.

Open ZhiqianXia opened this issue 3 years ago • 3 comments

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;
 }
}

ZhiqianXia avatar Jul 01 '21 08:07 ZhiqianXia

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 avatar Jul 05 '21 17:07 greg-lunarg

@greg-lunarg I find this shader from CTS test.

glcts.exe --deqp-case=KHR-GL45.shader_storage_buffer_object.basic-syntax

ZhiqianXia avatar Jul 07 '21 04:07 ZhiqianXia

@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.

greg-lunarg avatar Jul 07 '21 18:07 greg-lunarg