mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-23 04:35:46 +00:00
FSI (with raster order groups)
This commit is contained in:
parent
fdf7578928
commit
2b919493e3
3 changed files with 15 additions and 11 deletions
|
@ -65,14 +65,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||||
context.AppendLine("using namespace metal;");
|
context.AppendLine("using namespace metal;");
|
||||||
context.AppendLine();
|
context.AppendLine();
|
||||||
|
|
||||||
|
var fsi = (info.HelperFunctionsMask & HelperFunctionsMask.FSI) != 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));
|
||||||
context.AppendLine();
|
context.AppendLine();
|
||||||
DeclareBufferStructures(context, context.Properties.ConstantBuffers.Values, true);
|
DeclareBufferStructures(context, context.Properties.ConstantBuffers.Values, true, fsi);
|
||||||
DeclareBufferStructures(context, context.Properties.StorageBuffers.Values, false);
|
DeclareBufferStructures(context, context.Properties.StorageBuffers.Values, false, fsi);
|
||||||
DeclareTextures(context, context.Properties.Textures.Values);
|
DeclareTextures(context, context.Properties.Textures.Values);
|
||||||
DeclareImages(context, context.Properties.Images.Values);
|
DeclareImages(context, context.Properties.Images.Values, fsi);
|
||||||
|
|
||||||
if ((info.HelperFunctionsMask & HelperFunctionsMask.FindLSB) != 0)
|
if ((info.HelperFunctionsMask & HelperFunctionsMask.FindLSB) != 0)
|
||||||
{
|
{
|
||||||
|
@ -180,7 +182,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DeclareBufferStructures(CodeGenContext context, IEnumerable<BufferDefinition> buffers, bool constant)
|
private static void DeclareBufferStructures(CodeGenContext context, IEnumerable<BufferDefinition> buffers, bool constant, bool fsi)
|
||||||
{
|
{
|
||||||
var name = constant ? "ConstantBuffers" : "StorageBuffers";
|
var name = constant ? "ConstantBuffers" : "StorageBuffers";
|
||||||
var addressSpace = constant ? "constant" : "device";
|
var addressSpace = constant ? "constant" : "device";
|
||||||
|
@ -193,8 +195,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||||
foreach (BufferDefinition buffer in sortedBuffers)
|
foreach (BufferDefinition buffer in sortedBuffers)
|
||||||
{
|
{
|
||||||
var needsPadding = buffer.Layout == BufferLayout.Std140;
|
var needsPadding = buffer.Layout == BufferLayout.Std140;
|
||||||
|
string fsiSuffix = constant && fsi ? " [[raster_order_group(0)]]" : "";
|
||||||
|
|
||||||
argBufferPointers.Add($"{addressSpace} {Defaults.StructPrefix}_{buffer.Name}* {buffer.Name};");
|
argBufferPointers.Add($"{addressSpace} {Defaults.StructPrefix}_{buffer.Name}* {buffer.Name}{fsiSuffix};");
|
||||||
|
|
||||||
context.AppendLine($"struct {Defaults.StructPrefix}_{buffer.Name}");
|
context.AppendLine($"struct {Defaults.StructPrefix}_{buffer.Name}");
|
||||||
context.EnterScope();
|
context.EnterScope();
|
||||||
|
@ -271,7 +274,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||||
context.AppendLine();
|
context.AppendLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DeclareImages(CodeGenContext context, IEnumerable<TextureDefinition> images)
|
private static void DeclareImages(CodeGenContext context, IEnumerable<TextureDefinition> images, bool fsi)
|
||||||
{
|
{
|
||||||
context.AppendLine("struct Images");
|
context.AppendLine("struct Images");
|
||||||
context.EnterScope();
|
context.EnterScope();
|
||||||
|
@ -284,7 +287,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||||
foreach (TextureDefinition image in sortedImages)
|
foreach (TextureDefinition image in sortedImages)
|
||||||
{
|
{
|
||||||
var imageTypeName = image.Type.ToMslTextureType(true);
|
var imageTypeName = image.Type.ToMslTextureType(true);
|
||||||
argBufferPointers.Add($"{imageTypeName} {image.Name};");
|
string fsiSuffix = fsi ? " [[raster_order_group(0)]]" : "";
|
||||||
|
|
||||||
|
argBufferPointers.Add($"{imageTypeName} {image.Name}{fsiSuffix};");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var pointer in argBufferPointers)
|
foreach (var pointer in argBufferPointers)
|
||||||
|
|
|
@ -131,9 +131,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
case Instruction.Call:
|
case Instruction.Call:
|
||||||
return Call(context, operation);
|
return Call(context, operation);
|
||||||
case Instruction.FSIBegin:
|
case Instruction.FSIBegin:
|
||||||
return "|| FSI BEGIN ||";
|
|
||||||
case Instruction.FSIEnd:
|
case Instruction.FSIEnd:
|
||||||
return "|| FSI END ||";
|
return "// FSI implemented with raster order groups in MSL";
|
||||||
case Instruction.GroupMemoryBarrier:
|
case Instruction.GroupMemoryBarrier:
|
||||||
case Instruction.MemoryBarrier:
|
case Instruction.MemoryBarrier:
|
||||||
case Instruction.Barrier:
|
case Instruction.Barrier:
|
||||||
|
|
|
@ -164,8 +164,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
|
|
||||||
public static bool NeedsParenthesis(IAstNode node, Instruction pInst, InstInfo pInfo, bool isLhs)
|
public static bool NeedsParenthesis(IAstNode node, Instruction pInst, InstInfo pInfo, bool isLhs)
|
||||||
{
|
{
|
||||||
// If the node isn't a operation, then it can only be a operand,
|
// If the node isn't an operation, then it can only be an operand,
|
||||||
// and those never needs to be surrounded in parenthesis.
|
// and those never needs to be surrounded in parentheses.
|
||||||
if (node is not AstOperation operation)
|
if (node is not AstOperation operation)
|
||||||
{
|
{
|
||||||
// This is sort of a special case, if this is a negative constant,
|
// This is sort of a special case, if this is a negative constant,
|
||||||
|
|
Loading…
Reference in a new issue