@lsalzman thought it might be easier to review this here, rather than in the phabricator commit which just revendors all the files with no context.
A quick primer on how glsl-optimizer works to help you out:
It's essentially just a fork of the mesa repo. The GLSL compiler is used and everything else has been deleted
There are a couple additional files glsl_optimizer.cpp/h and Main.cpp to use the GLSL compiler to optimize shaders, either providing an API or standalone binary.
There are some additional files (mainly ir_print_glsl_visitor.cpp/h) which converts the optimized mesa IR back to GLSL.
There are also (unfortunately) some changes made to mesa's compiler files, eg additional optimization passes, or extra metadata added to the IR in order that it can be converted back to GLSL.
The first commit merges the new release. (Not expecting you to review all of the upstream commits!) Thankfully there were no conflicts in the files modified by both the optimizer and upstream. There were lots of conflicts due to upstream modifications in files from non-compiler parts of mesa, which had previously been deleted from the optimizer. I resolved these by deleting them again. Some files which had previously been deleted had to be restored because upstream modified files now depend on them (eg util files).
The second commit regenerates some files which are generated at build time in mesa. But we don't want to depend on flex, bison, or python during build.
The third commit fixes the build, and runs an optimization pass manually which mesa had done automatically prior the new release. Here is the mesa change which forced that change, for reference. The consequence of not making that change would be that builtin functions (eg max()) would not be inlined, and the shader would then fail to link.
The fourth commit changes how we translate from an IR opcode to a glsl string, to make it less brittle.
@lsalzman thought it might be easier to review this here, rather than in the phabricator commit which just revendors all the files with no context.
A quick primer on how glsl-optimizer works to help you out:
glsl_optimizer.cpp/h
andMain.cpp
to use the GLSL compiler to optimize shaders, either providing an API or standalone binary.ir_print_glsl_visitor.cpp/h
) which converts the optimized mesa IR back to GLSL.The first commit merges the new release. (Not expecting you to review all of the upstream commits!) Thankfully there were no conflicts in the files modified by both the optimizer and upstream. There were lots of conflicts due to upstream modifications in files from non-compiler parts of mesa, which had previously been deleted from the optimizer. I resolved these by deleting them again. Some files which had previously been deleted had to be restored because upstream modified files now depend on them (eg util files).
The second commit regenerates some files which are generated at build time in mesa. But we don't want to depend on flex, bison, or python during build.
The third commit fixes the build, and runs an optimization pass manually which mesa had done automatically prior the new release. Here is the mesa change which forced that change, for reference. The consequence of not making that change would be that builtin functions (eg
max()
) would not be inlined, and the shader would then fail to link.The fourth commit changes how we translate from an IR opcode to a glsl string, to make it less brittle.
The last two are fairly self explanatory.
Let me know if you have any questions!