Pergunta

I do understand a little on the concept of the pixel format for the back buffer. However, what's the difference between using the unknown format and a specified format:

(In DirectX 11) DXGI_FORMAT_UNKNOWN vs DXGI_FORMAT_R8G8B8A8_UNORM

(In DirectX 9) D3DFMT_UNKNOWN vs D3DFMT_X8R8G8B8

Does the unknown format allow the graphics adapter to choose the most appropriate format or something?

Thanks!

EDIT:

I've tried the unknown format in DirectX 9 and it works:

D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof( d3dpp ) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferHeight = 480;
d3dpp.BackBufferWidth = 640;
d3dpp.hDeviceWindow = mHWnd;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.EnableAutoDepthStencil = TRUE;

I've tried the unknown format in DirectX 11 and it doesn't work:

DXGI_SWAP_CHAIN_DESC sd;
sd.BufferDesc.Width = 640;
sd.BufferDesc.Height = 480;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_UNKNOWN;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 1;
sd.OutputWindow = mhMainWnd;
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
Foi útil?

Solução

You are running in windowed mode. From the DirectX9 docs:

In fact, D3DFMT_UNKNOWN can be specified for the BackBufferFormat while in windowed mode. This tells the runtime to use the current display-mode format and eliminates the need to call GetDisplayMode.

So there, D3DFMT_UNKNOWN just means "use the current display setting". DirectX 11 doesn't seem to support that, and the documentation about the modes there (and how you're supposed to create the swap chain) are a bit more complex. I think you can choose your BackBufferFormat in DirectX11 regardless of the actual display format and conversion will automatically occur. Probably 99% of all displays now are set to an X8R8G8B8 format anyway, I suppose.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top