aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Translation
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-07-26 00:03:40 -0300
committerGitHub <noreply@github.com>2020-07-26 00:03:40 -0300
commit8dbcae1ff88927dc0734d5f0e24fbf8781d68590 (patch)
treed884544af874f385a7a374c8889683db2e4c1ccc /Ryujinx.Graphics.Shader/Translation
parent2678bf0010166e683364102221b52caebea8747e (diff)
Implement BGRA texture support (#1418)
* Implement BGRA texture support * Missing AppendLine * Remove empty lines * Address PR feedback
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation')
-rw-r--r--Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs3
-rw-r--r--Ryujinx.Graphics.Shader/Translation/EmitterContext.cs38
2 files changed, 34 insertions, 7 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs b/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs
index 8ff37429..c194b5c2 100644
--- a/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs
+++ b/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs
@@ -35,6 +35,9 @@ namespace Ryujinx.Graphics.Shader.Translation
public const int FragmentOutputColorBase = 0x1000010;
public const int FragmentOutputColorEnd = FragmentOutputColorBase + 8 * 16;
+ public const int FragmentOutputIsBgraBase = 0x1000100;
+ public const int FragmentOutputIsBgraEnd = FragmentOutputIsBgraBase + 8 * 4;
+
public const int ThreadIdX = 0x2000000;
public const int ThreadIdY = 0x2000004;
public const int ThreadIdZ = 0x2000008;
diff --git a/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs b/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
index 39532a64..9b26fa4a 100644
--- a/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
+++ b/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
@@ -115,22 +115,46 @@ namespace Ryujinx.Graphics.Shader.Translation
int regIndex = 0;
- for (int attachment = 0; attachment < 8; attachment++)
+ for (int rtIndex = 0; rtIndex < 8; rtIndex++)
{
- OmapTarget target = Config.OmapTargets[attachment];
+ OmapTarget target = Config.OmapTargets[rtIndex];
for (int component = 0; component < 4; component++)
{
- if (target.ComponentEnabled(component))
+ if (!target.ComponentEnabled(component))
{
- Operand dest = Attribute(AttributeConsts.FragmentOutputColorBase + attachment * 16 + component * 4);
+ continue;
+ }
+
+ int fragmentOutputColorAttr = AttributeConsts.FragmentOutputColorBase + rtIndex * 16;
+
+ Operand src = Register(regIndex, RegisterType.Gpr);
+
+ // Perform B <-> R swap if needed, for BGRA formats (not supported on OpenGL).
+ if (component == 0 || component == 2)
+ {
+ Operand isBgra = Attribute(AttributeConsts.FragmentOutputIsBgraBase + rtIndex * 4);
+
+ Operand lblIsBgra = Label();
+ Operand lblEnd = Label();
- Operand src = Register(regIndex, RegisterType.Gpr);
+ this.BranchIfTrue(lblIsBgra, isBgra);
- this.Copy(dest, src);
+ this.Copy(Attribute(fragmentOutputColorAttr + component * 4), src);
+ this.Branch(lblEnd);
- regIndex++;
+ MarkLabel(lblIsBgra);
+
+ this.Copy(Attribute(fragmentOutputColorAttr + (2 - component) * 4), src);
+
+ MarkLabel(lblEnd);
}
+ else
+ {
+ this.Copy(Attribute(fragmentOutputColorAttr + component * 4), src);
+ }
+
+ regIndex++;
}
}
}