1

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

harut9
  • 77
  • 6

1 Answers1

2

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:

  • DXGI_FORMAT_R32_TYPELESS for texture
  • DXGI_FORMAT_D32_FLOAT for depthstencil
  • DXGI_FORMAT_R32_FLOAT for ShaderResourceView

Good luck.

kaiser
  • 940
  • 1
  • 10
  • 25
  • I checked and program failed to creat render target because render target cannot be creater with any typless format. I use render target for render to texture technique – harut9 Feb 14 '16 at 06:43
  • That's true, the render target, the depthstencil and the shaderresouceview are all views and views are fully typed. They have to know which format the target is writing, or which format you're reading. Format of texture may be typeless, because it is up to you, how you'll interpret the value of the texture (i.e with a specific shaderresource view). Just as an idea. You may have a texture with a typeless format, so the texture contains any bytes and bits. So maybe you create two SRV one which will interpret the byte data as an UNORM and one that will interpret the data as a FLOAT. – kaiser Feb 14 '16 at 23:30