Quote:Original post by SnakeHunta
Ok, my question is what is the difference between row-major packing and column major packing when setting vertex shader constants? Now I know that row-major is like so:
Err...Seems like I answered another question with my previous post. Anyway:
The difference as the docs say, is in the way the effect compiler interprets/reads the matrix data from the constant table into the registers.
If you tell it it's column-major packing, it'll assume each constant contains a column, and thus transformations can easily be done as 4 dot products.
If you tell it it's row-major packing, it'll assume so, and would generate code for transformations based on that. The documentation cites an example:
float4x3 World;float4 main(float4 pos : POSITION) : POSITION{ float4 val; val.xyz = mul(pos,World); val.w = 0; return val;}
With column-major packing, you get this asm:
vs_2_0def c3, 0, 0, 0, 0dcl_position v0m4x3 oPos.xyz, v0, c0mov oPos.w, c3.x// approximately four instruction slots used
IIRC, m4x3 is a macro that's equivalent to 3 dot products, but its use clarifies the purpose of the code (to do a transformation).
With row-major packing:
vs_2_0def c4, 0, 0, 0, 0dcl_position v0mul r0.xyz, v0.x, c0mad r2.xyz, v0.y, c1, r0mad r4.xyz, v0.z, c2, r2mad oPos.xyz, v0.w, c3, r4mov oPos.w, c4.x// approximately five instruction slots used
As you can see, the compiler had to do the transformation in a different way (not 3 dot products), which took more instructions lots.