Hello, it's AlisdairTW, I had to create another account as gamedev didn't seem to respond to me signing in with Google today for some reason.
Anywho, I have the debug layer enabled, and I am not getting any errors or warnings from it.
I believe I am correctly unbinding and binding the SRV's and UAV's each time I use them, here is the code for when I call the full screen quad, which is the shader I use to write to the Texture2D with the UAV:
const float zero[4] = { 1, 1, 1, 1 };
DX11AppHelper::_pImmediateContext->ClearUnorderedAccessViewFloat(mUAV, zero);
DX11AppHelper::_pImmediateContext->OMSetRenderTargetsAndUnorderedAccessViews(0, NULL, NULL, 0, 1, &mTexture2DUAV, 0); // Bind the Texture2D UAV
DX11AppHelper::_pImmediateContext->IASetInputLayout(mInputLayout);
DX11AppHelper::_pImmediateContext->VSSetShader(mVertexShader, nullptr, 0);
DX11AppHelper::_pImmediateContext->PSSetShader(mPixelShader, nullptr, 0);
DX11AppHelper::_pImmediateContext->PSSetSamplers(0, 1, &mSamplerLinear);
DX11AppHelper::_pImmediateContext->IASetVertexBuffers(0, 1, &mQuadVertexBuffer, &mQuadStride, &mQuadOffset);
DX11AppHelper::_pImmediateContext->IASetIndexBuffer(mQuadIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
DX11AppHelper::_pImmediateContext->DrawIndexed(6, 0, 0); ID3D11UnorderedAccessView* nullUAV = nullptr;
DX11AppHelper::_pImmediateContext->OMSetRenderTargetsAndUnorderedAccessViews(0, nullptr, nullptr, 0, 1, &nullUAV, 0); // UnBind the Texture2D UAV
Here is the code to then execute the second shader, and I am also binding and then unbinding the SRV before and after.
DX11AppHelper::_pImmediateContext->OMSetRenderTargets(1, &_pRenderTargetViews[0], nullptr);
DX11AppHelper::_pImmediateContext->ClearRenderTargetView(_pRenderTargetViews[0], _pClearColour);
DX11AppHelper::_pImmediateContext->IASetInputLayout(,InputLayout);
DX11AppHelper::_pImmediateContext->VSSetShader(mVertexShader, nullptr, 0);
DX11AppHelper::_pImmediateContext->PSSetShader(mPixelShader, nullptr, 0);
DX11AppHelper::_pImmediateContext->VSSetConstantBuffers(0, 1, &,ConstantBuffer);
DX11AppHelper::_pImmediateContext->PSSetConstantBuffers(0, 1, &,ConstantBuffer);
DX11AppHelper::_pImmediateContext->PSSetShaderResources(0, 1, &mTexture2DSRV)); // Bind SRV
DX11AppHelper::_pImmediateContext->IASetVertexBuffers(0, 1, &_pQuadVertexBuffer, &_pQuadStride, &_pQuadOffset);
DX11AppHelper::_pImmediateContext->IASetIndexBuffer(_pQuadIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
DX11AppHelper::_pImmediateContext->UpdateSubresource(DX11AppHelper::_pConstantBuffer, 0, nullptr, &cb, 0, 0);
DX11AppHelper::_pImmediateContext->DrawIndexed(6, 0, 0);
ID3D11ShaderResourceView* nullShaderResourceView nullShaderResourceView = nullptr;
DX11AppHelper::_pImmediateContext->PSSetShaderResources(0, 1, &nullShaderResourceView); // Unbind SRV
I believe I am doing it correctly?
All I am getting on my screen is the cleared white colour of the UAV from the line:
const float zero[4] = { 1, 1, 1, 1 };
DX11AppHelper::_pImmediateContext->ClearUnorderedAccessViewFloat(mUAV, zero);
Which makes me think I am setting the UAV incorrectly for the first shader perhaps?