DXGI_FORMAT_R8G8B8A8_UNORM problem

Started by
0 comments, last by DieterVW 13 years, 4 months ago
Hi, all
I want to use directcompute to copy a texture to a struct buffer,
so I first created a texture2d use DXGI_FORMAT_R8G8B8A8_UNORM,
the shader code is as follows
Texture2D<uint> Input : register( t0 );
RWStructuredBuffer<uint> g_OutBuff : register( u0 );
[numthreads( 1, 1, 1 )]
void convert( uint3 nGid : SV_GroupID)
{
g_OutBuff[nGid.y*nWidth+nGid.x] =Input[nGid.xy];
}
so, I want to know what is the value of Input[nGid.xy]?
I refer to the msdn but i can not unstand it clearly.
thanks!
Advertisement
Resources can't be casted to different numbers of components. So your R8G8B8A8 texture will always be read into the shader as a for component vector. When you type the shader resource as a Texture2D<uint> in the shader code it effectively limits you to reading the r channel only into the 32 bits. All other bits would be zero.

You'll have to read the R8G8B8A8 vector into the shader and pack it into a single uint32 yourself and store that into the structured buffer.

This topic is closed to new replies.

Advertisement