diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index fa73d6465..03f8911f9 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -429,7 +429,9 @@ namespace dxvk { ID3D11RenderTargetView* pRenderTargetView, const FLOAT ColorRGBA[4]) { auto rtv = static_cast(pRenderTargetView); - const Rc dxvkView = rtv->GetImageView(); + + if (rtv == nullptr) + return; // Find out whether the given attachment is currently bound // or not, and if it is, which attachment index it has. @@ -443,6 +445,8 @@ namespace dxvk { // Copy the clear color into a clear value structure. // This should also work for images that don nott have // a floating point format. + const Rc view = rtv->GetImageView(); + VkClearColorValue clearValue; std::memcpy(clearValue.float32, ColorRGBA, sizeof(clearValue.float32)); @@ -460,10 +464,10 @@ namespace dxvk { VkClearRect clearRect; clearRect.rect.offset.x = 0; clearRect.rect.offset.y = 0; - clearRect.rect.extent.width = dxvkView->mipLevelExtent(0).width; - clearRect.rect.extent.height = dxvkView->mipLevelExtent(0).height; + clearRect.rect.extent.width = view->mipLevelExtent(0).width; + clearRect.rect.extent.height = view->mipLevelExtent(0).height; clearRect.baseArrayLayer = 0; - clearRect.layerCount = dxvkView->info().numLayers; + clearRect.layerCount = view->info().numLayers; if (m_parent->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0) clearRect.layerCount = 1; @@ -479,7 +483,7 @@ namespace dxvk { // it, but we'll have to use a generic clear function. EmitCs([ cClearValue = clearValue, - cDstView = dxvkView + cDstView = view ] (DxvkContext* ctx) { ctx->clearColorImage(cDstView->image(), cClearValue, cDstView->subresources()); @@ -493,6 +497,9 @@ namespace dxvk { const UINT Values[4]) { auto uav = static_cast(pUnorderedAccessView); + if (uav == nullptr) + return; + if (uav->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER) { Logger::err("D3D11: ClearUnorderedAccessViewUint: Not supported for buffers"); } else { @@ -525,7 +532,13 @@ namespace dxvk { FLOAT Depth, UINT8 Stencil) { auto dsv = static_cast(pDepthStencilView); - const Rc dxvkView = dsv->GetImageView(); + + if (dsv == nullptr) + return; + + // Figure out which aspects to clear based + // on the image format and the clear flags. + const Rc view = dsv->GetImageView(); VkImageAspectFlags aspectMask = 0; @@ -536,7 +549,7 @@ namespace dxvk { aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; const DxvkFormatInfo* formatInfo = - imageFormatInfo(dxvkView->info().format); + imageFormatInfo(view->info().format); aspectMask &= formatInfo->aspectMask; VkClearDepthStencilValue clearValue; @@ -555,10 +568,10 @@ namespace dxvk { VkClearRect clearRect; clearRect.rect.offset.x = 0; clearRect.rect.offset.y = 0; - clearRect.rect.extent.width = dxvkView->mipLevelExtent(0).width; - clearRect.rect.extent.height = dxvkView->mipLevelExtent(0).height; + clearRect.rect.extent.width = view->mipLevelExtent(0).width; + clearRect.rect.extent.height = view->mipLevelExtent(0).height; clearRect.baseArrayLayer = 0; - clearRect.layerCount = dxvkView->info().numLayers; + clearRect.layerCount = view->info().numLayers; // FIXME Is this correct? Docs don't say anything if (m_parent->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0) @@ -573,7 +586,7 @@ namespace dxvk { } else { EmitCs([ cClearValue = clearValue, - cDstView = dxvkView, + cDstView = view, cAspectMask = aspectMask ] (DxvkContext* ctx) { VkImageSubresourceRange subresources = cDstView->subresources();