From 5452e8da71fa7b7fe3d65a1276caac97188039e3 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 27 Aug 2014 08:07:54 +0100 Subject: [PATCH] Apply same DXGI_FORMAT_UNKNOWN hack to SRV creation as to RTVs --- renderdoc/driver/d3d11/d3d11_device_wrap.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp index c74da92e1..c7b97a8c6 100644 --- a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp @@ -655,6 +655,17 @@ bool WrappedID3D11Device::Serialise_CreateShaderResourceView( backbufferTypedDesc.Texture2D.MostDetailedMip = 0; pDesc = &backbufferTypedDesc; } + + // if we have a descriptor but it specifies DXGI_FORMAT_UNKNOWN format, that means use + // the texture's format. But as above, we fudge around the typeless backbuffer so we + // have to set the correct typed format + // + // This behaviour is documented only for render targets, but seems to be used & work for + // SRVs, so apply it here too. + if(pDesc && pDesc->Format == DXGI_FORMAT_UNKNOWN && WrappedID3D11Texture2D::IsAlloc(live) && tex2d->m_RealDescriptor) + { + pDesc->Format = tex2d->m_RealDescriptor->Format; + } HRESULT hr = m_pDevice->CreateShaderResourceView(GetResourceManager()->UnwrapResource(live), pDesc, &ret); @@ -886,7 +897,7 @@ bool WrappedID3D11Device::Serialise_CreateRenderTargetView( // if we have a descriptor but it specifies DXGI_FORMAT_UNKNOWN format, that means use // the texture's format. But as above, we fudge around the typeless backbuffer so we // have to set the correct typed format - if(HasDesc && pDesc->Format == DXGI_FORMAT_UNKNOWN && tex2d->m_RealDescriptor) + if(pDesc && pDesc->Format == DXGI_FORMAT_UNKNOWN && WrappedID3D11Texture2D::IsAlloc(live) && tex2d->m_RealDescriptor) { pDesc->Format = tex2d->m_RealDescriptor->Format; }