Fix modulo operator
Support sample offsets Include FragmentIn as additional arg Always declare frag output struct SubgroupLaneId
This commit is contained in:
committed by
Isaac Marovitz
parent
fad653c12e
commit
efb7baf15c
@@ -13,12 +13,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
var functon = context.GetFunction(funcId.Value);
|
||||
|
||||
int argCount = operation.SourcesCount - 1;
|
||||
string[] args = new string[argCount + CodeGenContext.additionalArgCount];
|
||||
string[] args = new string[argCount + CodeGenContext.AdditionalArgCount];
|
||||
|
||||
// Additional arguments
|
||||
args[0] = "support_buffer";
|
||||
args[0] = "in";
|
||||
args[1] = "support_buffer";
|
||||
|
||||
int argIndex = CodeGenContext.additionalArgCount;
|
||||
int argIndex = CodeGenContext.AdditionalArgCount;
|
||||
for (int i = 0; i < argCount; i++)
|
||||
{
|
||||
args[argIndex++] = GetSourceExpr(context, operation.GetSource(i + 1), functon.GetArgumentType(i));
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
Add(Instruction.MemoryBarrier, InstType.Special);
|
||||
Add(Instruction.Minimum, InstType.CallBinary, "min");
|
||||
Add(Instruction.MinimumU32, InstType.CallBinary, "min");
|
||||
Add(Instruction.Modulo, InstType.CallBinary, "%");
|
||||
Add(Instruction.Modulo, InstType.CallBinary, "fmod");
|
||||
Add(Instruction.Multiply, InstType.OpBinaryCom, "*", 1);
|
||||
Add(Instruction.MultiplyHighS32, InstType.CallBinary, "mulhi");
|
||||
Add(Instruction.MultiplyHighU32, InstType.CallBinary, "mulhi");
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
||||
using Ryujinx.Graphics.Shader.StructuredIr;
|
||||
using Ryujinx.Graphics.Shader.Translation;
|
||||
@@ -193,11 +194,15 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
AstTextureOperation texOp = (AstTextureOperation)operation;
|
||||
|
||||
bool isGather = (texOp.Flags & TextureFlags.Gather) != 0;
|
||||
bool isShadow = (texOp.Type & SamplerType.Shadow) != 0;
|
||||
bool hasDerivatives = (texOp.Flags & TextureFlags.Derivatives) != 0;
|
||||
bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0;
|
||||
bool hasLodBias = (texOp.Flags & TextureFlags.LodBias) != 0;
|
||||
bool hasLodLevel = (texOp.Flags & TextureFlags.LodLevel) != 0;
|
||||
bool hasOffset = (texOp.Flags & TextureFlags.Offset) != 0;
|
||||
bool hasOffsets = (texOp.Flags & TextureFlags.Offsets) != 0;
|
||||
|
||||
bool isArray = (texOp.Type & SamplerType.Array) != 0;
|
||||
bool isShadow = (texOp.Type & SamplerType.Shadow) != 0;
|
||||
|
||||
bool colorIsVector = isGather || !isShadow;
|
||||
|
||||
@@ -291,6 +296,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
Append(Src(AggregateType.S32));
|
||||
}
|
||||
|
||||
if (hasDerivatives)
|
||||
{
|
||||
Logger.Warning?.PrintMsg(LogClass.Gpu, "Unused sampler derivatives!");
|
||||
}
|
||||
|
||||
if (hasLodBias)
|
||||
{
|
||||
Logger.Warning?.PrintMsg(LogClass.Gpu, "Unused sample LOD bias!");
|
||||
}
|
||||
|
||||
if (hasLodLevel)
|
||||
{
|
||||
if (intCoords)
|
||||
@@ -303,7 +318,37 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Support offsets
|
||||
string AssembleOffsetVector(int count)
|
||||
{
|
||||
if (count > 1)
|
||||
{
|
||||
string[] elems = new string[count];
|
||||
|
||||
for (int index = 0; index < count; index++)
|
||||
{
|
||||
elems[index] = Src(AggregateType.S32);
|
||||
}
|
||||
|
||||
return "int" + count + "(" + string.Join(", ", elems) + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return Src(AggregateType.S32);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Support reads with offsets
|
||||
if (!intCoords)
|
||||
{
|
||||
if (hasOffset)
|
||||
{
|
||||
Append(AssembleOffsetVector(coordsCount));
|
||||
}
|
||||
else if (hasOffsets)
|
||||
{
|
||||
Logger.Warning?.PrintMsg(LogClass.Gpu, "Multiple offsets on gathers are not yet supported!");
|
||||
}
|
||||
}
|
||||
|
||||
texCall += ")" + (colorIsVector ? GetMaskMultiDest(texOp.Index) : "");
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
IoVariable.PrimitiveId => ("primitive_id", AggregateType.S32),
|
||||
IoVariable.UserDefined => GetUserDefinedVariableName(definitions, location, component, isOutput, isPerPatch),
|
||||
IoVariable.ThreadId => ("thread_position_in_threadgroup", AggregateType.Vector3 | AggregateType.U32),
|
||||
IoVariable.SubgroupLaneId => ("thread_index_in_simdgroup", AggregateType.U32),
|
||||
IoVariable.VertexId => ("vertex_id", AggregateType.S32),
|
||||
// gl_VertexIndex does not have a direct equivalent in MSL
|
||||
IoVariable.VertexIndex => ("vertex_id", AggregateType.U32),
|
||||
|
||||
Reference in New Issue
Block a user