<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><i>I see precision qualifiers being parsed and stored in the AST, but I<br>
don't see where this information is passed to the IR: ir_variable or<br>
glsl_type don't have this info, in fact,<br>
apply_type_qualifier_to_variable() in ast_to_hir.cpp seems to ignore the<br>
ast precision qualifier data completely.</i><br></blockquote><div><br></div><div>Correct, precision is blissfully ignored in Mesa IR.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><i>So I am guessing that we should add precision information to the<br>
glsl_type, but I wonder if there is a reason why this hasn't been done<br>
yet</i><br></blockquote><div><br></div><div>I did add precision support for glsl-optimizer (<a href="https://github.com/aras-p/glsl-optimizer">https://github.com/aras-p/glsl-optimizer</a>) which is a fork of Mesa.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div></div><div><br></div>-- <br><div class="gmail_signature">Aras Pranckevičius<br>work: <a href="http://unity3d.com">http://unity3d.com</a><br>home: <a href="http://aras-p.info">http://aras-p.info</a></div><div class="gmail_signature"><br></div>
</div></div>