KhronosGroup / OpenGL-API

OpenGL and OpenGL ES API Issue Tracker
34 stars 5 forks source link

UNIFORM_ARRAY_STRIDE for atomic counters #5

Closed jchen10 closed 7 years ago

jchen10 commented 7 years ago

Spec says UNIFORM_ARRAY_STRIDE for atomic counters is an implementation-dependent value. ES 3.10 section 7.7.1: “Arrays of type atomic_uint are stored in memory by element order, with array element member zero at the lowest offset. The difference in offsets between each pair of elements in the array in basic machine units is referred to as the array stride, and is constant across the entire array. The array stride (the value of UNIFORM_ARRAY_STRIDE), is an implementation-dependent value and may be queried after a program is linked.”

And ESSL 3.10 section 4.4.6 says: "A subsequent atomic counter declaration will inherit the previous (post incremented) offset."

So if a developer writes a vertex shader like this: “layout(binding = 2, offset = 4) uniform atomic_uint a[2], b, c, d, e;” As the stride of counter array "a" is unknown to the developer before actually linked, he/she doesn't know the offset value for "b", "c", "d" and "e". Then the developer starts to write a framgent shader which needs use the counter "e" only. According to the uniform matching rule(ESSL 3.10 section 9.2.1), "e" should have a same offset specified in fragment shader as vertex shader. But the developer actually doesn't know how to declare "e" in fragment shader to match the vertex shader due to this offset uncertainty. There was a mention that UNIFORM_ARRAY_STRIDE is always 4 bytes for atomic counters. https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_shader_atomic_counters.txt 28 - What API should be used to query information about atomic counters?

 Resolved.  GetActiveUniformsiv.  Apart from the common type and count
 queries, UNIFORM_OFFSET can be used to query the offset of an atomic
 counter, UNIFORM_ARRAY_STRIDE can be used to query the stride in memory
 of an array of atomic counters (even though it's always four bytes), and
 UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX can be used to query the index of the
 active atomic counter buffer associated with the uniform.  

Was this rule simply missed by the subsequent specs?

shannonwoods commented 7 years ago

Can someone with project member access add the OpenGL ES label to this issue, please?

pdaniell-nv commented 7 years ago

The next spec revision will say the stride is always 4.