Sign in to follow this  


Recommended Posts

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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this