From e06300d592f17ade25511e4f92a679192f1d8df3 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 4 Apr 2018 11:24:16 +0200 Subject: [PATCH] [d3d11] Fix multisample format support query for depth images Fixes a crash in World of Warships when reflections are enabled. --- src/d3d11/d3d11_context.cpp | 4 +++- src/d3d11/d3d11_device.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 7ca12393..3e57c6ec 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -383,6 +383,7 @@ namespace dxvk { } } + void STDMETHODCALLTYPE D3D11DeviceContext::CopySubresourceRegion1( ID3D11Resource* pDstResource, UINT DstSubresource, @@ -393,9 +394,10 @@ namespace dxvk { UINT SrcSubresource, const D3D11_BOX* pSrcBox, UINT CopyFlags) { - CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, pSrcResource, SrcSubresource, pSrcBox); + CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, pSrcResource, SrcSubresource, pSrcBox); } + void STDMETHODCALLTYPE D3D11DeviceContext::CopyResource( ID3D11Resource* pDstResource, ID3D11Resource* pSrcResource) { diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 82116d95..2c4ed88d 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -1866,7 +1866,6 @@ namespace dxvk { HRESULT D3D11Device::GetFormatSupportFlags(DXGI_FORMAT Format, UINT* pFlags1, UINT* pFlags2) const { const VkFormat fmt = m_dxgiAdapter->LookupFormat(Format, DxgiFormatMode::Any).format; const VkFormatProperties fmtInfo = m_dxvkAdapter->formatProperties(fmt); - if (fmt == VK_FORMAT_UNDEFINED) return E_FAIL; @@ -1939,13 +1938,17 @@ namespace dxvk { || Format == DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM) flags1 |= D3D11_FORMAT_SUPPORT_DISPLAY; - // Query multisampling info + // Query multisample support info + const DxvkFormatInfo* formatInfo = imageFormatInfo(fmt); + VkImageFormatProperties imgInfo; VkResult status = m_dxvkAdapter->imageFormatProperties(fmt, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, + (formatInfo->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) + ? VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT + : VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, 0, imgInfo); if (status == VK_SUCCESS && imgInfo.sampleCounts > VK_SAMPLE_COUNT_1_BIT) {