This is a heads up for what is going on on the glsl-pp-rework-2 feature
The goal was to rewrite the existing preprocessor for GLSL compiler as a
stepping stone for a better GLSL compiler in general. Make it faster,
easy to understand and maintain. But the most important thing was to
make it easy to plug a new syntax parser in the future (Ian has started
some work towards this). That's done.
The next step was to integrate the new preprocessor with the existing
syntax parser to allow me to measure compiler performance. The results
were not very satisfying -- it turned out the syntax parser was such a
huge bottleneck, it did not matter how fast the preprocessor was.
So I just hacked up a simple and fast syntax parser that basically
emulates the old one, so that we don't have to touch too much code,
spend too much time on it and intruduce regressions. It's not perfect,
it looks ugly but it works well. I don't mind scrapping it and replacing
with a new, bison-based parser. And for the time being, here are the
The benchmark takes CorrectConstFolding2.vert shader from the GLSL
Compiler Test suite. It's one of the biggest files with around 400 lines
of code. What is being timed is preprocessing + syntax parsing, so no
further semantic checking and code generation is taken into account.
old 128,157 us
new 4,719 us
improvement 27 x
After that the new preprocessor becomes the bottleneck. That means it's
worthwile to keep on improving it. If the preprocessing step is taken
out of the equation and we only measure the syntax parsing stage, we get
the following numbers.
improvement 122 x
The code for the new parse should be in mesa repository in a week or so.