[Mesa-dev] [PATCH 4/4] glsl: Add implementation of inverse() for mat2/3/4.

Eric Anholt eric at anholt.net
Thu Apr 19 12:33:03 PDT 2012


On Thu, 19 Apr 2012 08:34:01 -0600, Brian Paul <brianp at vmware.com> wrote:
> On 04/18/2012 07:40 PM, Eric Anholt wrote:
> > +   float det = (+ m[0][0] * adj[0][0]
> > +		+ m[0][1] * adj[1][0]
> > +		+ m[0][2] * adj[2][0]
> > +		+ m[0][3] * adj[3][0]);
> > +
> > +   return adj / det;
> 
> Would something like this be more efficient:
> 
>    vec4 inv_det4 = vec4(1.0 / det);
>    adj[0] *= inv_det4;
>    adj[1] *= inv_det4;
>    adj[2] *= inv_det4;
>    adj[3] *= inv_det4;
> 
>    return adj;
> 
> Actually, I just tried it and it saves 3 RCP instructions (in TGSI).

For hardware without native DIVs, yeah.  For hardware with DIVs, no.
The right fix IMO is to write CSE so that you get the optimized path
whether you have DIVs or not.
-------------- 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/20120419/b64dea53/attachment.pgp>


More information about the mesa-dev mailing list