diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-10-23 17:59:52 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-23 17:59:52 -0300 |
| commit | 9ace6b9285c60c70aba153110bef3eb5372badb7 (patch) | |
| tree | a82257c23c20189896b59bc4e590b7f3f041c469 /Ryujinx.Graphics/Gal/Shader | |
| parent | 044b84b078c910c9c1d16c5351cd037716db70e3 (diff) | |
Fix for render target and a shader compilation issue (#471)
* Fix render target using possibly deleted or wrong handles
* Fix basic blocks with only a KIL instruction on the shader translator
* Formatting fix
Diffstat (limited to 'Ryujinx.Graphics/Gal/Shader')
| -rw-r--r-- | Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs | 98 | ||||
| -rw-r--r-- | Ryujinx.Graphics/Gal/Shader/ShaderDecodeAlu.cs | 2 |
2 files changed, 56 insertions, 44 deletions
diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs index d0f9223b..5b62ac3a 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs @@ -252,10 +252,9 @@ namespace Ryujinx.Graphics.Gal.Shader SB.AppendLine(IdentationStr + "int " + GlslDecl.InstanceUniformName + ";"); SB.AppendLine("};"); + SB.AppendLine(); } - SB.AppendLine(); - foreach (ShaderDeclInfo DeclInfo in Decl.Uniforms.Values.OrderBy(DeclKeySelector)) { SB.AppendLine($"layout (std140) uniform {DeclInfo.Name} {{"); @@ -312,17 +311,27 @@ namespace Ryujinx.Graphics.Gal.Shader { if (Decl.ShaderType == GalShaderType.Fragment) { + int Count = 0; + for (int Attachment = 0; Attachment < 8; Attachment++) { if (Header.OmapTargets[Attachment].Enabled) { SB.AppendLine("layout (location = " + Attachment + ") out vec4 " + GlslDecl.FragmentOutputName + Attachment + ";"); + + Count++; } } + + if (Count > 0) + { + SB.AppendLine(); + } } else { SB.AppendLine("layout (location = " + GlslDecl.PositionOutAttrLocation + ") out vec4 " + GlslDecl.PositionOutAttrName + ";"); + SB.AppendLine(); } PrintDeclAttributes(Decl.OutAttributes.Values, "out"); @@ -558,6 +567,49 @@ namespace Ryujinx.Graphics.Gal.Shader } } + private void PrintNodes(ShaderIrBlock Block, ShaderIrNode[] Nodes) + { + foreach (ShaderIrNode Node in Nodes) + { + PrintNode(Block, Node, IdentationStr); + } + + if (Nodes.Length == 0) + { + SB.AppendLine(IdentationStr + "return 0u;"); + + return; + } + + ShaderIrNode Last = Nodes[Nodes.Length - 1]; + + bool UnconditionalFlowChange = false; + + if (Last is ShaderIrOp Op) + { + switch (Op.Inst) + { + case ShaderIrInst.Bra: + case ShaderIrInst.Exit: + case ShaderIrInst.Sync: + UnconditionalFlowChange = true; + break; + } + } + + if (!UnconditionalFlowChange) + { + if (Block.Next != null) + { + SB.AppendLine(IdentationStr + "return " + GetBlockPosition(Block.Next) + ";"); + } + else + { + SB.AppendLine(IdentationStr + "return 0u;"); + } + } + } + private void PrintNode(ShaderIrBlock Block, ShaderIrNode Node, string Identation) { if (Node is ShaderIrCond Cond) @@ -571,14 +623,7 @@ namespace Ryujinx.Graphics.Gal.Shader SB.AppendLine(Identation + "if (" + IfExpr + ") {"); - if (Cond.Child is ShaderIrOp Op && Op.Inst == ShaderIrInst.Bra) - { - SB.AppendLine(Identation + IdentationStr + "return " + GetBlockPosition(Block.Branch) + ";"); - } - else - { - PrintNode(Block, Cond.Child, Identation + IdentationStr); - } + PrintNode(Block, Cond.Child, Identation + IdentationStr); SB.AppendLine(Identation + "}"); } @@ -655,39 +700,6 @@ namespace Ryujinx.Graphics.Gal.Shader } } - private void PrintNodes(ShaderIrBlock Block, ShaderIrNode[] Nodes) - { - foreach (ShaderIrNode Node in Nodes) - { - PrintNode(Block, Node, IdentationStr); - } - - if (Nodes.Length > 0) - { - ShaderIrNode Last = Nodes[Nodes.Length - 1]; - - bool UnconditionalFlowChange = false; - - if (Last is ShaderIrOp Op) - { - switch (Op.Inst) - { - case ShaderIrInst.Bra: - case ShaderIrInst.Exit: - case ShaderIrInst.Kil: - case ShaderIrInst.Sync: - UnconditionalFlowChange = true; - break; - } - } - - if (!UnconditionalFlowChange) - { - SB.AppendLine(IdentationStr + "return " + GetBlockPosition(Block.Next) + ";"); - } - } - } - private bool IsValidOutOper(ShaderIrNode Node) { if (Node is ShaderIrOperGpr Gpr && Gpr.IsConst) diff --git a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeAlu.cs b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeAlu.cs index d4a76bc9..6957e30b 100644 --- a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeAlu.cs +++ b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeAlu.cs @@ -730,7 +730,7 @@ namespace Ryujinx.Graphics.Gal.Shader } ShaderIrNode Src1 = GetAluIneg(ApplyHeight(OpCode.Gpr8(), Height1), Neg1); - ShaderIrNode Src2 = GetAluIneg(ApplyHeight(OperB, Height2), Neg2); + ShaderIrNode Src2 = GetAluIneg(ApplyHeight(OperB, Height2), Neg2); ShaderIrNode Src3 = GetAluIneg(ApplyHeight(OpCode.Gpr39(), Height3), Neg3); ShaderIrOp Sum = new ShaderIrOp(ShaderIrInst.Add, Src1, Src2); |
