1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[d3d10] Fix crash in CreateDepthStencilView when pDesc is null

This is legal and we should just pass the null pointer to D3D11.
Should fix a crash in Stalker: Call of Pripyat.
This commit is contained in:
Philip Rebohle 2018-08-14 00:12:53 +02:00
parent 861165f32a
commit dad015bd67
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -287,47 +287,52 @@ namespace dxvk {
Com<ID3D11Resource> d3d11Resource;
GetD3D11Resource(pResource, &d3d11Resource);
// D3D10 doesn't have the Flags member, so we have
// to convert the structure. pDesc can be nullptr.
D3D11_DEPTH_STENCIL_VIEW_DESC d3d11Desc;
d3d11Desc.ViewDimension = D3D11_DSV_DIMENSION(pDesc->ViewDimension);
d3d11Desc.Format = pDesc->Format;
d3d11Desc.Flags = 0;
switch (pDesc->ViewDimension) {
case D3D10_DSV_DIMENSION_UNKNOWN:
break;
case D3D10_DSV_DIMENSION_TEXTURE1D:
d3d11Desc.Texture1D.MipSlice = pDesc->Texture1D.MipSlice;
break;
case D3D10_DSV_DIMENSION_TEXTURE1DARRAY:
d3d11Desc.Texture1DArray.MipSlice = pDesc->Texture1DArray.MipSlice;
d3d11Desc.Texture1DArray.FirstArraySlice = pDesc->Texture1DArray.FirstArraySlice;
d3d11Desc.Texture1DArray.ArraySize = pDesc->Texture1DArray.ArraySize;
break;
case D3D10_DSV_DIMENSION_TEXTURE2D:
d3d11Desc.Texture2D.MipSlice = pDesc->Texture2D.MipSlice;
break;
case D3D10_DSV_DIMENSION_TEXTURE2DARRAY:
d3d11Desc.Texture2DArray.MipSlice = pDesc->Texture2DArray.MipSlice;
d3d11Desc.Texture2DArray.FirstArraySlice = pDesc->Texture2DArray.FirstArraySlice;
d3d11Desc.Texture2DArray.ArraySize = pDesc->Texture2DArray.ArraySize;
break;
case D3D10_DSV_DIMENSION_TEXTURE2DMS:
break;
if (pDesc != nullptr) {
d3d11Desc.ViewDimension = D3D11_DSV_DIMENSION(pDesc->ViewDimension);
d3d11Desc.Format = pDesc->Format;
d3d11Desc.Flags = 0;
case D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY:
d3d11Desc.Texture2DMSArray.FirstArraySlice = pDesc->Texture2DMSArray.FirstArraySlice;
d3d11Desc.Texture2DMSArray.ArraySize = pDesc->Texture2DMSArray.ArraySize;
break;
switch (pDesc->ViewDimension) {
case D3D10_DSV_DIMENSION_UNKNOWN:
break;
case D3D10_DSV_DIMENSION_TEXTURE1D:
d3d11Desc.Texture1D.MipSlice = pDesc->Texture1D.MipSlice;
break;
case D3D10_DSV_DIMENSION_TEXTURE1DARRAY:
d3d11Desc.Texture1DArray.MipSlice = pDesc->Texture1DArray.MipSlice;
d3d11Desc.Texture1DArray.FirstArraySlice = pDesc->Texture1DArray.FirstArraySlice;
d3d11Desc.Texture1DArray.ArraySize = pDesc->Texture1DArray.ArraySize;
break;
case D3D10_DSV_DIMENSION_TEXTURE2D:
d3d11Desc.Texture2D.MipSlice = pDesc->Texture2D.MipSlice;
break;
case D3D10_DSV_DIMENSION_TEXTURE2DARRAY:
d3d11Desc.Texture2DArray.MipSlice = pDesc->Texture2DArray.MipSlice;
d3d11Desc.Texture2DArray.FirstArraySlice = pDesc->Texture2DArray.FirstArraySlice;
d3d11Desc.Texture2DArray.ArraySize = pDesc->Texture2DArray.ArraySize;
break;
case D3D10_DSV_DIMENSION_TEXTURE2DMS:
break;
case D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY:
d3d11Desc.Texture2DMSArray.FirstArraySlice = pDesc->Texture2DMSArray.FirstArraySlice;
d3d11Desc.Texture2DMSArray.ArraySize = pDesc->Texture2DMSArray.ArraySize;
break;
}
}
ID3D11DepthStencilView* d3d11View = nullptr;
HRESULT hr = m_device->CreateDepthStencilView(
d3d11Resource.ptr(), &d3d11Desc,
d3d11Resource.ptr(), pDesc ? &d3d11Desc : nullptr,
ppDepthStencilView ? &d3d11View : nullptr);
if (FAILED(hr))