Jump to content
  • Advertisement
Sign in to follow this  
mliu

DXGI_FORMAT_R8G8B8A8_UNORM problem

This topic is 2761 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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.
thanks!

Share this post


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!