Reputation: 77
I want to apply PCF for my shadows and for that I need to set my shadow map texture format to DXGI_FORMAT_R24_UNORM_X8_TYPELESS
. After setting I cannot run my program , it crashes without any errors. I think the reason is that my GPU dont suppotrs that format and for that I want to check for format support. See enter link description here
Here is my code
UINT pSup;
result = device->CheckFormatSupport(DXGI_FORMAT_R24_UNORM_X8_TYPELESS,&pSup);
if (result != S_OK)
{
MessageBox(NULL, L"Dont support that format", L"Error", MB_OK);
}
But How to work with pSup
. I need to check if it supports D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON
, D3D11_FORMAT_SUPPORT_RENDER_TARGET
and D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
.
See also enter link description here
Upvotes: 1
Views: 547
Reputation: 1009
I cannot believe this: "After setting I cannot run my program , it crashes without any errors"
Run in Debug mode and go step by step to check at which line the programm crashes.
device->CheckFormatSupport(DXGI_FORMAT_R24_UNORM_X8_TYPELESS,&pSup);
Windows says that the function ORs the values.
So you just need to AND the D3D11_FORMAT_SUPPORT you want. For Example checking if given format is supported for my depthstencil and RenderTargetView:
if(pSup & D3D11_FORMAT_SUPPORT_RENDER_TARGET)
{
//render target supports that type
}
if(pSup & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL)
{
//depth stencil supports that type
}
Back to your Problem, i don't think that it's a support Problem of your hardware. You're talking about shadows and PCF. So i think you don't need the stencil bits. So do not use DXGI_FORMAT_R24_UNORM_X8_TYPELESS as format.
When rendering a shadow map you want as much precision as possible, so use:
Good luck.
Upvotes: 2