-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Segovia, Benjamin wrote: > Actually, even the computation of rad_angle is ignored at compile time. > > I was also thinking about more optimizations in the final GPU code i.e. > contuining what has been started with the _mesa_optimize function. rather > working directly on the ir tree. Not sure of what is the best strategy. I > actually output random shaders from warsow, openarena and nexuiz. For both > GPU code and native Intel Gen code, there are clear room for improvements. I > am not sure if there are easy to do (compared to pure scalar code, I imagine > the main problem is to handle the swizzling thing). > > So, even with glsl2, optimizing the final GPU code optimization pass would be > still usefull (except if glsl2 properly optimizes everything before)
There will absolutely still be room for chip-specific peephole optimizations. That the way most C compilers work, after all. There are multiple layers of optimization from language and target generic all the way through very, very target specific. At this point we're focused on the target-independent parts of the compiler. We're still generating Mesa's low-level assembly IR as our output. We plan to fix that in later work. > ________________________________________ > From: Brian Paul [bri...@vmware.com] > Sent: Wednesday, July 14, 2010 7:54 AM > To: Segovia, Benjamin > Cc: mesa-dev@lists.freedesktop.org > Subject: Re: [Mesa-dev] Optimizations in mesa shader compiler > > On 07/13/2010 05:46 PM, Segovia, Benjamin wrote: >> To be more precise, >> - The shader compiler present in src/mesa/slang is used. >> >> - The glsl shader (randomly taken on the net) is: >> void main(){ >> const float PI = 3.14159265358979323846264; >> const float angle = 45.0; >> const float rad_angle = angle*PI/180.0; >> vec4 a = gl_Vertex; >> vec4 b = a; >> >> b.x = a.x*cos(rad_angle) - a.y*sin(rad_angle); >> b.y = a.y*cos(rad_angle) + a.x*sin(rad_angle); >> gl_Position = gl_ModelViewProjectionMatrix*b; >> } Ken's recent work in the glsl2 branch causes all of the sin/cos computations to be replaced with constants. The generated IR below is from passing the --dump-lir option to src/glsl/glsl_compiler. All of the built-in functions and variables also appear in the output (not included below), but that should be fixed either this week or next week. During generation of the Mesa assembly IR, I'm pretty sure the (a*b)+(c*d) sequences get turned into a MUL followed by a MAD. Eric was doing some work in that area recently. (function main (signature void (parameters ) ((declare () vec4 b...@0x8a97910) (assign (constant bool (1)) (var_ref b...@0x8a97910) (var_ref gl_ver...@0x88816f0) ) (declare () float assignment_...@0x8a981b8) (assign (constant bool (1)) (var_ref assignment_...@0x8a981b8) (expression float - (expression float * (swiz x (var_ref gl_ver...@0x88816f0) )(constant float (0.707107)) ) (expression float * (swiz y (var_ref gl_ver...@0x88816f0) )(constant float (0.707107)) ) ) ) (assign (constant bool (1)) (swiz x (var_ref b...@0x8a97910) ) (var_ref assignment_...@0x8a981b8) ) (declare () float assignment_...@0x8a988f0) (assign (constant bool (1)) (var_ref assignment_...@0x8a988f0) (expression float + (expression float * (swiz y (var_ref gl_ver...@0x88816f0) )(constant float (0.707107)) ) (expression float * (swiz x (var_ref gl_ver...@0x88816f0) )(constant float (0.707107)) ) ) ) (assign (constant bool (1)) (swiz y (var_ref b...@0x8a97910) ) (var_ref assignment_...@0x8a988f0) ) (declare () vec4 assignment_...@0x8a98c38) (assign (constant bool (1)) (var_ref assignment_...@0x8a98c38) (expression vec4 * (var_ref gl_modelviewprojectionmat...@0x8882a00) (var_ref b...@0x8a97910) ) ) (assign (constant bool (1)) (var_ref gl_posit...@0x887e4e0) (var_ref assignment_...@0x8a98c38) ) )) ) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkw/XJUACgkQX1gOwKyEAw8spgCeKfrjl6NSAEfVnpbi9j8b2L11 arsAnRHCoDH05BmDj2pmWvA/X2k29vZz =K7Uc -----END PGP SIGNATURE----- _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev