aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-01-29 00:38:51 -0300
committerGitHub <noreply@github.com>2021-01-29 14:38:51 +1100
commitf93089a64f9586863e8a261af932d125e78230df (patch)
tree9899a0075441cbaa620d2dbf7609909c2d8b0bde /Ryujinx.Graphics.Shader/CodeGen
parent9c2f851d3946a2b789e8c00432c60c8d690299a7 (diff)
Implement geometry shader passthrough (#1961)
* Implement geometry shader passthrough * Cache version change
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs52
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/GlslGenerator.cs3
2 files changed, 38 insertions, 17 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
index a6109a95..dd3c8196 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
@@ -26,6 +26,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
context.AppendLine("#extension GL_ARB_compute_shader : enable");
}
+ if (context.Config.GpPassthrough)
+ {
+ context.AppendLine("#extension GL_NV_geometry_shader_passthrough : enable");
+ }
+
context.AppendLine("#pragma optionNV(fastmath off)");
context.AppendLine();
@@ -33,20 +38,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
context.AppendLine($"const int {DefaultNames.UndefinedName} = 0;");
context.AppendLine();
- if (context.Config.Stage == ShaderStage.Geometry)
- {
- string inPrimitive = context.Config.GpuAccessor.QueryPrimitiveTopology().ToGlslString();
-
- context.AppendLine($"layout ({inPrimitive}) in;");
-
- string outPrimitive = context.Config.OutputTopology.ToGlslString();
-
- int maxOutputVertices = context.Config.MaxOutputVertices;
-
- context.AppendLine($"layout ({outPrimitive}, max_vertices = {maxOutputVertices}) out;");
- context.AppendLine();
- }
-
if (context.Config.Stage == ShaderStage.Compute)
{
int localMemorySize = BitUtils.DivRoundUp(context.Config.GpuAccessor.QueryComputeLocalMemorySize(), 4);
@@ -109,6 +100,33 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
if (context.Config.Stage != ShaderStage.Compute)
{
+ if (context.Config.Stage == ShaderStage.Geometry)
+ {
+ string inPrimitive = context.Config.GpuAccessor.QueryPrimitiveTopology().ToGlslString();
+
+ context.AppendLine($"layout ({inPrimitive}) in;");
+
+ if (context.Config.GpPassthrough)
+ {
+ context.AppendLine($"layout (passthrough) in gl_PerVertex");
+ context.EnterScope();
+ context.AppendLine("vec4 gl_Position;");
+ context.AppendLine("float gl_PointSize;");
+ context.AppendLine("float gl_ClipDistance[];");
+ context.LeaveScope(";");
+ }
+ else
+ {
+ string outPrimitive = context.Config.OutputTopology.ToGlslString();
+
+ int maxOutputVertices = context.Config.MaxOutputVertices;
+
+ context.AppendLine($"layout ({outPrimitive}, max_vertices = {maxOutputVertices}) out;");
+ }
+
+ context.AppendLine();
+ }
+
if (info.IAttributes.Count != 0)
{
DeclareInputAttributes(context, info);
@@ -432,6 +450,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
};
}
+ string pass = context.Config.GpPassthrough ? "passthrough, " : string.Empty;
+
string name = $"{DefaultNames.IAttributePrefix}{attr}";
if ((context.Config.Flags & TranslationFlags.Feedback) != 0)
@@ -440,12 +460,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
{
char swzMask = "xyzw"[c];
- context.AppendLine($"layout (location = {attr}, component = {c}) {iq}in float {name}_{swzMask}{suffix};");
+ context.AppendLine($"layout ({pass}location = {attr}, component = {c}) {iq}in float {name}_{swzMask}{suffix};");
}
}
else
{
- context.AppendLine($"layout (location = {attr}) {iq}in vec4 {name}{suffix};");
+ context.AppendLine($"layout ({pass}location = {attr}) {iq}in vec4 {name}{suffix};");
}
}
}
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/GlslGenerator.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/GlslGenerator.cs
index 276544fc..37a1cd89 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/GlslGenerator.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/GlslGenerator.cs
@@ -69,7 +69,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
// compiler may eliminate them.
// (Not needed for fragment shader as it is the last stage).
if (context.Config.Stage != ShaderStage.Compute &&
- context.Config.Stage != ShaderStage.Fragment)
+ context.Config.Stage != ShaderStage.Fragment &&
+ !context.Config.GpPassthrough)
{
for (int attr = 0; attr < Declarations.MaxAttributes; attr++)
{