Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UNIFORM_ARRAY_STRIDE for atomic counters #5

Closed
jchen10 opened this issue May 19, 2017 · 2 comments
Closed

UNIFORM_ARRAY_STRIDE for atomic counters #5

jchen10 opened this issue May 19, 2017 · 2 comments

Comments

@jchen10
Copy link

jchen10 commented May 19, 2017

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
Copy link

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

@pdaniell-nv
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants