LunarGLASS is an LLVM-based shader-compiler stack available to open-source developers.
Problem: Graphics Vendors Provide Different Implementations and Optimizations
- Results in redoing the same work
- Optimizations lag behind state-of-the-art
- Low predictability of performance across vendors
The growing complexity of shaders increases this problem over time.
Solution – LunarGLASS Middle End, Top IR, and Bottom IR
LunarGLASS brings a new approach by splitting the common shared intermediate representation (IR) into two levels.
It is based on establishing common IRs, allowing modularity between stack layers. Each source-language front end would benefit from a common set of high- and mid-level optimizations, as would each back end, without the need to invent additional IRs.
LunarGLASS provides a shared compiler middle end:
- Running most of the standard LLVM optimizations without change
- With new analyses such as identifying and structuring flow control and per-component data-flow analysis
- With new graphics-specific optimizations such as constructing optimal swizzles and optimizing across graphics-specific idioms
LunarGLASS provides Top IR, an LLVM-based IR that provides a source-matching representation:
- LLVM vectors represent source-language types (AoS)
- Intrinsics to represent built-in functions and graphical idioms, especially I/O, swizzling, and masking
- Could form the basis of an architecturally-neutral industry standard IR
LunarGLASS also provides Bottom IR, an LLVM-based IR that provides a target-matching representation:
- LLVM vectors represent target registers
- Native operations such as swizzling and masking are restored after optimizations
- Tailorable forms of parallelism – scalar for scalar targets, transposed vectors for SoA targets, direct vectors for AoS targets, or hybrids
LunarGLASS is open-source software and available on the LunarG GitHub page.