1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-01 19:29:16 +01:00

[d3d11] Don't clear DSV aspects that are marked as read-only

Saint's Row 4 appears to be doing this. Ref #24.
This commit is contained in:
Philip Rebohle 2019-06-02 16:34:33 +02:00
parent c59a8e6e48
commit 6cbd611190
2 changed files with 14 additions and 6 deletions

View File

@ -883,10 +883,8 @@ namespace dxvk {
if (!dsv) if (!dsv)
return; return;
// Figure out which aspects to clear based // Figure out which aspects to clear based on
// on the image format and the clear flags. // the image view properties and clear flags.
const Rc<DxvkImageView> view = dsv->GetImageView();
VkImageAspectFlags aspectMask = 0; VkImageAspectFlags aspectMask = 0;
if (ClearFlags & D3D11_CLEAR_DEPTH) if (ClearFlags & D3D11_CLEAR_DEPTH)
@ -895,7 +893,10 @@ namespace dxvk {
if (ClearFlags & D3D11_CLEAR_STENCIL) if (ClearFlags & D3D11_CLEAR_STENCIL)
aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
aspectMask &= imageFormatInfo(view->info().format)->aspectMask; aspectMask &= dsv->GetWritableAspectMask();
if (!aspectMask)
return;
VkClearValue clearValue; VkClearValue clearValue;
clearValue.depthStencil.depth = Depth; clearValue.depthStencil.depth = Depth;
@ -904,7 +905,7 @@ namespace dxvk {
EmitCs([ EmitCs([
cClearValue = clearValue, cClearValue = clearValue,
cAspectMask = aspectMask, cAspectMask = aspectMask,
cImageView = view cImageView = dsv->GetImageView()
] (DxvkContext* ctx) { ] (DxvkContext* ctx) {
ctx->clearRenderTarget( ctx->clearRenderTarget(
cImageView, cImageView,

View File

@ -63,6 +63,13 @@ namespace dxvk {
} }
} }
VkImageAspectFlags GetWritableAspectMask() const {
VkImageAspectFlags mask = m_view->formatInfo()->aspectMask;
if (m_desc.Flags & D3D11_DSV_READ_ONLY_DEPTH) mask &= ~VK_IMAGE_ASPECT_DEPTH_BIT;
if (m_desc.Flags & D3D11_DSV_READ_ONLY_STENCIL) mask &= ~VK_IMAGE_ASPECT_STENCIL_BIT;
return mask;
}
D3D10DepthStencilView* GetD3D10Iface() { D3D10DepthStencilView* GetD3D10Iface() {
return &m_d3d10; return &m_d3d10;
} }