aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2023-04-25 19:51:07 -0300
committerGitHub <noreply@github.com>2023-04-25 19:51:07 -0300
commit9f12e50a546b15533778ed0d8290202af91c10a2 (patch)
treef0e77a7b7c605face5ef29270b4248af2682301a /Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs
parent097562bc6c227c42f803ce1078fcb4adf06cd20c (diff)
Refactor attribute handling on the shader generator (#4565)1.1.733
* Refactor attribute handling on the shader generator * Implement gl_ViewportMask[] * Add back the Intel FrontFacing bug workaround * Fix GLSL transform feedback outputs mistmatch with fragment stage * Shader cache version bump * Fix geometry shader recognition * PR feedback * Delete GetOperandDef and GetOperandUse * Remove replacements that are no longer needed on GLSL compilation on Vulkan * Fix incorrect load for per-patch outputs * Fix build
Diffstat (limited to 'Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs')
-rw-r--r--Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs67
1 files changed, 8 insertions, 59 deletions
diff --git a/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs b/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs
index ce57a578..68bbdeb1 100644
--- a/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs
+++ b/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs
@@ -37,43 +37,26 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Config = config;
- if (config.Stage == ShaderStage.TessellationControl)
- {
- // Required to index outputs.
- Info.Inputs.Add(AttributeConsts.InvocationId);
- }
- else if (config.GpPassthrough)
+ if (config.GpPassthrough)
{
int passthroughAttributes = config.PassthroughAttributes;
while (passthroughAttributes != 0)
{
int index = BitOperations.TrailingZeroCount(passthroughAttributes);
- int attrBase = AttributeConsts.UserAttributeBase + index * 16;
- Info.Inputs.Add(attrBase);
- Info.Inputs.Add(attrBase + 4);
- Info.Inputs.Add(attrBase + 8);
- Info.Inputs.Add(attrBase + 12);
+ Info.IoDefinitions.Add(new IoDefinition(StorageKind.Input, IoVariable.UserDefined, index));
passthroughAttributes &= ~(1 << index);
}
- Info.Inputs.Add(AttributeConsts.PositionX);
- Info.Inputs.Add(AttributeConsts.PositionY);
- Info.Inputs.Add(AttributeConsts.PositionZ);
- Info.Inputs.Add(AttributeConsts.PositionW);
- Info.Inputs.Add(AttributeConsts.PointSize);
-
- for (int i = 0; i < 8; i++)
- {
- Info.Inputs.Add(AttributeConsts.ClipDistance0 + i * 4);
- }
+ Info.IoDefinitions.Add(new IoDefinition(StorageKind.Input, IoVariable.Position));
+ Info.IoDefinitions.Add(new IoDefinition(StorageKind.Input, IoVariable.PointSize));
+ Info.IoDefinitions.Add(new IoDefinition(StorageKind.Input, IoVariable.ClipDistance));
}
else if (config.Stage == ShaderStage.Fragment)
{
// Potentially used for texture coordinate scaling.
- Info.Inputs.Add(AttributeConsts.PositionX);
- Info.Inputs.Add(AttributeConsts.PositionY);
+ Info.IoDefinitions.Add(new IoDefinition(StorageKind.Input, IoVariable.FragmentCoord));
}
}
@@ -281,7 +264,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
else
{
- cond = GetOperandUse(branchOp.GetSource(0));
+ cond = GetOperand(branchOp.GetSource(0));
Instruction invInst = type == AstBlockType.If
? Instruction.BranchIfTrue
@@ -315,41 +298,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return newTemp;
}
- public AstOperand GetOperandDef(Operand operand)
- {
- if (operand.Type == OperandType.Attribute)
- {
- Info.Outputs.Add(operand.Value & AttributeConsts.Mask);
- }
- else if (operand.Type == OperandType.AttributePerPatch)
- {
- Info.OutputsPerPatch.Add(operand.Value & AttributeConsts.Mask);
- }
-
- return GetOperand(operand);
- }
-
- public AstOperand GetOperandUse(Operand operand)
- {
- // If this flag is set, we're reading from an output attribute instead.
- if (operand.Type.IsAttribute() && (operand.Value & AttributeConsts.LoadOutputMask) != 0)
- {
- return GetOperandDef(operand);
- }
-
- if (operand.Type == OperandType.Attribute)
- {
- Info.Inputs.Add(operand.Value);
- }
- else if (operand.Type == OperandType.AttributePerPatch)
- {
- Info.InputsPerPatch.Add(operand.Value);
- }
-
- return GetOperand(operand);
- }
-
- private AstOperand GetOperand(Operand operand)
+ public AstOperand GetOperand(Operand operand)
{
if (operand == null)
{