KhronosGroup/WebGL

Clarify discarded expressions of uniform block reference through instance name only

Opened this issue · 2 comments

Consider uniform block declaration with a instance-name:

uniform MyBlock { int x; int y; } b;

The spec spends effort to disallow using b without any field access. You aren't allowed to use MyBlock, so it is not easy to refer to plain b in a valid program.

Except, you can use it in a discarded statement expression, like b; or in a comma expression like somethingsomething, b;

This is a problem because some rewrite steps don't anticipate uniform blocks, and ANGLE assert with these.

Would it be in the spirit of the spec to fail these programs, or should they pass?

As per my reading, that could affect the statically used uniform counts? However, I can't parse the spec to understand if individual members of an uniform block are affected with different static use counts. E.g. if I refer to b.x; does it mean that b.y can be optimized away if not used? Would b; in this case mean that all uniform variables of that block are statically used.

https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf

For uniform blocks, the application uses the block name to identify the block. Block names have no other use within a shader beyond interface matching; it is an error to use a block name at global scope for anything other than as a block name (e.g., use of a block name for a global variable name or function name is currently reserved). It is a compile-time error to use the same block name for more than one block declaration in the same shader interface (as defined above) within one shader, even if the block contents are identical.

The discussion in 2024-04-18 meeting was that it likely would be invalid to refer to uniform block instance itself.
The discussion was that we would wait for OpenGL WG to discuss the issue.