<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Dec 17, 2013 at 10:59 AM, Paul Berry <span dir="ltr"><<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="im">On 17 December 2013 08:46, Tom Stellard <span dir="ltr"><<a href="mailto:tom@stellard.net" target="_blank">tom@stellard.net</a>></span> wrote:<br>
</div><div class="gmail_extra"><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>On Tue, Dec 17, 2013 at 09:57:31AM -0600, Patrick Baggett wrote:<br>
> Hi all,<br>
><br>
> Is there a way to see the machine code that is generated by the GLSL<br>
> compiler for all GPU instruction sets? For example, I would like to know if<br>
> the optimizer optimizes certain (equivalent) constructs (or not), and avoid<br>
> them if possible. I know there is a lot to optimization on GPUs that I<br>
> don't know, but I'd still like to get some ballpark estimates. For example,<br>
> I'm curious whether:<br>
<br>
</div>Each driver has its own environment variable for dumping machine code.<br>
<br>
llvmpipe: GALLIVM_DEBUG=asm (I think you need to build mesa<br>
                             with --enable-debug for this to work)<br>
r300g: RADEON_DEBUG=fp,vp<br>
r600g, radeonsi: R600_DEBUG=ps,vs<br>
<br>
I'm not sure what the other drivers use.<br>
<br>
-Tom<br></blockquote><div><br></div></div><div>I believe every driver also supports MESA_GLSL=dump, which prints out the IR both before and after linking (you'll want to look at the version after linking to see what optimizations have been applied, since some optimizations happen at link time).  Looking at the IR rather than the machine code is more likely to give you the information you need, since Mesa performs the same IR-level optimizations on all architectures, whereas the optimizations that happen at machine code level are vastly different from one driver to the next.<br>

<br></div></div></div></div></blockquote><div><br></div><div>I do want to see both, actually. For example, if a driver implements a specific optimization (machine code level) and another driver clearly does not, then that would be considered "interesting" to me.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div>Another thing which might be useful to you is Aras Pranckevičius's "glsl-optimizer" project (<a href="https://github.com/aras-p/glsl-optimizer" target="_blank">https://github.com/aras-p/glsl-optimizer</a>), which performs Mesa's IR-level optimizations on a shader and then translates it from IR back to GLSL.<span class="HOEnZb"><font color="#888888"><br>

<br></font></span></div><span class="HOEnZb"><font color="#888888"><div>Paul<br></div></font></span><div class="im"><div><br></div></div></div></div></div></blockquote><div><br></div><div>Thanks to everyone for the great tips!</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="im"><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<div><br>
><br>
>     //let p1, p2, p3 be vec2 uniforms<br>
><br>
>     vec4(p1, 0, 0) + vec4(p2, 0, 0) + vec4(p3, 0, 1)<br>
><br>
> produces identical machine code as:<br>
><br>
>     vec4(p1+p2+p3, 0, 1);<br>
><br>
> for all architectures supported by Mesa.<br>
<br>
</div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div><br></div></div>
</blockquote></div><br></div></div>