I want to use PCF shadow map on my d3d11 app. My shadow map is an R16_FLOAT texture. When I use SampleCmpLevelZero it didn't give a correct result. After enabling debug layer, it shows:
The Shader Resource View in slot 1 of the Pixel Shader unit is using the Format (R16_FLOAT). This format does not support 'SampleCmp' or 'SampleCmpLevelZero', at least one of which is being used on the Resource by the shader. This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching).
But when I query whether the format support SampleCmp using the code below, it returns 0 which means success. Can someone explain why?
bool Renderer::InitRenderer(HWND hwnd)
{
if (!InitD3D11App(hwnd)) return false;
InitViewport();
UINT formatSupport = D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON;
printf("Support?\n");
HRESULT hr = d3d11Device->CheckFormatSupport(DXGI_FORMAT_R16_FLOAT, &formatSupport);
printf("result: %d\n", hr);
if (!SUCCEEDED(hr))
{
printf("Nope!\n");
return false;
}
return true;
}