I'm a bit of a die-hard for assembler shaders, and used to transposing matrices before I pass them via shader constants to the shader.
HOWEVER, with DX10 I am finally biting the bullet and using effects and HLSL.
Now the effects (.fx files) which I have, require the passing of transform matrices to the effect via the effect variables. That's fine, but they don't
require me to transpose them first. Does this mean that the effect is wasting time by doing this transform ? I have usually maintained copies of transforms 'ready transposed' in my code when using shader 3, but it now seems that by using effects there will be an undesirable preprocessing ( albeit small) each time I set the effect variables ?
Am I missing something here ?
Cheers
Effects in DX10, matrix transposes and HLSL
Started by Hawkwind, Jan 30 2008 08:21 AM
4 replies to this topic
#1
Posted 30 January 2008 - 08:21 AM
#2
Posted 30 January 2008 - 09:22 PM
Surely HLSL can, simply, optimise that behind your back ... so instead of using 4 dp4s for a matrix-vector mulitply it can use 4 madds instead?
#3
Posted 30 January 2008 - 09:43 PM
Just in case you don't know you can do a matrix vector multiply with an un-transposed matrix as follows ...
This sorta thing gets abstracted from you with HLSL doesn't it?
mul r0, c0, r1.x mad r0, c1, r1.y, r0 mad r0, c2, r1.z, r0 mad r0, c3, r1.w, r0
This sorta thing gets abstracted from you with HLSL doesn't it?
#4
Posted 30 January 2008 - 10:32 PM
Sure, if I remember it correctly it all depends on whether you use column vectors (m * v) or row vectors (v * m)
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.
-
Currently working on: the 3D engine for Tomb Raider.
#5
Posted 31 January 2008 - 08:27 AM
Thanks - Goz: I didn't know this trick, pretty neat though. I assumed that the matrix had to be transposed, I'll try it out with some old asm shaders. I guess that HLSL will be doing something similar. I just assumed that the m4x4 macro was the only sensible way....
Cheers
Cheers
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












