aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.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/CodeGen/Spirv/SpirvGenerator.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/CodeGen/Spirv/SpirvGenerator.cs')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs31
1 files changed, 11 insertions, 20 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs b/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs
index ca823538..3e11a974 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs
@@ -63,7 +63,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
if (config.Stage == ShaderStage.Fragment)
{
- if (context.Info.Inputs.Contains(AttributeConsts.Layer))
+ if (context.Info.IoDefinitions.Contains(new IoDefinition(StorageKind.Input, IoVariable.Layer)))
{
context.AddCapability(Capability.Geometry);
}
@@ -93,13 +93,19 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
context.AddCapability(Capability.DrawParameters);
}
- Declarations.DeclareAll(context, info);
+ if (context.Info.IoDefinitions.Contains(new IoDefinition(StorageKind.Output, IoVariable.ViewportMask)))
+ {
+ context.AddExtension("SPV_NV_viewport_array2");
+ context.AddCapability(Capability.ShaderViewportMaskNV);
+ }
if ((info.HelperFunctionsMask & NeedsInvocationIdMask) != 0)
{
- Declarations.DeclareInvocationId(context);
+ info.IoDefinitions.Add(new IoDefinition(StorageKind.Input, IoVariable.SubgroupLaneId));
}
+ Declarations.DeclareAll(context, info);
+
for (int funcIndex = 0; funcIndex < info.Functions.Count; funcIndex++)
{
var function = info.Functions[funcIndex];
@@ -203,7 +209,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
if (context.Config.Options.TargetApi == TargetApi.Vulkan)
{
- // We invert the front face on Vulkan backend, so we need to do that here aswell.
+ // We invert the front face on Vulkan backend, so we need to do that here as well.
tessCw = !tessCw;
}
@@ -250,7 +256,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
? ExecutionMode.OriginUpperLeft
: ExecutionMode.OriginLowerLeft);
- if (context.Outputs.ContainsKey(AttributeConsts.FragmentOutputDepth))
+ if (context.Info.IoDefinitions.Contains(new IoDefinition(StorageKind.Output, IoVariable.FragmentOutputDepth)))
{
context.AddExecutionMode(spvFunc, ExecutionMode.DepthReplacing);
}
@@ -389,21 +395,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
var source = context.Get(dest.VarType, assignment.Source);
context.Store(context.GetLocalPointer(dest), source);
}
- else if (dest.Type == OperandType.Attribute || dest.Type == OperandType.AttributePerPatch)
- {
- bool perPatch = dest.Type == OperandType.AttributePerPatch;
-
- if (AttributeInfo.Validate(context.Config, dest.Value, isOutAttr: true, perPatch))
- {
- AggregateType elemType;
-
- var elemPointer = perPatch
- ? context.GetAttributePerPatchElemPointer(dest.Value, true, out elemType)
- : context.GetAttributeElemPointer(dest.Value, true, null, out elemType);
-
- context.Store(elemPointer, context.Get(elemType, assignment.Source));
- }
- }
else if (dest.Type == OperandType.Argument)
{
var source = context.Get(dest.VarType, assignment.Source);