aboutsummaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
diff options
context:
space:
mode:
authorrayman30 <silentbitdev@gmail.com>2026-01-29 17:24:36 +0100
committercrueter <crueter@eden-emu.dev>2026-01-29 17:24:36 +0100
commit643f11d97218aad2c008d323b32bc65fa36f9e2d (patch)
tree32dedd21c73b308107e996036855b251b3f7988c /src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
parent025bc799f782be40544d2718bdcbb8f4d0d033d2 (diff)
[VK, MacOS] Fix strict output type mismatch on Metal (MK8D/TOTK fix) (#3414)
Metal validation requires fragment shader output types to strictly match the render target format (e.g., writing float to RGBA32Uint is invalid). This commit: 1. Adds color_output_types to RuntimeInfo. 2. Detects Integer/SignedInteger render targets in the Vulkan backend (MoltenVK only). 3. Updates the SPIR-V emitter to declare the correct output type (Uint/Sint) and bitcast values accordingly. This fixes the VK_ERROR_INITIALIZATION_FAILED crash on macOS. Co-authored-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3414 Co-authored-by: rayman30 <silentbitdev@gmail.com> Co-committed-by: rayman30 <silentbitdev@gmail.com>
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
index 1de5709394..db11def7b2 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
@@ -492,8 +492,22 @@ void EmitSetPatch(EmitContext& ctx, IR::Patch patch, Id value) {
void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, Id value) {
const Id component_id{ctx.Const(component)};
- const Id pointer{ctx.OpAccessChain(ctx.output_f32, ctx.frag_color.at(index), component_id)};
- ctx.OpStore(pointer, value);
+ const AttributeType type{ctx.runtime_info.color_output_types[index]};
+ if (type == AttributeType::Float) {
+ const Id pointer{ctx.OpAccessChain(ctx.output_f32, ctx.frag_color.at(index), component_id)};
+ ctx.OpStore(pointer, value);
+ } else if (type == AttributeType::UnsignedInt) {
+ const Id pointer{ctx.OpAccessChain(ctx.output_u32, ctx.frag_color.at(index), component_id)};
+ ctx.OpStore(pointer, ctx.OpBitcast(ctx.U32[1], value));
+ } else if (type == AttributeType::SignedInt) {
+ const Id output_s32{ctx.TypePointer(spv::StorageClass::Output, ctx.S32[1])};
+ const Id pointer{ctx.OpAccessChain(output_s32, ctx.frag_color.at(index), component_id)};
+ ctx.OpStore(pointer, ctx.OpBitcast(ctx.S32[1], value));
+ } else {
+ // Disabled or unknown, treat as float
+ const Id pointer{ctx.OpAccessChain(ctx.output_f32, ctx.frag_color.at(index), component_id)};
+ ctx.OpStore(pointer, value);
+ }
}
void EmitSetSampleMask(EmitContext& ctx, Id value) {