Dynamically uniform expressions with nested for loops in GLSL

628 views Asked by At

In GLSL, the for loop counter is dynamically uniform if it is initialized with, compared against, and incremented by dynamically uniform expressions: https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)#Dynamically_uniform_expression

This shader has nested for loops:

layout(binding = 0) uniform UniformBufferObject
{
    int x;
} ubo;

void main()
{
    for (int i = 0; i < ubo.x; i++)
    {
        // 'i' is dynamically uniform, because ubo.x is dynamically uniform

        for (int j = 0; j < i; j++)
        {
            // is 'j' dynamically uniform?
        }
    }
}

As I understand, 'j' is dynamically uniform, because it is compared to 'i', which is also dynamically uniform. Is that correct?

1

There are 1 answers

1
Nicol Bolas On BEST ANSWER

All other things being equal, j will be dynamically uniform.