Skip to content

v3d: do not write atomics, images or ssbos in coordinate shaders

Iago Toral requested to merge itoral/mesa:v3d_coord_shader_side_effects into master

We only want to execute these writes in the vertex shader.

@anholt: There is a test in CTS that uses atomic image stores in a vertex shader and has expectations about the result, which it ties to the number of vertices (so it expects the vertex shader to be run exactly once per vertex). I think the test is bogus because I don't think you can have such expectations... at least on V3D, the vertex shader can run multiple times if the primitives cross tile boundaries, I'll plan to discuss this inside Khronos.

But beyond that, I was thinking we should probably not be emitting code with side effects such as ssbo/image atomics and stores from a coordinate shader, since these writes are supposed to take place during the vertex shader execution and we don't need to execute them during coordinate shaders at all.

Alternatively, I was also wondering whether we could instead remove these from the vertex shader and keep them in the coord shader. This would ensure that they are only executed once, but it also means that the atomics and stores would all happen before the vertex shader execution and that can also lead to unexpected results (for example, if we have an atomic counter that we increment once per vertex, and we execute the atomicInc in the coord shader we would start all invocations of the vertex shader with a pre-incremented counter, and all vertex shader invocations would see the same counter value), so I am assuming we don't want to do that... even though that once you realize that you can't make any assumptions about the number of invocations in the vertex shader I wonder whether that actually matters at all.

What do you think?

Merge request reports