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:
Evan Husted
2024-12-24 00:55:16 -06:00
committed by GitHub
parent 3094df54dd
commit 852823104f
131 changed files with 14992 additions and 140 deletions

View File

@@ -7,7 +7,14 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
MultiplyHighS32 = 1 << 2,
MultiplyHighU32 = 1 << 3,
FindLSB = 1 << 5,
FindMSBS32 = 1 << 6,
FindMSBU32 = 1 << 7,
SwizzleAdd = 1 << 10,
FSI = 1 << 11,
Precise = 1 << 13
}
}

View File

@@ -18,9 +18,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
ShaderDefinitions definitions,
ResourceManager resourceManager,
TargetLanguage targetLanguage,
bool precise,
bool debugMode)
{
StructuredProgramContext context = new(attributeUsage, definitions, resourceManager, debugMode);
StructuredProgramContext context = new(attributeUsage, definitions, resourceManager, precise, debugMode);
for (int funcIndex = 0; funcIndex < functions.Count; funcIndex++)
{
@@ -321,8 +322,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
// Those instructions needs to be emulated by using helper functions,
// because they are NVIDIA specific. Those flags helps the backend to
// decide which helper functions are needed on the final generated code.
// because they are NVIDIA specific or because the target language has
// no direct equivalent. Those flags helps the backend to decide which
// helper functions are needed on the final generated code.
switch (operation.Inst)
{
case Instruction.MultiplyHighS32:
@@ -331,6 +333,15 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
case Instruction.MultiplyHighU32:
context.Info.HelperFunctionsMask |= HelperFunctionsMask.MultiplyHighU32;
break;
case Instruction.FindLSB:
context.Info.HelperFunctionsMask |= HelperFunctionsMask.FindLSB;
break;
case Instruction.FindMSBS32:
context.Info.HelperFunctionsMask |= HelperFunctionsMask.FindMSBS32;
break;
case Instruction.FindMSBU32:
context.Info.HelperFunctionsMask |= HelperFunctionsMask.FindMSBU32;
break;
case Instruction.SwizzleAdd:
context.Info.HelperFunctionsMask |= HelperFunctionsMask.SwizzleAdd;
break;

View File

@@ -36,9 +36,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
AttributeUsage attributeUsage,
ShaderDefinitions definitions,
ResourceManager resourceManager,
bool precise,
bool debugMode)
{
Info = new StructuredProgramInfo();
Info = new StructuredProgramInfo(precise);
Definitions = definitions;
ResourceManager = resourceManager;

View File

@@ -10,11 +10,16 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public HelperFunctionsMask HelperFunctionsMask { get; set; }
public StructuredProgramInfo()
public StructuredProgramInfo(bool precise)
{
Functions = new List<StructuredFunction>();
IoDefinitions = new HashSet<IoDefinition>();
if (precise)
{
HelperFunctionsMask |= HelperFunctionsMask.Precise;
}
}
}
}