先看dx sdk原文,
The data in a matrix is loaded into shader constant registers before a shader
runs. There are two choices for how the matrix data is read: in row-major order
or in column-major order. Column-major order means that each matrix column will
be stored in a single constant register, and row-major order means that each row
of the matrix will be stored in a single constant register. This is an important
consideration for how many constant registers are used for a matrix.
Row-major and column-major matrix ordering determine the order the matrix
components are read from the constant table or from shader inputs. Once the data
is written into constant registers, matrix order has no effect on how the data
is used or accessed from within shader code. Also, matrices declared in a shader
body do not get packed into constant registers.
解释:
这个row-major和column-major,只是决定你提供给shader的矩阵如何被理解,如果存入寄存器。举个例子,shader code中有column-major的float4x3
matWorld,那么你设置的时候提供一个4×3的矩阵,这个矩阵将占3个float4的寄存器,每列占一个,进行乘法计算的时候,必须是mul(pos,matWorld),也就是pos左乘这个矩阵。
如果shader中一个row-major的float3×4的矩阵,也占3个寄存器,乘法的时候是mul(matWorld,pos),就是pos右乘矩阵。
上面做法效率一样,结果一样。
如果,你混淆着瞎来,结果不是你想要的,就是占多寄存器之类。。。。
posted on 2007-09-27 09:48
Sherk 阅读(1204)
评论(0) 编辑 收藏 引用