mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-30 20:52:11 +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,
|
ID3D11RenderTargetView* pRenderTargetView,
|
||||||
const FLOAT ColorRGBA[4]) {
|
const FLOAT ColorRGBA[4]) {
|
||||||
auto rtv = static_cast<D3D11RenderTargetView*>(pRenderTargetView);
|
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
|
// Find out whether the given attachment is currently bound
|
||||||
// or not, and if it is, which attachment index it has.
|
// 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.
|
// Copy the clear color into a clear value structure.
|
||||||
// This should also work for images that don nott have
|
// This should also work for images that don nott have
|
||||||
// a floating point format.
|
// a floating point format.
|
||||||
|
const Rc<DxvkImageView> view = rtv->GetImageView();
|
||||||
|
|
||||||
VkClearColorValue clearValue;
|
VkClearColorValue clearValue;
|
||||||
std::memcpy(clearValue.float32, ColorRGBA,
|
std::memcpy(clearValue.float32, ColorRGBA,
|
||||||
sizeof(clearValue.float32));
|
sizeof(clearValue.float32));
|
||||||
@ -460,10 +464,10 @@ namespace dxvk {
|
|||||||
VkClearRect clearRect;
|
VkClearRect clearRect;
|
||||||
clearRect.rect.offset.x = 0;
|
clearRect.rect.offset.x = 0;
|
||||||
clearRect.rect.offset.y = 0;
|
clearRect.rect.offset.y = 0;
|
||||||
clearRect.rect.extent.width = dxvkView->mipLevelExtent(0).width;
|
clearRect.rect.extent.width = view->mipLevelExtent(0).width;
|
||||||
clearRect.rect.extent.height = dxvkView->mipLevelExtent(0).height;
|
clearRect.rect.extent.height = view->mipLevelExtent(0).height;
|
||||||
clearRect.baseArrayLayer = 0;
|
clearRect.baseArrayLayer = 0;
|
||||||
clearRect.layerCount = dxvkView->info().numLayers;
|
clearRect.layerCount = view->info().numLayers;
|
||||||
|
|
||||||
if (m_parent->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0)
|
if (m_parent->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0)
|
||||||
clearRect.layerCount = 1;
|
clearRect.layerCount = 1;
|
||||||
@ -479,7 +483,7 @@ namespace dxvk {
|
|||||||
// it, but we'll have to use a generic clear function.
|
// it, but we'll have to use a generic clear function.
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cClearValue = clearValue,
|
cClearValue = clearValue,
|
||||||
cDstView = dxvkView
|
cDstView = view
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
ctx->clearColorImage(cDstView->image(),
|
ctx->clearColorImage(cDstView->image(),
|
||||||
cClearValue, cDstView->subresources());
|
cClearValue, cDstView->subresources());
|
||||||
@ -493,6 +497,9 @@ namespace dxvk {
|
|||||||
const UINT Values[4]) {
|
const UINT Values[4]) {
|
||||||
auto uav = static_cast<D3D11UnorderedAccessView*>(pUnorderedAccessView);
|
auto uav = static_cast<D3D11UnorderedAccessView*>(pUnorderedAccessView);
|
||||||
|
|
||||||
|
if (uav == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if (uav->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
if (uav->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
||||||
Logger::err("D3D11: ClearUnorderedAccessViewUint: Not supported for buffers");
|
Logger::err("D3D11: ClearUnorderedAccessViewUint: Not supported for buffers");
|
||||||
} else {
|
} else {
|
||||||
@ -525,7 +532,13 @@ namespace dxvk {
|
|||||||
FLOAT Depth,
|
FLOAT Depth,
|
||||||
UINT8 Stencil) {
|
UINT8 Stencil) {
|
||||||
auto dsv = static_cast<D3D11DepthStencilView*>(pDepthStencilView);
|
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;
|
VkImageAspectFlags aspectMask = 0;
|
||||||
|
|
||||||
@ -536,7 +549,7 @@ namespace dxvk {
|
|||||||
aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
|
aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||||
|
|
||||||
const DxvkFormatInfo* formatInfo =
|
const DxvkFormatInfo* formatInfo =
|
||||||
imageFormatInfo(dxvkView->info().format);
|
imageFormatInfo(view->info().format);
|
||||||
aspectMask &= formatInfo->aspectMask;
|
aspectMask &= formatInfo->aspectMask;
|
||||||
|
|
||||||
VkClearDepthStencilValue clearValue;
|
VkClearDepthStencilValue clearValue;
|
||||||
@ -555,10 +568,10 @@ namespace dxvk {
|
|||||||
VkClearRect clearRect;
|
VkClearRect clearRect;
|
||||||
clearRect.rect.offset.x = 0;
|
clearRect.rect.offset.x = 0;
|
||||||
clearRect.rect.offset.y = 0;
|
clearRect.rect.offset.y = 0;
|
||||||
clearRect.rect.extent.width = dxvkView->mipLevelExtent(0).width;
|
clearRect.rect.extent.width = view->mipLevelExtent(0).width;
|
||||||
clearRect.rect.extent.height = dxvkView->mipLevelExtent(0).height;
|
clearRect.rect.extent.height = view->mipLevelExtent(0).height;
|
||||||
clearRect.baseArrayLayer = 0;
|
clearRect.baseArrayLayer = 0;
|
||||||
clearRect.layerCount = dxvkView->info().numLayers;
|
clearRect.layerCount = view->info().numLayers;
|
||||||
|
|
||||||
// FIXME Is this correct? Docs don't say anything
|
// FIXME Is this correct? Docs don't say anything
|
||||||
if (m_parent->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0)
|
if (m_parent->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0)
|
||||||
@ -573,7 +586,7 @@ namespace dxvk {
|
|||||||
} else {
|
} else {
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cClearValue = clearValue,
|
cClearValue = clearValue,
|
||||||
cDstView = dxvkView,
|
cDstView = view,
|
||||||
cAspectMask = aspectMask
|
cAspectMask = aspectMask
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
VkImageSubresourceRange subresources = cDstView->subresources();
|
VkImageSubresourceRange subresources = cDstView->subresources();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user