[Mesa-dev] [GLSL] defined expressions

José Fonseca jfonseca at vmware.com
Fri Dec 3 08:01:06 PST 2010


Hi Ian,

The current GLSL preprocessor fails to parse expressions such as

  #if 1 == 0 || defined UNDEFINED

which is used by CINEBENCH r11.

The problem is the

  parser->space_tokens = 1;

statement conditional_tokens stanza -- it causes space tokens to be
emitted halfway before reaching the DEFINED token.

The attached patch is a quick bandaid to this problem, but I suspect
that other space-related issues may subsist. 

I don't quite understand space_tokens' role here, or how it is supposed
to work. I confess I'm not very familiar with bison/flex inner-workings:
I though that the tokenizer was producing tokens quite ahead of the
parser, so the parser couldn't change the behavior of the tokenizer in
flight -- but perhaps I'm mixing up with other lexel/grammar generation
tools.

Also attached is an extended version of the defined-01.vert piglit
glslparsertest test which covers more variations.

Jose
-------------- next part --------------
A non-text attachment was scrubbed...
Name: defined-01.vert
Type: text/x-csrc
Size: 541 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20101203/12cc52b2/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glcpp.diff
Type: text/x-patch
Size: 604 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20101203/12cc52b2/attachment.bin>


More information about the mesa-dev mailing list