Hey,

I just pushed the initial support for vertex shaders through LLVM to Mesa's 
gallium-0.1 branch.

Let me explain quickly how it works right now. 

First of all for those who didn't know LLVM is a compiler infrastructure. You 
can read about it on http://llvm.org . The primary thing we're interested 
from LLVM right now are the optimization passes.

Those optimization passes are especially important in Gallium3D.

So here's the way it works right now. 

"linux-llvm" has been added for now. You need to make linux-llvm to actually 
get Gallium3D to use LLVM. It's done to not disrupt other targets for now.

Now if MESA_LLVM is defined, the state tracker on compilation of vertex 
shaders passes the created TGSI into ga_llvm_from_tgsi() function which 
returns a struct ga_llvm_prog. In that function TGSI is being compiled into 
LLVM IR, subsequently LLVM optimization passes are being run over it and once 
the optimal LLVM IR is available we get the LLVM to generate executable code 
at runtime from it and return the entry point to our shader.

Later in the draw module on vertex flush, draw_vertex_shader_queue_flush_llvm 
is invoked. That function, after fetching the vertices to be flushed, passes 
control to ga_llvm_prog_exec which actually invokes the code LLVM code 
generated.

The entry point to LLVM is auto-generated from a C file right now. 
llvm_builtins.c is being compiled with clang (new LLVM C frontend) into LLVM 
code stubs which are being stored in llvm_base_shader.cpp. Since clang didn't 
have an official release quite yet, I've committed the generated 
llvm_base_shader.cpp file.

LLVM is in C++, which I know has a very serious negative connotation among 
many low-level developers, but the interface to the LLVM module in Gallium3D 
is very thin and C only. It's only the llvmtgsi.h file that composes the 
Gallium3D wide shading interface to LLVM. 

There's still lots of work to do but everything except the GLSL opcodes works 
already and LLVM optimizes it quite beautifully. So one can be running 
glxgears all night long which in my opinion is really the main reason for 
having a 3D framework anyway.

If anyone has any questions about how any of this works, I'll do my best to 
answer any of them. I'll also be adding proper documentation for this stuff 
so those who care about it at all will be able to get a little more in-depth 
analysis of what's happening internally.  Otherwise you shouldn't be affected 
by this... At least for now.

z

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to