2023-08-15 13:17:00 +00:00
|
|
|
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 functon = context.GetFunction(funcId.Value);
|
|
|
|
|
2024-05-29 15:21:59 +00:00
|
|
|
int argCount = operation.SourcesCount - 1;
|
2024-06-21 09:31:21 +00:00
|
|
|
int additionalArgCount = CodeGenContext.AdditionalArgCount + (context.Definitions.Stage != ShaderStage.Compute ? 1 : 0);
|
|
|
|
|
|
|
|
string[] args = new string[argCount + additionalArgCount];
|
2023-08-15 13:17:00 +00:00
|
|
|
|
2024-05-29 15:21:59 +00:00
|
|
|
// Additional arguments
|
2024-06-21 09:31:21 +00:00
|
|
|
if (context.Definitions.Stage != ShaderStage.Compute)
|
|
|
|
{
|
|
|
|
args[0] = "in";
|
2024-06-25 13:25:31 +00:00
|
|
|
args[1] = "constant_buffers";
|
|
|
|
args[2] = "storage_buffers";
|
2024-06-21 09:31:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-06-25 13:25:31 +00:00
|
|
|
args[0] = "constant_buffers";
|
|
|
|
args[1] = "storage_buffers";
|
2024-06-21 09:31:21 +00:00
|
|
|
}
|
2024-05-29 15:21:59 +00:00
|
|
|
|
2024-06-21 09:31:21 +00:00
|
|
|
int argIndex = additionalArgCount;
|
2024-05-29 15:21:59 +00:00
|
|
|
for (int i = 0; i < argCount; i++)
|
2023-08-15 13:17:00 +00:00
|
|
|
{
|
2024-05-29 15:21:59 +00:00
|
|
|
args[argIndex++] = GetSourceExpr(context, operation.GetSource(i + 1), functon.GetArgumentType(i));
|
2023-08-15 13:17:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $"{functon.Name}({string.Join(", ", args)})";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|