[Mesa-dev] GLSL and alternative square matrix constructor, mat3x3 in Mesa
Eric Anholt
eric at anholt.net
Mon Aug 16 20:30:38 PDT 2010
On Tue, 10 Aug 2010 22:11:22 +0400, randrianasulu at gmail.com wrote:
> Hello all!
>
> Today i dived into GLSL for first time, so sorry if i write something stupid.
>
> One user at #radeon (nick <papillon81>) asked why some shade doesn't work.
>
> Here is link to vertex shader as i saw it today:
>
> http://mapserver.flightgear.org/git/gitweb.pl?p=fgdata;a=blob;f=Shaders/3dcloud.vert;h=135658ddb12c83e0652c85181f92575eeb06cf50;hb=HEAD
>
> With unmodified Mesa master (after commit what enabled OpenGL 2.1/GLSL 1.20
> for r600 in master) there was error:
...
>
> And finally after modifying shader it compiles sucessfully:
> we changed line 40
> from
> normalize(mat3x3(gl_ModelViewMatrix) * (- gl_Position.xyz)));;
> into
> normalize(vec3(gl_ModelViewMatrix * vec4(- gl_Position.xyz,0.0))));;
Looks like you've found a workaround for Mesa 7.8. For GLSL2, both
versions should work and produce equivalent code. It turns out that a
lot of people use your workaround code on the assumption that the mat3x3
constructor is more expensive than the possible extra math, so I added
an optimization pass to handle that.
You could verify that the code is the same on intel hardware by looking
at the output of the app with INTEL_DEBUG=vs in the environment. You
can use MESA_GLSL=dump on any hardware, but it dumps out before the copy
propagation and dead code elimination of _mesa_optimize_program(), so
counting instructions there can be misleading.
-------------- 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/20100816/ce938002/attachment.pgp>
More information about the mesa-dev
mailing list