Apply same DXGI_FORMAT_UNKNOWN hack to SRV creation as to RTVs

This commit is contained in:
baldurk
2014-08-27 08:07:54 +01:00
parent d7ffb16a72
commit 5452e8da71
+12 -1
View File
@@ -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;
}