diff options
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation')
| -rw-r--r-- | Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs | 3 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/Translation/EmitterContext.cs | 38 |
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++; } } } |
