@@ -271,15 +271,9 @@ bool CHW::CreateSwapChain(HWND hwnd)
271271 sd.BufferDesc .Height = Device.dwHeight ;
272272
273273 // TODO: DX11: implement dynamic format selection
274- constexpr DXGI_FORMAT formats[] =
275- {
276- // DXGI_FORMAT_R16G16B16A16_FLOAT, // Do we even need this?
277- // DXGI_FORMAT_R10G10B10A2_UNORM, // D3DX11SaveTextureToMemory fails on this format
278- DXGI_FORMAT_R8G8B8A8_UNORM,
279- };
274+ sd.BufferDesc .Format = selectBackBufferFormat ();
280275
281276 // Select back-buffer format
282- sd.BufferDesc .Format = SelectFormat (D3D_FORMAT_SUPPORT_DISPLAY, formats);
283277 Caps.fTarget = dx11TextureUtils::ConvertTextureFormat (sd.BufferDesc .Format );
284278
285279 // Buffering
@@ -329,16 +323,8 @@ bool CHW::CreateSwapChain2(HWND hwnd)
329323 desc.Width = Device.dwWidth ;
330324 desc.Height = Device.dwHeight ;
331325
332- constexpr DXGI_FORMAT formats[] =
333- {
334- // DXGI_FORMAT_R16G16B16A16_FLOAT,
335- // DXGI_FORMAT_R10G10B10A2_UNORM,
336- DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
337- // DXGI_FORMAT_R8G8B8A8_UNORM,
338- };
326+ desc.Format = selectBackBufferFormat ();
339327
340- // Select back-buffer format
341- desc.Format = SelectFormat (D3D11_FORMAT_SUPPORT_DISPLAY, formats);
342328 Caps.fTarget = dx11TextureUtils::ConvertTextureFormat (desc.Format );
343329
344330 // Buffering
@@ -389,6 +375,31 @@ bool CHW::CreateSwapChain2(HWND hwnd)
389375 return false ;
390376}
391377
378+ DXGI_FORMAT CHW::selectBackBufferFormat () const
379+ {
380+ if (ps_r3_rendering_space == 1 )
381+ {
382+ constexpr DXGI_FORMAT formats[] = {
383+ // DXGI_FORMAT_R16G16B16A16_FLOAT,
384+ // DXGI_FORMAT_R10G10B10A2_UNORM,
385+ DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
386+ // DXGI_FORMAT_R8G8B8A8_UNORM,
387+ };
388+
389+ // Select back-buffer format
390+ return SelectFormat (D3D11_FORMAT_SUPPORT_DISPLAY, formats);
391+ } else {
392+ constexpr DXGI_FORMAT formats[] = {
393+ // DXGI_FORMAT_R16G16B16A16_FLOAT,
394+ // DXGI_FORMAT_R10G10B10A2_UNORM,
395+ DXGI_FORMAT_R8G8B8A8_UNORM,
396+ };
397+
398+ // Select back-buffer format
399+ return SelectFormat (D3D11_FORMAT_SUPPORT_DISPLAY, formats);
400+ }
401+ }
402+
392403bool CHW::ThisInstanceIsGlobal () const
393404{
394405 return this == &HW;
@@ -439,6 +450,7 @@ void CHW::Reset()
439450 DXGI_MODE_DESC& desc = m_ChainDesc.BufferDesc ;
440451 desc.Width = Device.dwWidth ;
441452 desc.Height = Device.dwHeight ;
453+ desc.Format = selectBackBufferFormat ();
442454
443455 CHK_DX (m_pSwapChain->ResizeTarget (&desc));
444456 CHK_DX (m_pSwapChain->ResizeBuffers (
0 commit comments