aboutsummaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp
diff options
context:
space:
mode:
authortarako <r76036296@gmail.com>2026-03-03 01:54:57 +0100
committercrueter <crueter@eden-emu.dev>2026-03-03 01:54:57 +0100
commitd720a7b4b4e3c2bc4f7e2c1b16e282ec91766aa8 (patch)
tree4c1eebb39329f97e2bf75d73768734ac20ee988c /src/shader_recompiler/backend/spirv/emit_spirv_special.cpp
parent464212393e296c59488171692df1d096ecfa5607 (diff)
[vulkan] Fixed dual-source blending to correctly map shader outputs. (#3637)
Fixes Skyward Sword HD eye gitch and a related MoltenVK crash due to the incorrect output mapping. Verified working on mac and android. The test in vk_pipeline_cache.cpp is a bit ugly, but it didn't seem worth it to go lambda/macro just to make it look cleaner. Could change if necessary. Co-authored-by: tarako <none@none.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3637 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: tarako <r76036296@gmail.com> Co-committed-by: tarako <r76036296@gmail.com>
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv_special.cpp')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_special.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp
index fe5e70a63b..8eca1fac29 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp
@@ -1,3 +1,6 @@
+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -91,6 +94,17 @@ void AlphaTest(EmitContext& ctx) {
} // Anonymous namespace
void EmitPrologue(EmitContext& ctx) {
+ if (ctx.stage == Stage::Fragment && ctx.runtime_info.dual_source_blend) {
+ // Initialize dual-source blending outputs - prevents MoltenVK crash.
+ const Id zero{ctx.Const(0.0f)};
+ const Id one{ctx.Const(1.0f)};
+ const Id default_color{ctx.ConstantComposite(ctx.F32[4], zero, zero, zero, one)};
+ for (u32 i = 0; i < 2; ++i) {
+ if (Sirit::ValidId(ctx.frag_color[i])) {
+ ctx.OpStore(ctx.frag_color[i], default_color);
+ }
+ }
+ }
if (ctx.stage == Stage::VertexB) {
const Id zero{ctx.Const(0.0f)};
const Id one{ctx.Const(1.0f)};