mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-19 00:02:00 +00:00
SwizzleAdd (NOT TESTED)
This commit is contained in:
parent
558752594c
commit
fdf7578928
6 changed files with 21 additions and 8 deletions
|
@ -65,11 +65,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||||
context.AppendLine("using namespace metal;");
|
context.AppendLine("using namespace metal;");
|
||||||
context.AppendLine();
|
context.AppendLine();
|
||||||
|
|
||||||
if ((info.HelperFunctionsMask & HelperFunctionsMask.SwizzleAdd) != 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DeclareInputAttributes(context, info.IoDefinitions.Where(x => IsUserDefined(x, StorageKind.Input)));
|
DeclareInputAttributes(context, info.IoDefinitions.Where(x => IsUserDefined(x, StorageKind.Input)));
|
||||||
context.AppendLine();
|
context.AppendLine();
|
||||||
DeclareOutputAttributes(context, info.IoDefinitions.Where(x => x.StorageKind == StorageKind.Output));
|
DeclareOutputAttributes(context, info.IoDefinitions.Where(x => x.StorageKind == StorageKind.Output));
|
||||||
|
@ -93,6 +88,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||||
{
|
{
|
||||||
AppendHelperFunction(context, "Ryujinx.Graphics.Shader/CodeGen/Msl/HelperFunctions/FindMSBU32.metal");
|
AppendHelperFunction(context, "Ryujinx.Graphics.Shader/CodeGen/Msl/HelperFunctions/FindMSBU32.metal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((info.HelperFunctionsMask & HelperFunctionsMask.SwizzleAdd) != 0)
|
||||||
|
{
|
||||||
|
AppendHelperFunction(context, "Ryujinx.Graphics.Shader/CodeGen/Msl/HelperFunctions/SwizzleAdd.metal");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsUserDefined(IoDefinition ioDefinition, StorageKind storageKind)
|
static bool IsUserDefined(IoDefinition ioDefinition, StorageKind storageKind)
|
||||||
|
|
|
@ -5,5 +5,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||||
public static string FindLSB = "findLSB";
|
public static string FindLSB = "findLSB";
|
||||||
public static string FindMSBS32 = "findMSBS32";
|
public static string FindMSBS32 = "findMSBS32";
|
||||||
public static string FindMSBU32 = "findMSBU32";
|
public static string FindMSBU32 = "findMSBU32";
|
||||||
|
public static string SwizzleAdd = "swizzleAdd";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
float swizzleAdd(float x, float y, int mask, uint thread_index_in_simdgroup)
|
||||||
|
{
|
||||||
|
float4 xLut = float4(1.0, -1.0, 1.0, 0.0);
|
||||||
|
float4 yLut = float4(1.0, 1.0, -1.0, 1.0);
|
||||||
|
int lutIdx = (mask >> (int(thread_index_in_simdgroup & 3u) * 2)) & 3;
|
||||||
|
return x * xLut[lutIdx] + y * yLut[lutIdx];
|
||||||
|
}
|
|
@ -69,6 +69,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
|
|
||||||
builder.Append(GetSourceExpr(context, operation.GetSource(argIndex), dstType));
|
builder.Append(GetSourceExpr(context, operation.GetSource(argIndex), dstType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((operation.Inst & Instruction.Mask) == Instruction.SwizzleAdd)
|
||||||
|
{
|
||||||
|
// SwizzleAdd takes one last argument, the thread_index_in_simdgroup
|
||||||
|
builder.Append(", thread_index_in_simdgroup");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $"{info.OpName}({builder})";
|
return $"{info.OpName}({builder})";
|
||||||
|
@ -142,8 +148,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
return Lod(context, operation);
|
return Lod(context, operation);
|
||||||
case Instruction.Store:
|
case Instruction.Store:
|
||||||
return Store(context, operation);
|
return Store(context, operation);
|
||||||
case Instruction.SwizzleAdd:
|
|
||||||
return "|| SWIZZLE ADD ||";
|
|
||||||
case Instruction.TextureSample:
|
case Instruction.TextureSample:
|
||||||
return TextureSample(context, operation);
|
return TextureSample(context, operation);
|
||||||
case Instruction.TextureQuerySamples:
|
case Instruction.TextureQuerySamples:
|
||||||
|
|
|
@ -116,7 +116,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
Add(Instruction.SquareRoot, InstType.CallUnary, "sqrt");
|
Add(Instruction.SquareRoot, InstType.CallUnary, "sqrt");
|
||||||
Add(Instruction.Store, InstType.Special);
|
Add(Instruction.Store, InstType.Special);
|
||||||
Add(Instruction.Subtract, InstType.OpBinary, "-", 2);
|
Add(Instruction.Subtract, InstType.OpBinary, "-", 2);
|
||||||
Add(Instruction.SwizzleAdd, InstType.Special);
|
Add(Instruction.SwizzleAdd, InstType.CallTernary, HelperFunctionNames.SwizzleAdd);
|
||||||
Add(Instruction.TextureSample, InstType.Special);
|
Add(Instruction.TextureSample, InstType.Special);
|
||||||
Add(Instruction.TextureQuerySamples, InstType.Special);
|
Add(Instruction.TextureQuerySamples, InstType.Special);
|
||||||
Add(Instruction.TextureQuerySize, InstType.Special);
|
Add(Instruction.TextureQuerySize, InstType.Special);
|
||||||
|
|
|
@ -19,5 +19,6 @@
|
||||||
<EmbeddedResource Include="CodeGen\Msl\HelperFunctions\FindLSB.metal" />
|
<EmbeddedResource Include="CodeGen\Msl\HelperFunctions\FindLSB.metal" />
|
||||||
<EmbeddedResource Include="CodeGen\Msl\HelperFunctions\FindMSBS32.metal" />
|
<EmbeddedResource Include="CodeGen\Msl\HelperFunctions\FindMSBS32.metal" />
|
||||||
<EmbeddedResource Include="CodeGen\Msl\HelperFunctions\FindMSBU32.metal" />
|
<EmbeddedResource Include="CodeGen\Msl\HelperFunctions\FindMSBU32.metal" />
|
||||||
|
<EmbeddedResource Include="CodeGen\Msl\HelperFunctions\SwizzleAdd.metal" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
Loading…
Reference in a new issue