mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-05-09 14:55:45 +00:00
feature: .NET 10 (ryubing/ryujinx!214)
See merge request ryubing/ryujinx!214
This commit is contained in:
@@ -20,20 +20,18 @@ namespace Ryujinx.Graphics.Shader
|
||||
|
||||
static class AttributeTypeExtensions
|
||||
{
|
||||
public static AggregateType ToAggregateType(this AttributeType type)
|
||||
extension(AttributeType type)
|
||||
{
|
||||
return (type & ~AttributeType.AnyPacked) switch
|
||||
public AggregateType Aggregate =>
|
||||
(type & ~AttributeType.AnyPacked) switch
|
||||
{
|
||||
AttributeType.Float => AggregateType.FP32,
|
||||
AttributeType.Sint => AggregateType.S32,
|
||||
AttributeType.Uint => AggregateType.U32,
|
||||
_ => throw new ArgumentException($"Invalid attribute type \"{type}\"."),
|
||||
};
|
||||
}
|
||||
|
||||
public static AggregateType ToAggregateType(this AttributeType type, bool supportsScaledFormats)
|
||||
{
|
||||
return (type & ~AttributeType.AnyPacked) switch
|
||||
|
||||
public AggregateType AsAggregate(bool supportsScaledFormats) => (type & ~AttributeType.AnyPacked) switch
|
||||
{
|
||||
AttributeType.Float => AggregateType.FP32,
|
||||
AttributeType.Sint => AggregateType.S32,
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
{
|
||||
if (context.Definitions.Stage == ShaderStage.Geometry)
|
||||
{
|
||||
string inPrimitive = context.Definitions.InputTopology.ToGlslString();
|
||||
string inPrimitive = context.Definitions.InputTopology.GlslString;
|
||||
|
||||
context.AppendLine($"layout (invocations = {context.Definitions.ThreadsPerInputPrimitive}, {inPrimitive}) in;");
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
}
|
||||
else
|
||||
{
|
||||
string outPrimitive = context.Definitions.OutputTopology.ToGlslString();
|
||||
string outPrimitive = context.Definitions.OutputTopology.GlslString;
|
||||
int maxOutputVertices = context.Definitions.MaxOutputVertices;
|
||||
|
||||
context.AppendLine($"layout ({outPrimitive}, max_vertices = {maxOutputVertices}) out;");
|
||||
@@ -123,8 +123,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
tessCw = !tessCw;
|
||||
}
|
||||
|
||||
string patchType = context.Definitions.TessPatchType.ToGlsl();
|
||||
string spacing = context.Definitions.TessSpacing.ToGlsl();
|
||||
string patchType = context.Definitions.TessPatchType.Glsl;
|
||||
string spacing = context.Definitions.TessSpacing.Glsl;
|
||||
string windingOrder = tessCw ? "cw" : "ccw";
|
||||
|
||||
context.AppendLine($"layout ({patchType}, {spacing}, {windingOrder}) in;");
|
||||
@@ -351,7 +351,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
arrayDecl = "[]";
|
||||
}
|
||||
|
||||
string samplerTypeName = definition.Separate ? definition.Type.ToGlslTextureType() : definition.Type.ToGlslSamplerType();
|
||||
string samplerTypeName = definition.Separate ? definition.Type.GlslTextureTypeName : definition.Type.GlslSamplerTypeName;
|
||||
|
||||
string layout = string.Empty;
|
||||
|
||||
@@ -379,7 +379,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
arrayDecl = "[]";
|
||||
}
|
||||
|
||||
string imageTypeName = definition.Type.ToGlslImageType(definition.Format.GetComponentType());
|
||||
string imageTypeName = definition.Type.GetGlslImageTypeName(definition.Format.GetComponentType());
|
||||
|
||||
if (definition.Flags.HasFlag(TextureUsageFlags.ImageCoherent))
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
texCallBuilder.Append('(');
|
||||
texCallBuilder.Append(imageName);
|
||||
|
||||
int coordsCount = texOp.Type.GetDimensions();
|
||||
int coordsCount = texOp.Type.Dimensions;
|
||||
|
||||
int pCount = coordsCount + (isArray ? 1 : 0);
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
{
|
||||
AstTextureOperation texOp = (AstTextureOperation)operation;
|
||||
|
||||
int coordsCount = texOp.Type.GetDimensions();
|
||||
int coordsCount = texOp.Type.Dimensions;
|
||||
int coordsIndex = 0;
|
||||
|
||||
string samplerName = GetSamplerName(context, texOp, ref coordsIndex);
|
||||
@@ -264,7 +264,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
|
||||
texCall += "(" + samplerName;
|
||||
|
||||
int coordsCount = texOp.Type.GetDimensions();
|
||||
int coordsCount = texOp.Type.Dimensions;
|
||||
|
||||
int pCount = coordsCount;
|
||||
|
||||
@@ -658,7 +658,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
samplerName = $"{samplerName}[{GetSourceExpr(context, texOp.GetSource(srcIndex++), AggregateType.S32)}]";
|
||||
}
|
||||
|
||||
name = $"{texOp.Type.ToGlslSamplerType()}({name}, {samplerName})";
|
||||
name = $"{texOp.Type.GlslSamplerTypeName}({name}, {samplerName})";
|
||||
}
|
||||
|
||||
return name;
|
||||
|
||||
@@ -385,12 +385,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
|
||||
private static void DeclarePerVertexBlock(CodeGenContext context)
|
||||
{
|
||||
if (context.Definitions.Stage.IsVtg())
|
||||
if (context.Definitions.Stage.IsVtg)
|
||||
{
|
||||
if (context.Definitions.Stage != ShaderStage.Vertex)
|
||||
{
|
||||
SpvInstruction perVertexInputStructType = CreatePerVertexStructType(context);
|
||||
int arraySize = context.Definitions.Stage == ShaderStage.Geometry ? context.Definitions.InputTopology.ToInputVertices() : 32;
|
||||
int arraySize = context.Definitions.Stage == ShaderStage.Geometry ? context.Definitions.InputTopology.InputVertexCount : 32;
|
||||
SpvInstruction perVertexInputArrayType = context.TypeArray(perVertexInputStructType, context.Constant(context.TypeU32(), arraySize));
|
||||
SpvInstruction perVertexInputPointerType = context.TypePointer(StorageClass.Input, perVertexInputArrayType);
|
||||
SpvInstruction perVertexInputVariable = context.Variable(perVertexInputPointerType, StorageClass.Input);
|
||||
@@ -537,7 +537,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
|
||||
if (!isPerPatch && IoMap.IsPerVertex(ioVariable, context.Definitions.Stage, isOutput))
|
||||
{
|
||||
int arraySize = context.Definitions.Stage == ShaderStage.Geometry ? context.Definitions.InputTopology.ToInputVertices() : 32;
|
||||
int arraySize = context.Definitions.Stage == ShaderStage.Geometry ? context.Definitions.InputTopology.InputVertexCount : 32;
|
||||
spvType = context.TypeArray(spvType, context.Constant(context.TypeU32(), arraySize));
|
||||
|
||||
if (context.Definitions.GpPassthrough && context.HostCapabilities.SupportsGeometryShaderPassthrough)
|
||||
|
||||
@@ -615,7 +615,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
image = context.AccessChain(imagePointerType, image, textureIndex);
|
||||
}
|
||||
|
||||
int coordsCount = texOp.Type.GetDimensions();
|
||||
int coordsCount = texOp.Type.Dimensions;
|
||||
|
||||
int pCount = coordsCount + (isArray ? 1 : 0);
|
||||
|
||||
@@ -693,7 +693,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
|
||||
image = context.Load(declaration.ImageType, image);
|
||||
|
||||
int coordsCount = texOp.Type.GetDimensions();
|
||||
int coordsCount = texOp.Type.Dimensions;
|
||||
|
||||
int pCount = coordsCount + (isArray ? 1 : 0);
|
||||
|
||||
@@ -750,7 +750,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
|
||||
image = context.Load(declaration.ImageType, image);
|
||||
|
||||
int coordsCount = texOp.Type.GetDimensions();
|
||||
int coordsCount = texOp.Type.Dimensions;
|
||||
|
||||
int pCount = coordsCount + (isArray ? 1 : 0);
|
||||
|
||||
@@ -840,7 +840,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
SamplerDeclaration declaration = context.Samplers[texOp.GetTextureSetAndBinding()];
|
||||
SpvInstruction image = GenerateSampledImageLoad(context, texOp, declaration, ref srcIndex);
|
||||
|
||||
int pCount = texOp.Type.GetDimensions();
|
||||
int pCount = texOp.Type.Dimensions;
|
||||
|
||||
SpvInstruction pCoords;
|
||||
|
||||
@@ -1164,7 +1164,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
SamplerDeclaration declaration = context.Samplers[texOp.GetTextureSetAndBinding()];
|
||||
SpvInstruction image = GenerateSampledImageLoad(context, texOp, declaration, ref srcIndex);
|
||||
|
||||
int coordsCount = texOp.Type.GetDimensions();
|
||||
int coordsCount = texOp.Type.Dimensions;
|
||||
|
||||
int pCount = coordsCount;
|
||||
|
||||
@@ -1463,7 +1463,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
SamplerType type = context.SamplersTypes[texOp.GetTextureSetAndBinding()];
|
||||
bool hasLod = !type.HasFlag(SamplerType.Multisample) && type != SamplerType.TextureBuffer;
|
||||
|
||||
int dimensions = (type & SamplerType.Mask) == SamplerType.TextureCube ? 2 : type.GetDimensions();
|
||||
int dimensions = (type & SamplerType.Mask) == SamplerType.TextureCube ? 2 : type.Dimensions;
|
||||
|
||||
if (type.HasFlag(SamplerType.Array))
|
||||
{
|
||||
@@ -1486,7 +1486,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
|
||||
if (dimensions != 1)
|
||||
{
|
||||
result = context.CompositeExtract(context.TypeS32(), result, (SpvLiteralInteger)texOp.Index);
|
||||
result = context.CompositeExtract(context.TypeS32(), result, texOp.Index);
|
||||
}
|
||||
|
||||
return new OperationResult(AggregateType.S32, result);
|
||||
|
||||
@@ -457,7 +457,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
||||
case AttributeConsts.ClipDistance5:
|
||||
case AttributeConsts.ClipDistance6:
|
||||
case AttributeConsts.ClipDistance7:
|
||||
if (definitions.Stage.IsVtg())
|
||||
if (definitions.Stage.IsVtg)
|
||||
{
|
||||
context.SetClipDistanceWritten((attr - AttributeConsts.ClipDistance0) / 4);
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace Ryujinx.Graphics.Shader
|
||||
|
||||
static class InputTopologyExtensions
|
||||
{
|
||||
public static string ToGlslString(this InputTopology topology)
|
||||
extension(InputTopology topology)
|
||||
{
|
||||
return topology switch
|
||||
public string GlslString => topology switch
|
||||
{
|
||||
InputTopology.Points => "points",
|
||||
InputTopology.Lines => "lines",
|
||||
@@ -22,11 +22,8 @@ namespace Ryujinx.Graphics.Shader
|
||||
InputTopology.TrianglesAdjacency => "triangles_adjacency",
|
||||
_ => "points",
|
||||
};
|
||||
}
|
||||
|
||||
public static int ToInputVertices(this InputTopology topology)
|
||||
{
|
||||
return topology switch
|
||||
|
||||
public int InputVertexCount => topology switch
|
||||
{
|
||||
InputTopology.Points => 1,
|
||||
InputTopology.Lines => 2,
|
||||
@@ -35,17 +32,14 @@ namespace Ryujinx.Graphics.Shader
|
||||
InputTopology.TrianglesAdjacency => 6,
|
||||
_ => 1,
|
||||
};
|
||||
}
|
||||
|
||||
public static int ToInputVerticesNoAdjacency(this InputTopology topology)
|
||||
{
|
||||
return topology switch
|
||||
|
||||
public int InputVertexCountNoAdjacency => topology switch
|
||||
{
|
||||
InputTopology.Points => 1,
|
||||
InputTopology.Lines or
|
||||
InputTopology.LinesAdjacency => 2,
|
||||
InputTopology.LinesAdjacency => 2,
|
||||
InputTopology.Triangles or
|
||||
InputTopology.TrianglesAdjacency => 3,
|
||||
InputTopology.TrianglesAdjacency => 3,
|
||||
_ => 1,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
}
|
||||
else
|
||||
{
|
||||
src = Const(context.TranslatorContext.Definitions.InputTopology.ToInputVertices() << 16);
|
||||
src = Const(context.TranslatorContext.Definitions.InputTopology.InputVertexCount << 16);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
sourcesList.Add(context.Copy(GetSrcReg(context, srcC)));
|
||||
}
|
||||
|
||||
int coordsCount = type.GetDimensions();
|
||||
int coordsCount = type.Dimensions;
|
||||
|
||||
for (int index = 0; index < coordsCount; index++)
|
||||
{
|
||||
@@ -335,7 +335,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
sourcesList.Add(context.Copy(Register(srcC, RegisterType.Gpr)));
|
||||
}
|
||||
|
||||
int coordsCount = type.GetDimensions();
|
||||
int coordsCount = type.Dimensions;
|
||||
|
||||
for (int index = 0; index < coordsCount; index++)
|
||||
{
|
||||
@@ -507,7 +507,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
sourcesList.Add(context.Copy(GetSrcReg(context, srcC)));
|
||||
}
|
||||
|
||||
int coordsCount = type.GetDimensions();
|
||||
int coordsCount = type.Dimensions;
|
||||
|
||||
for (int index = 0; index < coordsCount; index++)
|
||||
{
|
||||
@@ -612,7 +612,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
sourcesList.Add(context.Copy(Register(srcC, RegisterType.Gpr)));
|
||||
}
|
||||
|
||||
int coordsCount = type.GetDimensions();
|
||||
int coordsCount = type.Dimensions;
|
||||
|
||||
for (int index = 0; index < coordsCount; index++)
|
||||
{
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
}
|
||||
}
|
||||
|
||||
int coordsCount = type.GetDimensions();
|
||||
int coordsCount = type.Dimensions;
|
||||
|
||||
for (int index = 0; index < coordsCount; index++)
|
||||
{
|
||||
@@ -558,7 +558,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
|
||||
if ((flags & TextureFlags.Offset) != 0)
|
||||
{
|
||||
AddTextureOffset(type.GetDimensions(), 4, 4);
|
||||
AddTextureOffset(type.Dimensions, 4, 4);
|
||||
}
|
||||
}
|
||||
else if (texsType == TexsType.Tld4s)
|
||||
@@ -583,7 +583,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
|
||||
if (tld4sOp.Aoffi)
|
||||
{
|
||||
AddTextureOffset(type.GetDimensions(), 8, 6);
|
||||
AddTextureOffset(type.Dimensions, 8, 6);
|
||||
|
||||
flags |= TextureFlags.Offset;
|
||||
}
|
||||
@@ -714,7 +714,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
flags |= TextureFlags.Bindless;
|
||||
}
|
||||
|
||||
int coordsCount = type.GetDimensions();
|
||||
int coordsCount = type.Dimensions;
|
||||
|
||||
for (int index = 0; index < coordsCount; index++)
|
||||
{
|
||||
@@ -847,7 +847,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
|
||||
SamplerType type = ConvertSamplerType(dimensions);
|
||||
|
||||
int coordsCount = type.GetDimensions();
|
||||
int coordsCount = type.Dimensions;
|
||||
|
||||
bool isArray =
|
||||
dimensions is TexDim.Array1d or
|
||||
@@ -942,26 +942,6 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
return;
|
||||
}
|
||||
|
||||
Operand Ra()
|
||||
{
|
||||
if (srcA > RegisterConsts.RegisterZeroIndex)
|
||||
{
|
||||
return Const(0);
|
||||
}
|
||||
|
||||
return context.Copy(Register(srcA++, RegisterType.Gpr));
|
||||
}
|
||||
|
||||
Operand Rb()
|
||||
{
|
||||
if (srcB > RegisterConsts.RegisterZeroIndex)
|
||||
{
|
||||
return Const(0);
|
||||
}
|
||||
|
||||
return context.Copy(Register(srcB++, RegisterType.Gpr));
|
||||
}
|
||||
|
||||
TextureFlags flags = TextureFlags.Derivatives;
|
||||
|
||||
List<Operand> sourcesList = [];
|
||||
@@ -975,7 +955,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
|
||||
SamplerType type = ConvertSamplerType(dimensions);
|
||||
|
||||
int coordsCount = type.GetDimensions();
|
||||
int coordsCount = type.Dimensions;
|
||||
|
||||
for (int index = 0; index < coordsCount; index++)
|
||||
{
|
||||
@@ -1051,6 +1031,28 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
}
|
||||
|
||||
EmitTextureSample(context, type, flags, imm, componentMask, dests, sources);
|
||||
|
||||
return;
|
||||
|
||||
Operand Ra()
|
||||
{
|
||||
if (srcA > RegisterConsts.RegisterZeroIndex)
|
||||
{
|
||||
return Const(0);
|
||||
}
|
||||
|
||||
return context.Copy(Register(srcA++, RegisterType.Gpr));
|
||||
}
|
||||
|
||||
Operand Rb()
|
||||
{
|
||||
if (srcB > RegisterConsts.RegisterZeroIndex)
|
||||
{
|
||||
return Const(0);
|
||||
}
|
||||
|
||||
return context.Copy(Register(srcB++, RegisterType.Gpr));
|
||||
}
|
||||
}
|
||||
|
||||
private static void EmitTxq(
|
||||
|
||||
@@ -9,9 +9,10 @@ namespace Ryujinx.Graphics.Shader
|
||||
|
||||
static class OutputTopologyExtensions
|
||||
{
|
||||
public static string ToGlslString(this OutputTopology topology)
|
||||
|
||||
extension(OutputTopology topology)
|
||||
{
|
||||
return topology switch
|
||||
public string GlslString => topology switch
|
||||
{
|
||||
OutputTopology.LineStrip => "line_strip",
|
||||
OutputTopology.PointList => "points",
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace Ryujinx.Graphics.Shader
|
||||
|
||||
static class SamplerTypeExtensions
|
||||
{
|
||||
public static int GetDimensions(this SamplerType type)
|
||||
extension(SamplerType type)
|
||||
{
|
||||
return (type & SamplerType.Mask) switch
|
||||
public int Dimensions => (type & SamplerType.Mask) switch
|
||||
{
|
||||
SamplerType.Texture1D => 1,
|
||||
SamplerType.TextureBuffer => 1,
|
||||
@@ -33,127 +33,136 @@ namespace Ryujinx.Graphics.Shader
|
||||
SamplerType.TextureCube => 3,
|
||||
_ => throw new ArgumentException($"Invalid sampler type \"{type}\"."),
|
||||
};
|
||||
}
|
||||
|
||||
public static string ToShortSamplerType(this SamplerType type)
|
||||
{
|
||||
string typeName = (type & SamplerType.Mask) switch
|
||||
public string ShortTypeName
|
||||
{
|
||||
SamplerType.Texture1D => "1d",
|
||||
SamplerType.TextureBuffer => "b",
|
||||
SamplerType.Texture2D => "2d",
|
||||
SamplerType.Texture3D => "3d",
|
||||
SamplerType.TextureCube => "cube",
|
||||
_ => throw new ArgumentException($"Invalid sampler type \"{type}\"."),
|
||||
};
|
||||
get
|
||||
{
|
||||
string typeName = (type & SamplerType.Mask) switch
|
||||
{
|
||||
SamplerType.Texture1D => "1d",
|
||||
SamplerType.TextureBuffer => "b",
|
||||
SamplerType.Texture2D => "2d",
|
||||
SamplerType.Texture3D => "3d",
|
||||
SamplerType.TextureCube => "cube",
|
||||
_ => throw new ArgumentException($"Invalid sampler type \"{type}\"."),
|
||||
};
|
||||
|
||||
if ((type & SamplerType.Multisample) != 0)
|
||||
{
|
||||
typeName += "ms";
|
||||
if ((type & SamplerType.Multisample) != 0)
|
||||
{
|
||||
typeName += "ms";
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Array) != 0)
|
||||
{
|
||||
typeName += "a";
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Shadow) != 0)
|
||||
{
|
||||
typeName += "s";
|
||||
}
|
||||
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Array) != 0)
|
||||
public string GlslSamplerTypeName
|
||||
{
|
||||
typeName += "a";
|
||||
get
|
||||
{
|
||||
string typeName = (type & SamplerType.Mask) switch
|
||||
{
|
||||
SamplerType.None => "sampler",
|
||||
SamplerType.Texture1D => "sampler1D",
|
||||
SamplerType.TextureBuffer => "samplerBuffer",
|
||||
SamplerType.Texture2D => "sampler2D",
|
||||
SamplerType.Texture3D => "sampler3D",
|
||||
SamplerType.TextureCube => "samplerCube",
|
||||
_ => throw new ArgumentException($"Invalid sampler type \"{type}\"."),
|
||||
};
|
||||
|
||||
if ((type & SamplerType.Multisample) != 0)
|
||||
{
|
||||
typeName += "MS";
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Array) != 0)
|
||||
{
|
||||
typeName += "Array";
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Shadow) != 0)
|
||||
{
|
||||
typeName += "Shadow";
|
||||
}
|
||||
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Shadow) != 0)
|
||||
public string GlslTextureTypeName
|
||||
{
|
||||
typeName += "s";
|
||||
get
|
||||
{
|
||||
string typeName = (type & SamplerType.Mask) switch
|
||||
{
|
||||
SamplerType.Texture1D => "texture1D",
|
||||
SamplerType.TextureBuffer => "textureBuffer",
|
||||
SamplerType.Texture2D => "texture2D",
|
||||
SamplerType.Texture3D => "texture3D",
|
||||
SamplerType.TextureCube => "textureCube",
|
||||
_ => throw new ArgumentException($"Invalid texture type \"{type}\"."),
|
||||
};
|
||||
|
||||
if ((type & SamplerType.Multisample) != 0)
|
||||
{
|
||||
typeName += "MS";
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Array) != 0)
|
||||
{
|
||||
typeName += "Array";
|
||||
}
|
||||
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public static string ToGlslSamplerType(this SamplerType type)
|
||||
{
|
||||
string typeName = (type & SamplerType.Mask) switch
|
||||
public string GetGlslImageTypeName(AggregateType componentType)
|
||||
{
|
||||
SamplerType.None => "sampler",
|
||||
SamplerType.Texture1D => "sampler1D",
|
||||
SamplerType.TextureBuffer => "samplerBuffer",
|
||||
SamplerType.Texture2D => "sampler2D",
|
||||
SamplerType.Texture3D => "sampler3D",
|
||||
SamplerType.TextureCube => "samplerCube",
|
||||
_ => throw new ArgumentException($"Invalid sampler type \"{type}\"."),
|
||||
};
|
||||
string typeName = (type & SamplerType.Mask) switch
|
||||
{
|
||||
SamplerType.Texture1D => "image1D",
|
||||
SamplerType.TextureBuffer => "imageBuffer",
|
||||
SamplerType.Texture2D => "image2D",
|
||||
SamplerType.Texture3D => "image3D",
|
||||
SamplerType.TextureCube => "imageCube",
|
||||
_ => throw new ArgumentException($"Invalid sampler type \"{type}\"."),
|
||||
};
|
||||
|
||||
if ((type & SamplerType.Multisample) != 0)
|
||||
{
|
||||
typeName += "MS";
|
||||
if ((type & SamplerType.Multisample) != 0)
|
||||
{
|
||||
typeName += "MS";
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Array) != 0)
|
||||
{
|
||||
typeName += "Array";
|
||||
}
|
||||
|
||||
switch (componentType)
|
||||
{
|
||||
case AggregateType.U32:
|
||||
typeName = 'u' + typeName;
|
||||
break;
|
||||
case AggregateType.S32:
|
||||
typeName = 'i' + typeName;
|
||||
break;
|
||||
}
|
||||
|
||||
return typeName;
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Array) != 0)
|
||||
{
|
||||
typeName += "Array";
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Shadow) != 0)
|
||||
{
|
||||
typeName += "Shadow";
|
||||
}
|
||||
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public static string ToGlslTextureType(this SamplerType type)
|
||||
{
|
||||
string typeName = (type & SamplerType.Mask) switch
|
||||
{
|
||||
SamplerType.Texture1D => "texture1D",
|
||||
SamplerType.TextureBuffer => "textureBuffer",
|
||||
SamplerType.Texture2D => "texture2D",
|
||||
SamplerType.Texture3D => "texture3D",
|
||||
SamplerType.TextureCube => "textureCube",
|
||||
_ => throw new ArgumentException($"Invalid texture type \"{type}\"."),
|
||||
};
|
||||
|
||||
if ((type & SamplerType.Multisample) != 0)
|
||||
{
|
||||
typeName += "MS";
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Array) != 0)
|
||||
{
|
||||
typeName += "Array";
|
||||
}
|
||||
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public static string ToGlslImageType(this SamplerType type, AggregateType componentType)
|
||||
{
|
||||
string typeName = (type & SamplerType.Mask) switch
|
||||
{
|
||||
SamplerType.Texture1D => "image1D",
|
||||
SamplerType.TextureBuffer => "imageBuffer",
|
||||
SamplerType.Texture2D => "image2D",
|
||||
SamplerType.Texture3D => "image3D",
|
||||
SamplerType.TextureCube => "imageCube",
|
||||
_ => throw new ArgumentException($"Invalid sampler type \"{type}\"."),
|
||||
};
|
||||
|
||||
if ((type & SamplerType.Multisample) != 0)
|
||||
{
|
||||
typeName += "MS";
|
||||
}
|
||||
|
||||
if ((type & SamplerType.Array) != 0)
|
||||
{
|
||||
typeName += "Array";
|
||||
}
|
||||
|
||||
switch (componentType)
|
||||
{
|
||||
case AggregateType.U32:
|
||||
typeName = 'u' + typeName;
|
||||
break;
|
||||
case AggregateType.S32:
|
||||
typeName = 'i' + typeName;
|
||||
break;
|
||||
}
|
||||
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,27 +14,23 @@ namespace Ryujinx.Graphics.Shader
|
||||
|
||||
public static class ShaderStageExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if the shader stage supports render scale.
|
||||
/// </summary>
|
||||
/// <param name="stage">Shader stage</param>
|
||||
/// <returns>True if the shader stage supports render scale, false otherwise</returns>
|
||||
public static bool SupportsRenderScale(this ShaderStage stage)
|
||||
extension(ShaderStage shaderStage)
|
||||
{
|
||||
return stage is ShaderStage.Vertex or ShaderStage.Fragment or ShaderStage.Compute;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the shader stage is vertex, tessellation or geometry.
|
||||
/// </summary>
|
||||
/// <param name="stage">Shader stage</param>
|
||||
/// <returns>True if the shader stage is vertex, tessellation or geometry, false otherwise</returns>
|
||||
public static bool IsVtg(this ShaderStage stage)
|
||||
{
|
||||
return stage is ShaderStage.Vertex or
|
||||
ShaderStage.TessellationControl or
|
||||
ShaderStage.TessellationEvaluation or
|
||||
ShaderStage.Geometry;
|
||||
/// <summary>
|
||||
/// Checks if the shader stage supports render scale.
|
||||
/// </summary>
|
||||
public bool SupportsRenderScale =>
|
||||
shaderStage is ShaderStage.Vertex or ShaderStage.Fragment or ShaderStage.Compute;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the shader stage is vertex, tessellation or geometry.
|
||||
/// </summary>
|
||||
public bool IsVtg =>
|
||||
shaderStage is ShaderStage.Vertex or
|
||||
ShaderStage.TessellationControl or
|
||||
ShaderStage.TessellationEvaluation or
|
||||
ShaderStage.Geometry;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ namespace Ryujinx.Graphics.Shader
|
||||
|
||||
static class TessPatchTypeExtensions
|
||||
{
|
||||
public static string ToGlsl(this TessPatchType type)
|
||||
extension(TessPatchType patchType)
|
||||
{
|
||||
return type switch
|
||||
public string Glsl => patchType switch
|
||||
{
|
||||
TessPatchType.Isolines => "isolines",
|
||||
TessPatchType.Quads => "quads",
|
||||
|
||||
@@ -9,9 +9,9 @@ namespace Ryujinx.Graphics.Shader
|
||||
|
||||
static class TessSpacingExtensions
|
||||
{
|
||||
public static string ToGlsl(this TessSpacing spacing)
|
||||
extension(TessSpacing spacing)
|
||||
{
|
||||
return spacing switch
|
||||
public string Glsl => spacing switch
|
||||
{
|
||||
TessSpacing.FractionalEventSpacing => "fractional_even_spacing",
|
||||
TessSpacing.FractionalOddSpacing => "fractional_odd_spacing",
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
}
|
||||
else if (TranslatorContext.Stage == ShaderStage.Geometry)
|
||||
{
|
||||
int inputVertices = TranslatorContext.Definitions.InputTopology.ToInputVertices();
|
||||
int inputVertices = TranslatorContext.Definitions.InputTopology.InputVertexCount;
|
||||
|
||||
Operand baseVertex = this.IMultiply(outputVertexOffset, Const(inputVertices));
|
||||
|
||||
@@ -404,7 +404,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
else
|
||||
{
|
||||
inputStart = 0;
|
||||
inputEnd = topology.ToInputVerticesNoAdjacency();
|
||||
inputEnd = topology.InputVertexCountNoAdjacency;
|
||||
inputStep = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
||||
// Set any destination variables to zero.
|
||||
|
||||
string typeName = texOp.Inst.IsImage()
|
||||
? texOp.Type.ToGlslImageType(texOp.Format.GetComponentType())
|
||||
: texOp.Type.ToGlslTextureType();
|
||||
? texOp.Type.GetGlslImageTypeName(texOp.Format.GetComponentType())
|
||||
: texOp.Type.GlslTextureTypeName;
|
||||
|
||||
gpuAccessor.Log($"Failed to find handle source for bindless access of type \"{typeName}\".");
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
}
|
||||
else if (stage == ShaderStage.Geometry)
|
||||
{
|
||||
LocalTopologyRemapMemoryId = AddMemoryDefinition("local_topology_remap", AggregateType.Array | AggregateType.U32, inputTopology.ToInputVertices());
|
||||
LocalTopologyRemapMemoryId = AddMemoryDefinition("local_topology_remap", AggregateType.Array | AggregateType.U32, inputTopology.InputVertexCount);
|
||||
|
||||
LocalGeometryOutputVertexCountMemoryId = AddMemoryDefinition("local_geometry_output_vertex", AggregateType.U32);
|
||||
LocalGeometryOutputIndexCountMemoryId = AddMemoryDefinition("local_geometry_output_index", AggregateType.U32);
|
||||
@@ -273,7 +273,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
bool coherent,
|
||||
bool separate)
|
||||
{
|
||||
int dimensions = type == SamplerType.None ? 0 : type.GetDimensions();
|
||||
int dimensions = type == SamplerType.None ? 0 : type.Dimensions;
|
||||
Dictionary<TextureInfo, TextureMeta> dict = isImage ? _usedImages : _usedTextures;
|
||||
|
||||
TextureUsageFlags usageFlags = TextureUsageFlags.None;
|
||||
@@ -282,7 +282,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
{
|
||||
usageFlags |= TextureUsageFlags.NeedsScaleValue;
|
||||
|
||||
bool canScale = _stage.SupportsRenderScale() && arrayLength == 1 && !write && dimensions == 2;
|
||||
bool canScale = _stage.SupportsRenderScale && arrayLength == 1 && !write && dimensions == 2;
|
||||
|
||||
if (!canScale)
|
||||
{
|
||||
@@ -355,7 +355,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
|
||||
if (arrayLength != 1 && type != SamplerType.None)
|
||||
{
|
||||
prefix += type.ToShortSamplerType();
|
||||
prefix += type.ShortTypeName;
|
||||
}
|
||||
|
||||
if (isImage)
|
||||
@@ -432,9 +432,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
if (found)
|
||||
{
|
||||
selectedMeta.UsageFlags |= TextureUsageFlags.NeedsScaleValue;
|
||||
|
||||
int dimensions = type.GetDimensions();
|
||||
bool canScale = _stage.SupportsRenderScale() && selectedInfo.ArrayLength == 1 && dimensions == 2;
|
||||
|
||||
int dimensions = type.Dimensions;
|
||||
bool canScale = _stage.SupportsRenderScale && selectedInfo.ArrayLength == 1 && dimensions == 2;
|
||||
|
||||
if (!canScale)
|
||||
{
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
GpPassthrough = gpPassthrough;
|
||||
ThreadsPerInputPrimitive = threadsPerInputPrimitive;
|
||||
OutputTopology = outputTopology;
|
||||
MaxOutputVertices = gpPassthrough ? graphicsState.Topology.ToInputVerticesNoAdjacency() : maxOutputVertices;
|
||||
MaxOutputVertices = gpPassthrough ? graphicsState.Topology.InputVertexCountNoAdjacency : maxOutputVertices;
|
||||
ImapTypes = imapTypes;
|
||||
OmapTargets = omapTargets;
|
||||
OmapSampleMask = omapSampleMask;
|
||||
@@ -293,7 +293,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
|
||||
public AggregateType GetFragmentOutputColorType(int location)
|
||||
{
|
||||
return AggregateType.Vector4 | _graphicsState.FragmentOutputTypes[location].ToAggregateType();
|
||||
return AggregateType.Vector4 | _graphicsState.FragmentOutputTypes[location].Aggregate;
|
||||
}
|
||||
|
||||
public AggregateType GetUserDefinedType(int location, bool isOutput)
|
||||
@@ -307,7 +307,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
|
||||
if (Stage == ShaderStage.Vertex && !isOutput)
|
||||
{
|
||||
type |= _graphicsState.AttributeTypes[location].ToAggregateType(SupportsScaledVertexFormats);
|
||||
type |= _graphicsState.AttributeTypes[location].AsAggregate(SupportsScaledVertexFormats);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
||||
(intCoords || isImage) &&
|
||||
!isBindless &&
|
||||
!isIndexed &&
|
||||
stage.SupportsRenderScale() &&
|
||||
stage.SupportsRenderScale &&
|
||||
TypeSupportsScale(texOp.Type))
|
||||
{
|
||||
int functionId = hfm.GetOrCreateFunctionId(HelperFunctionName.TexelFetchScale);
|
||||
@@ -61,7 +61,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
||||
? resourceManager.GetTextureDescriptors(includeArrays: false).Length + resourceManager.FindImageDescriptorIndex(texOp.Binding)
|
||||
: resourceManager.FindTextureDescriptorIndex(texOp.Binding);
|
||||
|
||||
int coordsCount = texOp.Type.GetDimensions();
|
||||
int coordsCount = texOp.Type.Dimensions;
|
||||
int coordsIndex = isBindless ? 1 : 0;
|
||||
|
||||
for (int index = 0; index < coordsCount; index++)
|
||||
@@ -103,7 +103,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
||||
texOp.Index < 2 &&
|
||||
!isBindless &&
|
||||
!isIndexed &&
|
||||
stage.SupportsRenderScale() &&
|
||||
stage.SupportsRenderScale &&
|
||||
TypeSupportsScale(texOp.Type))
|
||||
{
|
||||
int functionId = hfm.GetOrCreateFunctionId(HelperFunctionName.TextureSizeUnscale);
|
||||
@@ -168,7 +168,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
||||
return node;
|
||||
}
|
||||
|
||||
int coordsCount = texOp.Type.GetDimensions();
|
||||
int coordsCount = texOp.Type.Dimensions;
|
||||
|
||||
int normCoordsCount = (texOp.Type & SamplerType.Mask) == SamplerType.TextureCube ? 2 : coordsCount;
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
||||
|
||||
bool isIndexed = resourceManager.IsArrayOfTexturesOrImages(texOp.Binding, isImage: false);
|
||||
|
||||
int coordsCount = texOp.Type.GetDimensions();
|
||||
int coordsCount = texOp.Type.Dimensions;
|
||||
int coordsIndex = isBindless || isIndexed ? 1 : 0;
|
||||
|
||||
int normCoordsCount = (texOp.Type & SamplerType.Mask) == SamplerType.TextureCube ? 2 : coordsCount;
|
||||
@@ -315,7 +315,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
||||
bool isMultisample = (texOp.Type & SamplerType.Multisample) != 0;
|
||||
bool isShadow = (texOp.Type & SamplerType.Shadow) != 0;
|
||||
|
||||
int coordsCount = texOp.Type.GetDimensions();
|
||||
int coordsCount = texOp.Type.Dimensions;
|
||||
|
||||
int offsetsCount;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user