I'm getting this error when trying to dispatch a compute shader that does some writes to a 3D texture:
ID3D11DeviceContext::Dispatch: The resource return type for component 0 declared in the shader code (FLOAT) is not compatible with the resource type bound to Unordered Access View slot 0 of the Compute 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]
The (shortened) compute shader (full one here):
RWTexture3D<float4> gOutputTex;
[numthreads(8, 8, 1)]
void csmain(uint3 dispatchThreadId : SV_DispatchThreadID)
{
float3 gammaColor = ...;
gOutputTex[dispatchThreadId] = float4(gammaColor, 1.0f);
}
UAV format is set to DXGI_FORMAT_R8G8B8A8_UNORM.
To me this feels like it should work, write as float and the hardware converts it to an 8-bit integer (it certainly works with render targets). And if I ignore the reported error, it does in fact render fine on my machine. Also I'm pretty sure this code ran fine without errors until some recent OS/driver update (but I might be wrong).
I can't find anything about this on MSDN or elsewhere on the web. Am I forced to use "uint" in the shader and manually convert from float? Anyone has any insight?