[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Public WebGL] GLSL loops and constant expressions
- To: public webgl <email@example.com>
- Subject: [Public WebGL] GLSL loops and constant expressions
- From: Vladimir Vukicevic <firstname.lastname@example.org>
- Date: Mon, 6 Dec 2010 13:04:47 -0800 (PST)
- In-reply-to: <385303112.493109.1291669059836.JavaMail.email@example.com>
- List-id: Public WebGL Mailing List <public_webgl.khronos.org>
- Sender: firstname.lastname@example.org
I've noticed a number of demos (even some recent ones) are failing the shader validation/translation step due to using a non-constant expression in a for loop. This is a limitation imposed by Appendix A of the GLSL ES spec, which WebGL is following, and which ANGLE is now validating.
For loops, as decribed in section 4 of appendix A are allowed with the following limitations:
- one loop index
- index has type int or float
- for statement must have the form:
for (type_specifier identifier = constant_expression ;
loop_index op constant_expression ;
where op is > >= < <= == or !=, and loop_expression is of the form
loop_index++, loop_index--, loop_index += constant_expression, loop_index -= constant_expression
As described in section 5.10 of the GLSL ES spec, a constant expression is:
- a literal value (e.g., 5 or true)
- a global or local variable qualified as const excluding function parameters
- an expression formed by an operator on operands that are constant expressions, including getting an element of a constant vector or a constant matrix, or a field of a constant structure
- a constructor whose arguments are all constant expressions
- a built-in function call whose arguments are all constant expressions, with the exception of the
texture lookup functions.
The following are not constant expressions:
- User-defined functions
- Uniforms, attributes and varyings.
In particular, a number of shaders are attempting to use a uniform value as a loop expression. This won't work, and triggers validation failure (and thus a compilation failure at compileShader time).
You are currently subscribed to email@example.com.
To unsubscribe, send an email to firstname.lastname@example.org with
the following command in the body of your email: