From 16370809dba18da724fa84cecfa1973c2caeab45 Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Fri, 11 Sep 2026 07:51:49 -0700 Subject: [PATCH] renderer_vulkan: Fix shadow-texture usage determination The shadow-texture should only actually be binded if shadows are enabled and if the shadow-texture slot is actually enabled. Otherwise the null-surface should be binded. This ensures that we are are not binding whatever texture slot the register happens to be set to as a shadow-texture. This avoids an RGBA4 texture from being binded into the shadow-texture slot in Monster Hunter 4 Ultimate when opening the equipment set screen. Addresses https://github.com/azahar-emu/azahar/issues/2531 --- src/video_core/renderer_vulkan/vk_rasterizer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 324fb0606..b50274f9a 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -700,7 +700,14 @@ void RasterizerVulkan::SyncTextureUnits(const Framebuffer* framebuffer) { void RasterizerVulkan::SyncUtilityTextures(const Framebuffer* framebuffer) { const bool shadow_writing = regs.framebuffer.IsShadowRendering(); - const bool shadow_reading = regs.lighting.config0.enable_shadow; + bool shadow_reading = regs.lighting.config0.enable_shadow; + // Ensure the shadow-texture slot is actually enabled + if (shadow_reading) { + const u32 shadow_texture_unit = regs.lighting.config0.shadow_selector.Value(); + const auto shadow_texture = regs.texturing.GetTextures()[shadow_texture_unit]; + shadow_reading &= shadow_texture.enabled; + } + const auto utility_set = pipeline_cache.Acquire(DescriptorHeapType::Utility); // Reading and writing are mutually exclusive