Jump to content
  • Advertisement
Sign in to follow this  
BuraCULa

Texture2D load problem in CS

This topic is 2463 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. I am trying to implement deferred shading technique.I am encoding my normals into a render target in pixel shader.Then i am bounding shader resource view of this resource to the compute shader.In PIX, i can see that the surface is bounded to CS so everything works fine but when i try to sample any normal data it just returns "0". Here is my simple code but it doesn't work.As you can guess it is just filling surface with blue.
#define TILE_SIZE 16
RWTexture2D<float4> gOutTexture : register(u0);
Texture2D<float2> gInputTexture : register(t0);
/*---------------------
COMPUTE SHADER FUNC
----------------------*/
[numthreads(TILE_SIZE,TILE_SIZE,1)]
void DeferredShadingCS(uint3 groupId : SV_GroupID,
uint3 dispatchThreadId : SV_DispatchThreadID,
uint3 groupThreadId : SV_GroupThreadID
)
{
float2 data = gInputTexture.Load(uint3(dispatchThreadId.xy,0));
gOutTexture[dispatchThreadId.xy] = float4(data,1,1);
}

Share this post


Link to post
Share on other sites
Advertisement
Do you still have the texture bound as a render target? You'll need to unset it as a render target before you bind it as a shader resource view for any pipeline stage, otherwise it will get set to NULL by the runtime. If you aren't already, you should create your device with the D3D11_CREATE_DEVICE_DEBUG flag. This will cause the runtime to output warning/error messages to the debug output that will tell you about problems like this.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!