#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);
}
Texture2D load problem in CS
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement