aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Translation/Rewriter.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/Translation/Rewriter.cs
parent097562bc6c227c42f803ce1078fcb4adf06cd20c (diff)
Refactor attribute handling on the shader generator (#4565)
* 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/Translation/Rewriter.cs')
-rw-r--r--Ryujinx.Graphics.Shader/Translation/Rewriter.cs23
1 files changed, 14 insertions, 9 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/Rewriter.cs b/Ryujinx.Graphics.Shader/Translation/Rewriter.cs
index 3ec4e49a..91e7ace1 100644
--- a/Ryujinx.Graphics.Shader/Translation/Rewriter.cs
+++ b/Ryujinx.Graphics.Shader/Translation/Rewriter.cs
@@ -34,7 +34,7 @@ namespace Ryujinx.Graphics.Shader.Translation
{
if (hasConstantBufferDrawParameters)
{
- if (ReplaceConstantBufferWithDrawParameters(operation))
+ if (ReplaceConstantBufferWithDrawParameters(node, operation))
{
config.SetUsedFeature(FeatureFlags.DrawParameters);
}
@@ -61,7 +61,7 @@ namespace Ryujinx.Graphics.Shader.Translation
nextNode = node.Next;
}
- else if (UsesGlobalMemory(operation.Inst))
+ else if (UsesGlobalMemory(operation.Inst, operation.StorageKind))
{
nextNode = RewriteGlobalAccess(node, config)?.Next ?? nextNode;
}
@@ -169,9 +169,7 @@ namespace Ryujinx.Graphics.Shader.Translation
if (isAtomic)
{
- Instruction inst = (operation.Inst & ~Instruction.MrMask) | Instruction.MrStorage;
-
- storageOp = new Operation(inst, operation.Dest, sources);
+ storageOp = new Operation(operation.Inst, StorageKind.StorageBuffer, operation.Dest, sources);
}
else if (operation.Inst == Instruction.LoadGlobal)
{
@@ -708,8 +706,15 @@ namespace Ryujinx.Graphics.Shader.Translation
return node;
}
- private static bool ReplaceConstantBufferWithDrawParameters(Operation operation)
+ private static bool ReplaceConstantBufferWithDrawParameters(LinkedListNode<INode> node, Operation operation)
{
+ Operand GenerateLoad(IoVariable ioVariable)
+ {
+ Operand value = Local();
+ node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.Input, value, Const((int)ioVariable)));
+ return value;
+ }
+
bool modified = false;
for (int srcIndex = 0; srcIndex < operation.SourcesCount; srcIndex++)
@@ -721,15 +726,15 @@ namespace Ryujinx.Graphics.Shader.Translation
switch (src.GetCbufOffset())
{
case Constants.NvnBaseVertexByteOffset / 4:
- operation.SetSource(srcIndex, Attribute(AttributeConsts.BaseVertex));
+ operation.SetSource(srcIndex, GenerateLoad(IoVariable.BaseVertex));
modified = true;
break;
case Constants.NvnBaseInstanceByteOffset / 4:
- operation.SetSource(srcIndex, Attribute(AttributeConsts.BaseInstance));
+ operation.SetSource(srcIndex, GenerateLoad(IoVariable.BaseInstance));
modified = true;
break;
case Constants.NvnDrawIndexByteOffset / 4:
- operation.SetSource(srcIndex, Attribute(AttributeConsts.DrawIndex));
+ operation.SetSource(srcIndex, GenerateLoad(IoVariable.DrawIndex));
modified = true;
break;
}