
238 GPGPU Programming for Games and Science
struct MyMatrix { float4x4 A; } ;
StructuredBuffer<MyMatrix> input ; // 1 e l em en t
RWTexture1D<float> output ; // 16 elements
[numthreads(1,1,1)]
void CSMai n ( i nt3 t : S V
DispatchThreadID)
{
for ( int j=0,k=0; j< 4; ++j )
{
for ( int i=0; i< 4 ; ++ i , ++k )
{
output [k] = input [0].A[ j ][ i ];
}
}
}
LISTING 5.4: A compute shader program that fetches a matrix from a
structured buffer with a struct that has a single member
float4x4.
The output from
FXC using /Zpr is shown in Listing 5.5. The ld structured indexable
instruction was manually split across lines to fit in the width of the page.
//
// Generated by Microsoft ...