EXPERIMENTAL: Metal backend (#441)
This is not a continuation of the Metal backend; this is simply bringing the branch up to date and merging it as-is behind an experiment. --------- Co-authored-by: Isaac Marovitz <isaacryu@icloud.com> Co-authored-by: Samuliak <samuliak77@gmail.com> Co-authored-by: SamoZ256 <96914946+SamoZ256@users.noreply.github.com> Co-authored-by: Isaac Marovitz <42140194+IsaacMarovitz@users.noreply.github.com> Co-authored-by: riperiperi <rhy3756547@hotmail.com> Co-authored-by: Gabriel A <gab.dark.100@gmail.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using Ryujinx.Graphics.Shader.StructuredIr;
|
||||
|
||||
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenHelper;
|
||||
|
||||
namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
{
|
||||
static class InstGenCall
|
||||
{
|
||||
public static string Call(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
AstOperand funcId = (AstOperand)operation.GetSource(0);
|
||||
|
||||
var function = context.GetFunction(funcId.Value);
|
||||
|
||||
int argCount = operation.SourcesCount - 1;
|
||||
int additionalArgCount = CodeGenContext.AdditionalArgCount + (context.Definitions.Stage != ShaderStage.Compute ? 1 : 0);
|
||||
bool needsThreadIndex = false;
|
||||
|
||||
// TODO: Replace this with a proper flag
|
||||
if (function.Name.Contains("Shuffle"))
|
||||
{
|
||||
needsThreadIndex = true;
|
||||
additionalArgCount++;
|
||||
}
|
||||
|
||||
string[] args = new string[argCount + additionalArgCount];
|
||||
|
||||
// Additional arguments
|
||||
if (context.Definitions.Stage != ShaderStage.Compute)
|
||||
{
|
||||
args[0] = "in";
|
||||
args[1] = "constant_buffers";
|
||||
args[2] = "storage_buffers";
|
||||
|
||||
if (needsThreadIndex)
|
||||
{
|
||||
args[3] = "thread_index_in_simdgroup";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
args[0] = "constant_buffers";
|
||||
args[1] = "storage_buffers";
|
||||
|
||||
if (needsThreadIndex)
|
||||
{
|
||||
args[2] = "thread_index_in_simdgroup";
|
||||
}
|
||||
}
|
||||
|
||||
int argIndex = additionalArgCount;
|
||||
for (int i = 0; i < argCount; i++)
|
||||
{
|
||||
args[argIndex++] = GetSourceExpr(context, operation.GetSource(i + 1), function.GetArgumentType(i));
|
||||
}
|
||||
|
||||
return $"{function.Name}({string.Join(", ", args)})";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user