[Mesa-dev] [PATCH] Remove ir_binop_dot optimization from glsl TODO

Eric Anholt eric at anholt.net
Mon Jun 4 17:33:43 CEST 2012


On Sun, 03 Jun 2012 18:12:05 -0400, Matt Turner <mattst88 at gmail.com> wrote:
> On Sun, 2012-06-03 at 14:30 -0700, Kenneth Graunke wrote:
> > On 06/03/2012 10:15 AM, Matt Turner wrote:
> > > It seems that we already do this.
> > > ---
> > >  src/glsl/TODO |    3 ---
> > >  1 files changed, 0 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/src/glsl/TODO b/src/glsl/TODO
> > > index eb73fc2..bd077a8 100644
> > > --- a/src/glsl/TODO
> > > +++ b/src/glsl/TODO
> > > @@ -6,9 +6,6 @@
> > >    constant index values.  For others it is more complicated.  Perhaps these
> > >    cases should be silently converted to uniforms?
> > >  
> > > -- Implement support for ir_binop_dot in opt_algebraic.cpp.  Perform
> > > -  transformations such as "dot(v, vec3(0.0, 1.0, 0.0))" -> v.y.
> > > -
> > >  - Track source locations throughout the IR.  There are currently several
> > >    places where we cannot emit line numbers for errors (and currently emit 0:0)
> > >    because we've "lost" the line number information.  This is particularly
> > 
> > We do?  Considering there's no instance of ir_binop_dot in
> > opt_algebraic.cpp, I'm a bit skeptical :)
> 
> I could of course be mistaken, but consider the following fragment
> shader:
> 
> varying vec3 light;
> void main() {
> 	const vec4 DiffuseColor = vec4(0.9, 0.9, 0.9, 1.0);
> 	float DiffuseTerm = dot(vec3(0.0, 1.0, 0.0), light);
> 	gl_FragColor = DiffuseColor * DiffuseTerm;
> }
> 
> From this, we generate this GLSL IR:
> 
> (
> (declare (temporary ) float light_y)
> (declare (out ) vec4 gl_FragColor)
> (function main
>   (signature void
>     (parameters
>     )
>     (
>       (assign  (x) (var_ref gl_FragColor)  (expression float * (constant
> float (0.900000)) (var_ref light_y) ) ) 
>       (assign  (y) (var_ref gl_FragColor)  (expression float * (constant
> float (0.900000)) (var_ref light_y) ) ) 
>       (assign  (z) (var_ref gl_FragColor)  (expression float * (constant
> float (0.900000)) (var_ref light_y) ) ) 
>       (assign  (w) (var_ref gl_FragColor)  (var_ref light_y) ) 
>     ))
> 
> )
> )
> 
> I don't claim to understand how (obviously there's no ir_binop_dot in
> opt_algebraic.cpp, so) but it looks like we're already getting the
> result of the TODO.
> 
> The other part that I thought opt_algebraic.cpp's ir_binop_dot case
> should handle was zero vectors, but they're already handled as well. I
> presume because dot is lowered into mul/madd which already handle zero
> vectors.
> 
> Does this sound right, or did I miss some piece?

The i965 fragment shader breaks everything down to scalar operations, at
which point the dot to swizzle thing falls out.  The TODO I think meant
doing it in the general vec4 IR case.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120604/dbc1fa42/attachment.pgp>


More information about the mesa-dev mailing list