Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Alastair_D_1
Beginner
92 Views

GLSL front-end rejects valid use of comma operator

I find that the following (valid) piece of GLSL is rejected by then Intel GLSL front-end:

 

#version 150

 

void foo() {

    vec3(0.0, 0.0, (uvec3(0u), 0.0))[2];

}

 

I get this error:

 

ERROR: 0:4: 'Error' : cannot offset into the vector

 

If I rewrite the code like this:

 

#version 150

void foo() {
     float temp = (uvec3(0u), 0.0);
     vec3(0.0, 0.0, temp)[2];
}

 

then it is accepted by the front end.

 

I have an Intel(R) HD Graphics 520 GPU, and I am running driver version 20.19.15.4326 (18/11/2015).

 

I have attached the example (as a .txt file).

 

I believe this is a bug, because it is valid to use the comma operator inside a vector initializer.  Can you reproduce it?

 

Thanks

 

Ally

0 Kudos
5 Replies
Michael_C_Intel2
Employee
92 Views

Hi Alastair,

I have this filed for investigation, like the previous issue it may be some time before we have any news. The team GLSL team is very busy right now.

-Michael

Alastair_D_1
Beginner
92 Views

Understood.

I just filed two further bug reports which might be higher priority, as (if I am correct that they are indeed bugs) they look like "wrong code" bugs.

Anyway, I'll stop filing bugs for the time being, but let me know if you do find these valuable and we can report some more in due course.

Cheers

Ally

Richard_S_Intel1
Employee
92 Views

 

Hi Alistair,

I am the developer in the GLSL team working on this problem.

The issue is not really the use of the comma operator; rather, it is a problem with constant folding in the GLSL compiler.

In the error case, the compiler attempts to perform constant folding as it recognizes that both the vector and the index (2) are constants, so it tries to do the array indexing at compile-time.   The error arises because the vector constant containing the element which contains the comma operator is a particular case that is not handled by the constant-folding code!   You will see the same issue if you use e.g.  .xz instead of [2].

In the case that is accepted, the 'temp' element of the vector is not recognized as a constant, so constant folding is not attempted, and so the error does not occur.

I have a fix for this problem, and it is currently undergoing review and regression testing.

- Richard

Alastair_D_1
Beginner
92 Views

Hi Richard

Thanks for looking into this, and for the details.

Ally

Richard_S_Intel1
Employee
92 Views

Hi Alastair,

The fix has been tested, reviewed and checked-in.

I have also fixed a similar problem where using the comma operator in array indexing, e.g.  arr[1, 2],  would cause a NULL pointer de-reference in the GLSL front-end, resulting in a crash rather than an error message.

      Richard

Reply