I have gone thru and "wrapped" the functionality that allows me to create the Buffer, UAV and the SRV for the buffer.
I can set the CS, the UAV and i dispatch, which executes the CS, and i verify the output by copying the UAV to a staging buffer ( ala DX SDK examples ). the UAV contains the expected values.
The problem comes when i try to set the associated Shader Resource View for the buffer. Using pix, the Shader Resource says the buffer is filled with 0's. However, it should be filled with 1's ( just for debug purposes ).
The shader i am using, works if i hard code the values to output, so i know the shader is executing. I have even tried to index into the StructuredBuffer with a constant ( 1 ), so that i know that the threads are not mixing up.
Setting the UAV - This works and has been verified
ID3D11UnorderedAccessView* uav = buffers_[buffer]->GetUnorderedAccess();
immediateContext_->CSSetUnorderedAccessViews(0, 1, &uav, 0);
Passing the Shader Resource to the Shader
ID3D11ShaderResourceView* pFromRV = buffers_[buffer]->GetShaderResource();
ID3D11ShaderResourceView* aRViews[ 1 ] = { pFromRV };
immediateContext_->PSSetShaderResources(0, 1, aRViews);
CopyToFrame Shader - Takes in a buffer, and returns the value
StructuredBuffer<float4> buffer : register( t0 );
cbuffer cbPS : register( b0 ) {
uint4 g_param;
};
void VS(uint VertexID: SV_VertexID, out float2 oTexCoord : TexCoord, out float4 oPosition : SV_Position) {
// Produce a fullscreen triangle
oPosition.x = (VertexID == 2) ? 3.0f : -1.0f;
oPosition.y = (VertexID == 0) ? -3.0f : 1.0f;
oPosition.zw = 1.0f;
oTexCoord = oPosition.xy * float2(0.5f, -0.5f) + 0.5f;
}
void PS(float4 iPosition : SV_Position, out float4 oColor : SV_Target) {
oColor = buffer[1];
}
Thanks for any help you can provide