Hello
I'm trying to do some dynamic blending in a pixel shader. This is on DX 11. I created the swap chain with DXGI_USAGE_UNORDERED_ACCESS and DXGI_FORMAT_R8G8B8A8_UNORM format. The idea is to have a pixel shader with no declared output but instead read read/write to a RWTexture2D inside the shader.
However I'm having a bit of a problem to declare the RWTexture2D. What type should it be, uint doesn't work? I get the error message:
The resource return type for component 0 declared in the shader code (UINT) is not compatible with the resource type bound to Unordered Access View slot 0 of the Pixel Shader unit (UNORM). This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). [ EXECUTION ERROR #2097372: DEVICE_UNORDEREDACCESSVIEW_RETURN_TYPE_MISMATCH]
And if I try to create the UAV with a different format I get errors like this:
The Format (0x1e, R8G8B8A8_UINT) is invalid, when creating a View; the Resource was already created with a fully qualified Format, which is not castable (0x1c, R8G8B8A8_UNORM). [ STATE_CREATION ERROR #2097343: CREATEUNORDEREDACCESSVIEW_INVALIDFORMAT]
So how can I resolve this? Is there a correct way to declare the texture in the shader or should handle the setup on the CPU in a different way?
Thanks!