[Mesa-dev] Precision qualifiers in the IR

Aras Pranckevicius aras at unity3d.com
Thu Jan 8 03:54:18 PST 2015


>
>
>
>
>
> *I see precision qualifiers being parsed and stored in the AST, but I
> don't see where this information is passed to the IR: ir_variable or
> glsl_type don't have this info, in fact, apply_type_qualifier_to_variable()
> in ast_to_hir.cpp seems to ignore the ast precision qualifier data
> completely.*
>

Correct, precision is blissfully ignored in Mesa IR.



>
>
> *So I am guessing that we should add precision information to the
> glsl_type, but I wonder if there is a reason why this hasn't been done yet*
>

I did add precision support for glsl-optimizer (
https://github.com/aras-p/glsl-optimizer) which is a fork of Mesa.

I forgot why I did not make precision be part of the type to be honest, but
I think there was some reason. Maybe because a ton of places in Mesa do
things like "get me a float type", and changing all these places to deal
with 4x more types (unspecified, low, medium, high) did not sound attactive.

So what I did is ir make ir_rvalues and ir_variables have precision (and a
few other oddball things, like return type of ir_function_signature). And
then in places that construct rvalues or variables, the precision is
determined. In some cases that comes directly from AST, in other cases
(e.g. results of optimization passes) it comes from "higher precision of
things being operated upon" (e.g. result of a+b is higher precision of the
arguments), etc.

And then I tweaked some optimization passes to stop applying optimizations
across different precision. For example, tree grafting should not paste
subtrees into other places, if precision is different there.

Not sure if my approach (precision as not part of type, but
rvalues+variables) is a good one, but seems to work so far in
glsl-optimizer.


-- 
Aras Pranckevičius
work: http://unity3d.com
home: http://aras-p.info
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150108/c51b864d/attachment.html>


More information about the mesa-dev mailing list