From e0a7912d7c83587336f26bc43eac0a81c4f12f37 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Fri, 30 Aug 2019 20:49:57 +0300 Subject: [PATCH] rsx: Check for stencil writes when determining zeta_write flag --- rpcs3/Emu/RSX/RSXThread.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index bce54e7962..d2e758b807 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -1067,6 +1067,24 @@ namespace rsx // Check write masks layout.zeta_write_enabled = rsx::method_registers.depth_write_enabled(); + if (!layout.zeta_write_enabled && stencil_test_enabled) + { + // Check if stencil data is modified + auto mask = rsx::method_registers.stencil_mask(); + bool active_write_op = (rsx::method_registers.stencil_op_zpass() != rsx::stencil_op::keep || + rsx::method_registers.stencil_op_fail() != rsx::stencil_op::keep || + rsx::method_registers.stencil_op_zfail() != rsx::stencil_op::keep); + + if ((!mask || !active_write_op) && rsx::method_registers.two_sided_stencil_test_enabled()) + { + mask |= rsx::method_registers.back_stencil_mask(); + active_write_op |= (rsx::method_registers.stencil_op_zpass() != rsx::stencil_op::keep || + rsx::method_registers.stencil_op_fail() != rsx::stencil_op::keep || + rsx::method_registers.stencil_op_zfail() != rsx::stencil_op::keep); + } + + layout.zeta_write_enabled = (mask && active_write_op); + } // NOTE: surface_target_a is index 1 but is not MRT since only one surface is active bool color_write_enabled = false;