mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 02:52:10 +01:00
[d3d11] Return early for clear operations on NULL views
Fixes a crash in Fallout 4 when loading into the game.
This commit is contained in:
parent
f582c4e1ce
commit
eadf74264b
@ -429,7 +429,9 @@ namespace dxvk {
|
||||
ID3D11RenderTargetView* pRenderTargetView,
|
||||
const FLOAT ColorRGBA[4]) {
|
||||
auto rtv = static_cast<D3D11RenderTargetView*>(pRenderTargetView);
|
||||
const Rc<DxvkImageView> 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<DxvkImageView> 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<D3D11UnorderedAccessView*>(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<D3D11DepthStencilView*>(pDepthStencilView);
|
||||
const Rc<DxvkImageView> dxvkView = dsv->GetImageView();
|
||||
|
||||
if (dsv == nullptr)
|
||||
return;
|
||||
|
||||
// Figure out which aspects to clear based
|
||||
// on the image format and the clear flags.
|
||||
const Rc<DxvkImageView> 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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user