From d5367253204887c14b52fd6b64eda3e94559bdee Mon Sep 17 00:00:00 2001 From: Francesco Pretto Date: Mon, 18 Dec 2017 22:27:20 +0100 Subject: [PATCH] Set the render target view to sRGB format (#68) This allows to correctly sample from sRGB textures and write back correct colors to backbuffer. Also work with linear RGB textures --- DDSView/ddsview.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DDSView/ddsview.cpp b/DDSView/ddsview.cpp index 7476c39..84b8c2c 100644 --- a/DDSView/ddsview.cpp +++ b/DDSView/ddsview.cpp @@ -385,7 +385,11 @@ HRESULT InitDevice( const TexMetadata& mdata ) if( FAILED( hr ) ) return hr; - hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, nullptr, &g_pRenderTargetView ); + D3D11_RENDER_TARGET_VIEW_DESC vd; + ZeroMemory(&vd, sizeof(vd)); + vd.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; + vd.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; + hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, &vd, &g_pRenderTargetView ); pBackBuffer->Release(); if( FAILED( hr ) ) return hr;