diff --git a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp index 612c0738cd..09ee10c0bb 100644 --- a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp +++ b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp @@ -449,6 +449,8 @@ void GSDevice12::CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r, sTexVK->TransitionToState(D3D12_RESOURCE_STATE_COPY_SOURCE); sTexVK->SetUsedThisCommandBuffer(); + if (m_tfx_textures[0] && sTexVK->GetSRVDescriptor() == m_tfx_textures[0]) + PSSetShaderResource(0, nullptr, false); dTexVK->TransitionToState(D3D12_RESOURCE_STATE_COPY_DEST); dTexVK->SetUsedThisCommandBuffer(); @@ -2457,6 +2459,7 @@ void GSDevice12::RenderHW(GSHWDrawConfig& config) } if (config.pal) PSSetShaderResource(1, config.pal, true); + if (config.blend.constant_enable) SetBlendConstants(config.blend.constant); @@ -2538,23 +2541,33 @@ void GSDevice12::RenderHW(GSHWDrawConfig& config) } } - if (config.tex && config.tex == config.ds) + if (config.tex) { - // requires a copy of the depth buffer. this is mainly for ico. - copy_ds = static_cast(CreateDepthStencil(rtsize.x, rtsize.y, GSTexture::Format::DepthStencil, false)); - if (copy_ds) + if (config.tex == config.ds) { - EndRenderPass(); + // requires a copy of the depth buffer. this is mainly for ico. + copy_ds = static_cast(CreateDepthStencil(rtsize.x, rtsize.y, GSTexture::Format::DepthStencil, false)); + if (copy_ds) + { + EndRenderPass(); - GL_PUSH("Copy depth to temp texture for shuffle {%d,%d %dx%d}", - config.drawarea.left, config.drawarea.top, - config.drawarea.width(), config.drawarea.height()); + GL_PUSH("Copy depth to temp texture for shuffle {%d,%d %dx%d}", + config.drawarea.left, config.drawarea.top, + config.drawarea.width(), config.drawarea.height()); - copy_ds->SetState(GSTexture::State::Invalidated); - CopyRect(config.ds, copy_ds, config.drawarea, config.drawarea.left, config.drawarea.top); - PSSetShaderResource(0, copy_ds, true); + copy_ds->SetState(GSTexture::State::Invalidated); + CopyRect(config.ds, copy_ds, config.drawarea, config.drawarea.left, config.drawarea.top); + PSSetShaderResource(0, copy_ds, true); + } } } + // clear texture binding when it's bound to RT or DS + else if (m_tfx_textures[0] && + ((config.rt && static_cast(config.rt)->GetSRVDescriptor() == m_tfx_textures[0]) || + (config.ds && static_cast(config.ds)->GetSRVDescriptor() == m_tfx_textures[0]))) + { + PSSetShaderResource(0, nullptr, false); + } // avoid restarting the render pass just to switch from rt+depth to rt and vice versa if (m_in_render_pass && !hdr_rt && !draw_ds && m_current_depth_target && m_current_render_target == draw_rt && config.tex != m_current_depth_target) diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index 7899f65ddd..e2e2e41bf7 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -553,9 +553,14 @@ void GSDeviceVK::CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r, dTexVK->TransitionToLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); dTexVK->SetUsedThisCommandBuffer(); + sTexVK->TransitionToLayout(VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); sTexVK->SetUsedThisCommandBuffer(); + // ensure we don't leave this bound later on + if (m_tfx_textures[0] == sTexVK->GetView()) + PSSetShaderResource(0, nullptr, false); + vkCmdCopyImage(g_vulkan_context->GetCurrentCommandBuffer(), sTexVK->GetImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dTexVK->GetImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &ic); @@ -712,14 +717,15 @@ void GSDeviceVK::BlitRect(GSTexture* sTex, const GSVector4i& sRect, u32 sLevel, GSTextureVK* sTexVK = static_cast(sTex); GSTextureVK* dTexVK = static_cast(dTex); - //const VkImageLayout old_src_layout = sTexVK->GetTexture().GetLayout(); - //const VkImageLayout old_dst_layout = dTexVK->GetTexture().GetLayout(); - EndRenderPass(); sTexVK->TransitionToLayout(VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); dTexVK->TransitionToLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); + // ensure we don't leave this bound later on + if (m_tfx_textures[0] == sTexVK->GetView()) + PSSetShaderResource(0, nullptr, false); + pxAssert( (sTexVK->GetType() == GSTexture::Type::DepthStencil) == (dTexVK->GetType() == GSTexture::Type::DepthStencil)); const VkImageAspectFlags aspect = @@ -2885,6 +2891,7 @@ void GSDeviceVK::RenderHW(GSHWDrawConfig& config) } if (config.pal) PSSetShaderResource(1, config.pal, true); + if (config.blend.constant_enable) SetBlendConstants(config.blend.constant);