[Mesa-dev] GLSL IR representation of EmitVertex

Vincent Lejeune vljn at ovi.com
Thu Aug 18 12:02:20 PDT 2011


I would like to have several opinions about the implementation (on the frontend side) of EmitVertex() function.

Prototype of the function is :
void EmitVertex();

It is only available when writing Geometry Shader Code, it acts as a beacon saying the GPU to generate a vertex according to gl_Position/gl_FrontColor,... defined at the time of calling.
The syntax of EmitVertex is the syntax of a function and is recognised as such by the parser, which is fine. However having it considered as a function when building GLSL high level tree is more problematic :
At link stage all function calls are currently inlined, but EmitVertex has no body. This would requires to add lots of guards statements all over optimisations/lowering passes, which is not the most elegant solution IMHO.

Builtins function are mostly wrapper around operators, which allow to have them parsed as functions and transparently emitted as native hardware opcode later.
Such a solution would need to add some "0 operator" that can be passed to an ir_expression*. If this solution might work, it is unsafe on the semantic side of things : Operators are meant to "operate" on something and above all, expressions are rvalue that might be reordered whereas EmitVertex is a side effect function and not an rvalue.

A third solution is to have another ir_* node type in ir.h to reflect the specificities of the EmitVertex function (and might be used for RestartPrimitive as well). This is the most safe solution on the long term but it is likely to break stuff at early developement step : adding another node has impact in the overall compiling/linking process.



More information about the mesa-dev mailing list