devwaker / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

Shader Code with comma operator doesn't compile with ANGLE, but with native GLSL #461

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
Compile the following fragment shader code:

precision mediump float;
void main ( void ) {
    vec4 a = vec4(1,0,0,1), t;
    vec3 c;
    c= (t=a*0.5, t.xyz); 
    gl_FragColor = vec4(c.xyz, 1);
}

What is the expected output? What do you see instead?

The code should compile (it does in with native GLSL).
Instead the following error message is shown:

Failed to compile: ERROR: 0:4: 'assign' : cannot convert from '4-component 
vector of float' to '3-component vector of float'

What version of the product are you using? On what operating system?

ANGLE revision 2431 used in Chrome Canary on Windows 7.

Please provide any additional information below.

The error comes from line 5:
    c= (t=a*0.5, t.xyz); 

It works when changed to this:
    c= (a*0.5).xyz;

Original issue reported on code.google.com by lach...@gmail.com on 14 Aug 2013 at 10:28

GoogleCodeExporter commented 9 years ago
This appears to be a bug in the HLSL compiler.

We could work around it by rewriting it as (t=a*0.5, c=t.xyz), but that's not a 
trivial transformation in a high level language. Perhaps the traverser to 
unfold short-circuiting operations is a good starting point...

Anyway, are you able to work around this for now? It looks like a pretty rare 
case to run into.

Original comment by nico...@transgaming.com on 15 Aug 2013 at 5:58

GoogleCodeExporter commented 9 years ago
So it's an HLSL compiler problem.

It's kinda sad how buggy shader languages are with respect to the comma 
operator.
GLSL has a similar problem, but it seems to only occur in variable 
declarations, when using the comma operator inside the initialization.

We're currently working on a project that generates GLSL from another 
languages. For us, the comma operator would be a great help, as it would 
simplify many of the code transformations.

We might be able to find workarounds, but that would make the whole code 
generation more complicated.

It probably makes more sense to report these issues to the GLSL and HLSL 
compilers.

Original comment by lach...@gmail.com on 16 Aug 2013 at 9:36