From 15e4d4e89103a6e8f3792a2f825f6888017cc2e6 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Sat, 22 Jun 2024 13:15:23 +0100 Subject: [PATCH] Fix thread_index_in_simdgroup outside of compute --- src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs index d6ead984c7..59552b885e 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs @@ -80,6 +80,14 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl context.AppendLine("FragmentOut out;"); break; } + + // TODO: Only add if necessary + if (stage != ShaderStage.Compute) + { + // MSL does not give us access to [[thread_index_in_simdgroup]] + // outside compute. But we may still need to provide this value in frag/vert. + context.AppendLine("uint thread_index_in_simdgroup = simd_prefix_exclusive_sum(1);"); + } } foreach (AstOperand decl in function.Locals)