From 7e3eab99158d27263d4c358e9c4bbf601a6fba97 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Mon, 8 Nov 2021 20:58:24 +0300 Subject: [PATCH] rsx: Fix texture state propagation between unrelated draw calls - Older games can load all textures before a draw sequence and then swap shaders for different draws. - Optimizations in texture state streaming make it so that only referenced data is carried forward. --- rpcs3/Emu/RSX/RSXThread.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index a9a547976c..fcbe364349 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -1625,6 +1625,8 @@ namespace rsx m_graphics_state &= ~rsx::pipeline_state::fragment_program_ucode_dirty; const auto [program_offset, program_location] = method_registers.shader_program_address(); + const auto prev_textures_reference_mask = current_fp_metadata.referenced_textures_mask; + auto data_ptr = vm::base(rsx::get_address(program_offset, program_location)); current_fp_metadata = program_hash_util::fragment_program_utils::analyse_fragment_program(data_ptr); @@ -1649,6 +1651,14 @@ namespace rsx } } } + + if (!(m_graphics_state & rsx::pipeline_state::fragment_program_state_dirty) && + (prev_textures_reference_mask != current_fp_metadata.referenced_textures_mask)) + { + // If different textures are used, upload their coefficients. + // The texture parameters transfer routine is optimized and only writes data for textures consumed by the ucode. + m_graphics_state |= rsx::pipeline_state::fragment_texture_state_dirty; + } } void thread::prefetch_vertex_program()