[d3d9] Fix depth hazard case for write + read

Closes #1519
This commit is contained in:
Joshua Ashton 2020-03-20 13:19:23 +00:00 committed by Philip Rebohle
parent 1150121606
commit a9339ae832
3 changed files with 19 additions and 8 deletions

View File

@ -324,10 +324,14 @@ namespace dxvk {
: VK_IMAGE_LAYOUT_GENERAL;
}
VkImageLayout DetermineDepthStencilLayout(bool hazardous) const {
VkImageLayout layout = hazardous
? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
: VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
VkImageLayout DetermineDepthStencilLayout(bool write, bool hazardous) const {
VkImageLayout layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
if (unlikely(hazardous)) {
layout = write
? VK_IMAGE_LAYOUT_GENERAL
: VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
}
if (unlikely(m_image->info().tiling != VK_IMAGE_TILING_OPTIMAL))
layout = VK_IMAGE_LAYOUT_GENERAL;

View File

@ -1783,10 +1783,16 @@ namespace dxvk {
m_flags.set(D3D9DeviceFlag::DirtyMultiSampleState);
break;
case D3DRS_ZWRITEENABLE:
if (m_activeHazardsDS != 0)
m_flags.set(D3D9DeviceFlag::DirtyFramebuffer);
m_flags.set(D3D9DeviceFlag::DirtyDepthStencilState);
break;
case D3DRS_ZENABLE:
case D3DRS_ZFUNC:
case D3DRS_TWOSIDEDSTENCILMODE:
case D3DRS_ZWRITEENABLE:
case D3DRS_STENCILENABLE:
case D3DRS_STENCILFAIL:
case D3DRS_STENCILZFAIL:
@ -4962,11 +4968,12 @@ namespace dxvk {
if (m_state.depthStencil != nullptr) {
const DxvkImageCreateInfo& dsImageInfo = m_state.depthStencil->GetCommonTexture()->GetImage()->info();
const bool depthWrite = m_state.renderStates[D3DRS_ZWRITEENABLE];
if (likely(sampleCount == VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM || sampleCount == dsImageInfo.sampleCount)) {
attachments.depth = {
m_state.depthStencil->GetDepthStencilView(),
m_state.depthStencil->GetDepthStencilLayout(m_activeHazardsDS != 0) };
m_state.depthStencil->GetDepthStencilLayout(depthWrite, m_activeHazardsDS != 0) };
}
}

View File

@ -99,8 +99,8 @@ namespace dxvk {
return view;
}
VkImageLayout GetDepthStencilLayout(bool hazardous) const {
return m_texture->DetermineDepthStencilLayout(hazardous);
VkImageLayout GetDepthStencilLayout(bool write, bool hazardous) const {
return m_texture->DetermineDepthStencilLayout(write, hazardous);
}
bool IsNull() {