diff options
| author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2018-08-23 02:07:23 -0300 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2018-08-23 02:07:23 -0300 |
| commit | 624e813cd3e5d782847c577c2da0cfb8a121fd18 (patch) | |
| tree | fa12638a42a406f1736662f1a2fdee1d9f9bd014 /Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs | |
| parent | 9977acad0fe08ee98a8174ce1c5609be22ba67ee (diff) | |
Implement multiple rendertarget attachments and depth writting (#375)
* Add depth writting
* Implement multiple attachments
* Address feedback
Diffstat (limited to 'Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs')
| -rw-r--r-- | Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs index 72637984..8baf30e0 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs @@ -120,8 +120,8 @@ namespace Ryujinx.Graphics.Gal.Shader Blocks = ShaderDecoder.Decode(Memory, VpAPosition); BlocksB = ShaderDecoder.Decode(Memory, VpBPosition); - GlslDecl DeclVpA = new GlslDecl(Blocks, ShaderType); - GlslDecl DeclVpB = new GlslDecl(BlocksB, ShaderType); + GlslDecl DeclVpA = new GlslDecl(Blocks, ShaderType, Header); + GlslDecl DeclVpB = new GlslDecl(BlocksB, ShaderType, HeaderB); Decl = GlslDecl.Merge(DeclVpA, DeclVpB); @@ -136,7 +136,7 @@ namespace Ryujinx.Graphics.Gal.Shader Blocks = ShaderDecoder.Decode(Memory, Position); BlocksB = null; - Decl = new GlslDecl(Blocks, ShaderType); + Decl = new GlslDecl(Blocks, ShaderType, Header); return Decompile(); } @@ -304,7 +304,17 @@ namespace Ryujinx.Graphics.Gal.Shader private void PrintDeclOutAttributes() { - if (Decl.ShaderType != GalShaderType.Fragment) + if (Decl.ShaderType == GalShaderType.Fragment) + { + for (int Attachment = 0; Attachment < 8; Attachment++) + { + if (Header.OmapTargets[Attachment].Enabled) + { + SB.AppendLine("layout (location = " + Attachment + ") out vec4 " + GlslDecl.FragmentOutputName + Attachment + ";"); + } + } + } + else { SB.AppendLine("layout (location = " + GlslDecl.PositionOutAttrLocation + ") out vec4 " + GlslDecl.PositionOutAttrName + ";"); } @@ -432,6 +442,33 @@ namespace Ryujinx.Graphics.Gal.Shader PrintAttrToOutput(); } + if (Decl.ShaderType == GalShaderType.Fragment) + { + if (Header.OmapDepth) + { + SB.AppendLine(IdentationStr + "gl_FragDepth = " + GlslDecl.GetGprName(Header.DepthRegister) + ";"); + } + + int GprIndex = 0; + + for (int Attachment = 0; Attachment < 8; Attachment++) + { + string Output = GlslDecl.FragmentOutputName + Attachment; + + OmapTarget Target = Header.OmapTargets[Attachment]; + + for (int Component = 0; Component < 4; Component++) + { + if (Target.ComponentEnabled(Component)) + { + SB.AppendLine(IdentationStr + Output + "[" + Component + "] = " + GlslDecl.GetGprName(GprIndex) + ";"); + + GprIndex++; + } + } + } + } + SB.AppendLine("}"); } |
