Mesa Makes Way For Assembly Shaders To GLSL IR
Phoronix: Mesa Makes Way For Assembly Shaders To GLSL IR
Intel's Ian Romanick has made progress in his long side-project of compiling OpenGL assembly shaders to GLSL IR. He's now up to the point of being able to run the Doom 3 binaries with this conversion work for Mesa...
Wrong screenshot, Michael. That's the old, correct path. Ian's new branch is the screenshot in the middle, where rendering errors are apparent.
Anyway, I'm kind of losing track of what is going on, and what the plan is. This eliminates Mesa IR, right? What is left?
As I understand, before Gallium3D in Mesa GLSL used to be compiled to some Mesa IR, which was tied to OpenGL API, thus forbidding other APIs to be implemented on top of it. Then the Tungsten Graphics developed Gallium3D, and now Gallium3D OpenGL state tracker translates GLSL directly to their API-independent TGSI, and other state trackers as well. Then idea of using LLVM for common optimizations came out, TGSI->LLVM translator was written and now LunarG crew is working on their stack which uses LLVM as its only IR.
So what is "GLSL IR" and what is its place in all this?
The old mesa drivers got Mesa IR from both these assembly shaders and the old GLSL compiler. It was limited to GL 1.x features i think.
Originally Posted by shatsky
When Gallium3D was added, it converted this Mesa IR into TGSI for gallium drivers to use. TGSI was actually a similar format, i think, but better defined, cross-platform, and with more features available.
Around Mesa 7.10 or so, Intel committed a new GLSL compiler, which generates GLSL IR natively (IR is a common compiler term - internal representation). At first, this GLSL IR was converted into Mesa IR for backwards compatibility - then sent off to the classic drivers or turned into TGSI for gallium. Later, the i965 driver gained the ability to work on GLSL IR directly, and gallium converted directly from it into TGSI to bypass the Mesa IR as well. That was important because Mesa IR was getting old and missing features that both GLSL IR and TGSI had that were necessary for newer GL features.
My understanding of the current LLVM work is that it would directly replace TGSI in the gallium stack (as an alternative option) - although it's still early and many different things could eventually end up happening. There's also been whispers of possibly replacing TGSI with GLSL IR, or it could introduce multiple levels where it starts as one language and is later converted to another.
It is "Intermediate Representation".
Originally Posted by smitty3268
LLVM will not replace TGSI in near term. It is used only in AMD backend for the moment, where TGSI IR is converted to LLVM IR, to be optimized further and converted to VLIW for r600 class hardware, or SIMD for GCN.
My inderstanding so far is that TGSI is modelled after DX intermediate representation, so if anyone wants Mesa to be replacement GPU driver implementation for windows, TGSI should stay.
Last edited by Drago; 04-18-2012 at 04:41 PM.
I know what intermediate representation is. TGSI, LLVM IRs, AMD IL - they all are documented and their usage is clear enough. My question is what exactly GLSL IR is and where is it documented. Here, for example, it's mentioned that ARB assembly language itself is used as an IR. And here such things as High level IR, Mesa IR and GLSL IR are mentioned.
In this "GLSL IR to TSGI" message the example code seems to be ARB assembly. But the words "compiling assembly shaders (e.g. GL_ARB_vertex_program) to GLSL IR" clearly state that these two are not equal.
I'm not sure there is any good documentation of the GLSL IR, or if there is whether it's public or not. That's Intel's baby and they're using it in their GLSL compiler and their i965 driver. Also the GLSL IR -> TGSI conversion is probably some pretty easy code to look through and figure it out.
Originally Posted by shatsky
The big difference with GLSL IR is that it's more of an object-oriented structure - there will be a class for a while-loop, for example, and that will have members for the expression and the loop body, which will have classes for statements, etc.
TGSI/AMD IL/DX11 is all more like assembly instructions where it's just text that you read through one line at a time.
Several full time mesa developers are paid by companies that have proprietary drivers running on Mesa in Windows. Which is why they take care to make sure Mesa compiles in Visual Studio, maintain the scons build system, etc.
Originally Posted by 89c51
So yes, there is, although you won't find any of them on this website.
Though i don't think that's any reason that TGSI has to stick around. They just modelled it off that as something easy to start with that they knew would work. I'm sure they could move to GLSL IR eventually if they wanted to (which may not be very likely - i'm guessing Intel would have to make a commitment to move their drivers into Gallium before it would happen).
Last edited by smitty3268; 04-18-2012 at 09:21 PM.
its all either got to go tgsi or llvm. they really gotta pick one. hey, in a couple years gcc ir might even be a good choice seeing as they want to make their compiler structure more like llvm. i think they should all just stick with tgsi and mortph it to what they need to support whatever functionality they need.