KhronosGroup / GLSL

GLSL Shading Language Specification and Extensions
Other
341 stars 100 forks source link

Increase GL_MAX_COMPUTE_UNIFORM_BLOCKS and GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS interface block constrains in compute shaders #127

Closed emilmasoumi closed 3 years ago

emilmasoumi commented 4 years ago

The amount of interface blocks used in compute shaders such as uniform blocks and shader storage blocks are currently limited by GL_MAX_COMPUTE_UNIFORM_BLOCKS and GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS respectively. The constraints lay around 8 for shader storage blocks and 15 for uniform blocks on most modern GPUs which is inadequate. It would be very useful if some extension were added increasing these constraints.

emilmasoumi commented 4 years ago

Increasing GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS and GL_MAX_UNIFORM_BUFFER_BINDINGS would also most likely be needed.

dgkoch commented 4 years ago

These are all implementation-specific limits -- no extension is needed to advertise higher limits for these, assuming the hardware supports more. Given that these generally aren't higher tends to suggest that there are hardware limitations resulting in the current limits, and you are better talking to your favourite implementors to see if they can increase their advertised limits.

emilmasoumi commented 4 years ago

An extension could allow having the maximum amount of blocks proportional to the amount of bindings allowed.

pdaniell-nv commented 4 years ago

What are the specific minimums are you needing for GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS and GL_MAX_UNIFORM_BUFFER_BINDINGS?

I think NVIDIA reports GL_MAX_UNIFORM_BUFFER_BINDINGS=84 (14 per shader stage), and I don't think that can easily be increased. NVIDIA reports GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS=96 (16 per shader stage), which potentially be increased if there was a need.

emilmasoumi commented 4 years ago

What are the specific minimums are you needing for GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS and GL_MAX_UNIFORM_BUFFER_BINDINGS?

I am not really rooting for some specific minimum as the issue stems from a compiler [1] generating OpenGL code from a higher functional language, so there could in reality be generated an endless amount of storage and uniform blocks depending on the amount of arrays specified by the programmer. I would just request setting the maximum amount of blocks proportional to the amount of bindings allowed.

I think NVIDIA reports GL_MAX_UNIFORM_BUFFER_BINDINGS=14, and I don't think that can easily be increased. NVIDIA reports GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS=16, which potentially be increased if there was a need.

Is that for all NVIDIA GPUs? My AMD GPU reports GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS = 40 and GL_MAX_UNIFORM_BUFFER_BINDINGS = 90 when queried.

[1]. https://github.com/diku-dk/futhark

pdaniell-nv commented 4 years ago

Sorry that should have been "14 per stage" and "16 per stage". I updated my comment.

gnl21 commented 3 years ago

Sorry this issue went dark. Is there still an issue here? This doesn't look like something that GLSL can change, but perhaps I haven't understood correctly.

These limits are real limitations imposed by the hardware devices that the programs will run on, so I'm not sure that we can improve things by expressing them differently (eg. as a number per binding). The total number of blocks that can be supported won't change because that's baked into the hardware.

To reflect the variety of hardware that exists, each of which may expose different limits, many compilers allow these options to be set outside the shader program so that the language can express programs that might only be valid on certain hardware devices. Alternatively your compiler is free to ignore the limits altogether, but then it will produce programs that cannot be executed on certain GPUs which have a limit on these resources.

emilmasoumi commented 3 years ago

I am closing this issue as it is no longer relevant and due to the disagreement.