Back to where we were
First special instruction Start Load/Store implementation Start TextureSample Sample progress I/O Load/Store Progress Rest of load/store TODO: Currently, the generator still assumes the GLSL style of I/O attributres. On MSL, the vertex function should output a struct which contains a float4 with the required position attribute. TextureSize and VectorExtract Fix UserDefined IO Vars Fix stage input struct names
This commit is contained in:
parent
5198fcb881
commit
a1b314acd2
10 changed files with 507 additions and 43 deletions
|
@ -3,6 +3,7 @@ using Ryujinx.Graphics.Shader.StructuredIr;
|
|||
using Ryujinx.Graphics.Shader.Translation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
|
@ -23,7 +24,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
|||
|
||||
}
|
||||
|
||||
// DeclareInputAttributes(context, info.IoDefinitions.Where(x => IsUserDefined(x, StorageKind.Input)));
|
||||
DeclareInputAttributes(context, info.IoDefinitions.Where(x => IsUserDefined(x, StorageKind.Input)));
|
||||
}
|
||||
|
||||
static bool IsUserDefined(IoDefinition ioDefinition, StorageKind storageKind)
|
||||
|
@ -66,28 +67,45 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
|||
};
|
||||
}
|
||||
|
||||
// TODO: Redo for new Shader IR rep
|
||||
// private static void DeclareInputAttributes(CodeGenContext context, IEnumerable<IoDefinition> inputs)
|
||||
// {
|
||||
// if (context.AttributeUsage.UsedInputAttributes != 0)
|
||||
// {
|
||||
// context.AppendLine("struct VertexIn");
|
||||
// context.EnterScope();
|
||||
//
|
||||
// int usedAttributes = context.AttributeUsage.UsedInputAttributes | context.AttributeUsage.PassthroughAttributes;
|
||||
// while (usedAttributes != 0)
|
||||
// {
|
||||
// int index = BitOperations.TrailingZeroCount(usedAttributes);
|
||||
//
|
||||
// string name = $"{DefaultNames.IAttributePrefix}{index}";
|
||||
// var type = context.AttributeUsage.get .QueryAttributeType(index).ToVec4Type(TargetLanguage.Msl);
|
||||
// context.AppendLine($"{type} {name} [[attribute({index})]];");
|
||||
//
|
||||
// usedAttributes &= ~(1 << index);
|
||||
// }
|
||||
//
|
||||
// context.LeaveScope(";");
|
||||
// }
|
||||
// }
|
||||
private static void DeclareInputAttributes(CodeGenContext context, IEnumerable<IoDefinition> inputs)
|
||||
{
|
||||
if (context.Definitions.IaIndexing)
|
||||
{
|
||||
// Not handled
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inputs.Any())
|
||||
{
|
||||
string prefix = "";
|
||||
|
||||
switch (context.Definitions.Stage)
|
||||
{
|
||||
case ShaderStage.Vertex:
|
||||
prefix = "Vertex";
|
||||
break;
|
||||
case ShaderStage.Fragment:
|
||||
prefix = "Fragment";
|
||||
break;
|
||||
case ShaderStage.Compute:
|
||||
prefix = "Compute";
|
||||
break;
|
||||
}
|
||||
|
||||
context.AppendLine($"struct {prefix}In");
|
||||
context.EnterScope();
|
||||
|
||||
foreach (var ioDefinition in inputs.OrderBy(x => x.Location))
|
||||
{
|
||||
string type = GetVarTypeName(context, context.Definitions.GetUserDefinedType(ioDefinition.Location, isOutput: false));
|
||||
string name = $"{DefaultNames.IAttributePrefix}{ioDefinition.Location}";
|
||||
|
||||
context.AppendLine($"{type} {name} [[attribute({ioDefinition.Location})]];");
|
||||
}
|
||||
|
||||
context.LeaveScope(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue