From 61cf550d0c951d02db7b347ffcee82e34a3e5160 Mon Sep 17 00:00:00 2001 From: GPUCode <47210458+GPUCode@users.noreply.github.com> Date: Sun, 27 Aug 2023 01:48:45 +0300 Subject: [PATCH] video_core: Avoid setting alpha tev with Dot3_RGBA8 color op (#6907) * Further reduces unnecessary shader regenerations --- src/video_core/renderer_opengl/gl_shader_gen.cpp | 10 ++++++++-- src/video_core/renderer_vulkan/vk_shader_gen.cpp | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index d8a1ed114..6f860fc24 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp @@ -99,6 +99,11 @@ PicaFSConfig PicaFSConfig::BuildFromRegs(const Pica::Regs& regs, bool use_normal state.tev_stages[i].modifiers_raw = tev_stage.modifiers_raw; state.tev_stages[i].ops_raw = tev_stage.ops_raw; state.tev_stages[i].scales_raw = tev_stage.scales_raw; + if (tev_stage.color_op == TevStageConfig::Operation::Dot3_RGBA) { + state.tev_stages[i].sources_raw &= 0xFFF; + state.tev_stages[i].modifiers_raw &= 0xFFF; + state.tev_stages[i].ops_raw &= 0xF; + } } state.fog_mode = regs.texturing.fog_mode; @@ -226,8 +231,9 @@ PicaFSConfig PicaFSConfig::BuildFromRegs(const Pica::Regs& regs, bool use_normal state.shadow_rendering = regs.framebuffer.output_merger.fragment_operation_mode == FramebufferRegs::FragmentOperationMode::Shadow; - - state.shadow_texture_orthographic = regs.texturing.shadow.orthographic != 0; + if (state.shadow_rendering) { + state.shadow_texture_orthographic = regs.texturing.shadow.orthographic != 0; + } state.use_custom_normal_map = use_normal; diff --git a/src/video_core/renderer_vulkan/vk_shader_gen.cpp b/src/video_core/renderer_vulkan/vk_shader_gen.cpp index 6f1dc412b..5beeee025 100644 --- a/src/video_core/renderer_vulkan/vk_shader_gen.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_gen.cpp @@ -102,6 +102,11 @@ PicaFSConfig::PicaFSConfig(const Pica::Regs& regs, const Instance& instance) { state.tev_stages[i].modifiers_raw = tev_stage.modifiers_raw; state.tev_stages[i].ops_raw = tev_stage.ops_raw; state.tev_stages[i].scales_raw = tev_stage.scales_raw; + if (tev_stage.color_op == TevStageConfig::Operation::Dot3_RGBA) { + state.tev_stages[i].sources_raw &= 0xFFF; + state.tev_stages[i].modifiers_raw &= 0xFFF; + state.tev_stages[i].ops_raw &= 0xF; + } } state.fog_mode.Assign(regs.texturing.fog_mode); @@ -230,8 +235,9 @@ PicaFSConfig::PicaFSConfig(const Pica::Regs& regs, const Instance& instance) { state.shadow_rendering.Assign(regs.framebuffer.output_merger.fragment_operation_mode == FramebufferRegs::FragmentOperationMode::Shadow); - - state.shadow_texture_orthographic.Assign(regs.texturing.shadow.orthographic != 0); + if (state.shadow_rendering) { + state.shadow_texture_orthographic.Assign(regs.texturing.shadow.orthographic != 0); + } } void PicaShaderConfigCommon::Init(const Pica::RasterizerRegs& rasterizer,