This page explains how to use open-gpu-tools to generate the required shaders for the limare port of Quake 3 Arena to run without using the binary compiler. The shaders have been hand-converted from ESSL (the input of the binary compiler) to a custom assembly/IR, and so some playing around/learning/reading the source is necessary in order to understand how the shaders work.

Setting up open-gpu-tools

Clone my open-gpu-tools tree, and switch to the ir branch. Compile libcommon.so by cd'ing to the common directory and running make. Same thing with ir_tools and assemble.

Fragment shaders

The fragment shaders are written in assembly, meaning that you have to use the use the assemble tool to generate a working MBS file. To assemble a shader ~/my_shader.in into an mbs file ~/my_shader.mbs, from the assemble directory do:

./assemble -a lima_pp -s verbose -t fragment -o ~/my_shader.mbs ~/my_shader.in

Vertex shaders

The vertex shaders are compiled from gp_ir, meaning you need to use the ir_tools to compile it to MBS. To parse an input shader ~/my_shader.in into a binary gp_ir file ~/my_shader.ir, from the ir_tool directory do:

./ir_parse -i lima_gp_ir -o ~/my_shader.ir ~/my_shader.in

And to compile that to MBS, do:

./ir_lower -i lima_gp_ir -a lima_gp -f mbs -o ~/my_shader.mbs ~/my_shader.ir