aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs42
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs2
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs2
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs2
4 files changed, 31 insertions, 17 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
index 9032ca59..5e53d62a 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
@@ -569,7 +569,23 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
if (context.Config.TransformFeedbackEnabled && context.Config.Stage == ShaderStage.Fragment)
{
- for (int c = 0; c < 4; c++)
+ int attrOffset = AttributeConsts.UserAttributeBase + attr * 16;
+ int components = context.Info.GetTransformFeedbackOutputComponents(attrOffset);
+
+ if (components > 1)
+ {
+ string type = components switch
+ {
+ 2 => "vec2",
+ 3 => "vec3",
+ 4 => "vec4",
+ _ => "float"
+ };
+
+ context.AppendLine($"layout (location = {attr}) in {type} {name};");
+ }
+
+ for (int c = components > 1 ? components : 0; c < 4; c++)
{
char swzMask = "xyzw"[c];
@@ -642,7 +658,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
if (context.Config.TransformFeedbackEnabled && context.Config.LastInVertexPipeline)
{
int attrOffset = AttributeConsts.UserAttributeBase + attr * 16;
- int components = context.Config.LastInPipeline ? context.Info.GetTransformFeedbackOutputComponents(attrOffset) : 1;
+ int components = context.Info.GetTransformFeedbackOutputComponents(attrOffset);
if (components > 1)
{
@@ -664,22 +680,20 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
context.AppendLine($"layout (location = {attr}{xfb}) out {type} {name};");
}
- else
- {
- for (int c = 0; c < 4; c++)
- {
- char swzMask = "xyzw"[c];
- string xfb = string.Empty;
+ for (int c = components > 1 ? components : 0; c < 4; c++)
+ {
+ char swzMask = "xyzw"[c];
- var tfOutput = context.Info.GetTransformFeedbackOutput(attrOffset + c * 4);
- if (tfOutput.Valid)
- {
- xfb = $", xfb_buffer = {tfOutput.Buffer}, xfb_offset = {tfOutput.Offset}, xfb_stride = {tfOutput.Stride}";
- }
+ string xfb = string.Empty;
- context.AppendLine($"layout (location = {attr}, component = {c}{xfb}) out float {name}_{swzMask};");
+ var tfOutput = context.Info.GetTransformFeedbackOutput(attrOffset + c * 4);
+ if (tfOutput.Valid)
+ {
+ xfb = $", xfb_buffer = {tfOutput.Buffer}, xfb_offset = {tfOutput.Offset}, xfb_stride = {tfOutput.Stride}";
}
+
+ context.AppendLine($"layout (location = {attr}, component = {c}{xfb}) out float {name}_{swzMask};");
}
}
else
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs
index ce1ab50e..ec761fa6 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs
@@ -220,7 +220,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
((config.LastInVertexPipeline && isOutAttr) ||
(config.Stage == ShaderStage.Fragment && !isOutAttr)))
{
- int components = config.LastInPipeline ? context.Info.GetTransformFeedbackOutputComponents(attrOffset) : 1;
+ int components = context.Info.GetTransformFeedbackOutputComponents(attrOffset);
string name = components > 1 ? $"{prefix}{(value >> 4)}" : $"{prefix}{(value >> 4)}_{swzMask}";
if (AttributeInfo.IsArrayAttributeGlsl(config.Stage, isOutAttr))
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs b/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs
index 41afdf18..e693307d 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs
@@ -341,7 +341,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
attrOffset = attr;
type = elemType;
- if (Config.LastInPipeline && isOutAttr)
+ if (isOutAttr)
{
int components = Info.GetTransformFeedbackOutputComponents(attr);
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs
index df42a13c..fdca5e89 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs
@@ -673,7 +673,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
int components = 1;
var type = attrInfo.Type & AggregateType.ElementTypeMask;
- if (context.Config.LastInPipeline && isOutAttr)
+ if (isOutAttr)
{
components = context.Info.GetTransformFeedbackOutputComponents(attr);