From 79e007036383b11cd53c2563fbb7f139a02c90ec Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 22 May 2018 22:43:31 -0300 Subject: Improve shader sending method to GAL, use a memory interface instead of reading a fixed array size and sending every time --- Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs | 4 ++-- Ryujinx.Graphics/Gal/Shader/ShaderDecodeFlow.cs | 2 +- Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs | 22 +++++++++++----------- Ryujinx.Graphics/Gal/Shader/ShaderIrBlock.cs | 10 +++++----- 4 files changed, 19 insertions(+), 19 deletions(-) (limited to 'Ryujinx.Graphics/Gal/Shader') diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs index d6f171f4..88e46243 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs @@ -89,9 +89,9 @@ namespace Ryujinx.Graphics.Gal.Shader }; } - public GlslProgram Decompile(int[] Code, GalShaderType ShaderType) + public GlslProgram Decompile(IGalMemory Memory, long Position, GalShaderType ShaderType) { - ShaderIrBlock Block = ShaderDecoder.DecodeBasicBlock(Code, 0); + ShaderIrBlock Block = ShaderDecoder.DecodeBasicBlock(Memory, Position); ShaderIrNode[] Nodes = Block.GetNodes(); diff --git a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeFlow.cs b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeFlow.cs index b5f3e0b7..6f48d1a8 100644 --- a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeFlow.cs +++ b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeFlow.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Gal.Shader throw new NotImplementedException(); } - int Target = ((int)(OpCode >> 20) << 8) >> 8; + long Target = ((int)(OpCode >> 20) << 8) >> 8; Target += Block.Position + 8; diff --git a/Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs b/Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs index 4958dfcf..024fa364 100644 --- a/Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs +++ b/Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs @@ -4,28 +4,28 @@ namespace Ryujinx.Graphics.Gal.Shader { private const bool AddDbgComments = true; - public static ShaderIrBlock DecodeBasicBlock(int[] Code, int Offset) + public static ShaderIrBlock DecodeBasicBlock(IGalMemory Memory, long Position) { ShaderIrBlock Block = new ShaderIrBlock(); - while (Offset + 2 <= Code.Length) + while (true) { - int InstPos = Offset * 4; + Block.Position = Position; - Block.Position = InstPos; - - Block.MarkLabel(InstPos); + Block.MarkLabel(Position); //Ignore scheduling instructions, which are written every 32 bytes. - if ((Offset & 7) == 0) + if ((Position & 0x1f) == 0) { - Offset += 2; + Position += 8; continue; } - uint Word0 = (uint)Code[Offset++]; - uint Word1 = (uint)Code[Offset++]; + uint Word0 = (uint)Memory.ReadInt32(Position + 0); + uint Word1 = (uint)Memory.ReadInt32(Position + 4); + + Position += 8; long OpCode = Word0 | (long)Word1 << 32; @@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Gal.Shader if (AddDbgComments) { - string DbgOpCode = $"0x{InstPos:x8}: 0x{OpCode:x16} "; + string DbgOpCode = $"0x{Position:x16}: 0x{OpCode:x16} "; Block.AddNode(new ShaderIrCmnt(DbgOpCode + (Decode?.Method.Name ?? "???"))); } diff --git a/Ryujinx.Graphics/Gal/Shader/ShaderIrBlock.cs b/Ryujinx.Graphics/Gal/Shader/ShaderIrBlock.cs index 5f365d8c..31d72169 100644 --- a/Ryujinx.Graphics/Gal/Shader/ShaderIrBlock.cs +++ b/Ryujinx.Graphics/Gal/Shader/ShaderIrBlock.cs @@ -6,15 +6,15 @@ namespace Ryujinx.Graphics.Gal.Shader { private List Nodes; - private Dictionary LabelsToInsert; + private Dictionary LabelsToInsert; - public int Position; + public long Position; public ShaderIrBlock() { Nodes = new List(); - LabelsToInsert = new Dictionary(); + LabelsToInsert = new Dictionary(); } public void AddNode(ShaderIrNode Node) @@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gal.Shader Nodes.Add(Node); } - public ShaderIrLabel GetLabel(int Position) + public ShaderIrLabel GetLabel(long Position) { if (LabelsToInsert.TryGetValue(Position, out ShaderIrLabel Label)) { @@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Gal.Shader return Label; } - public void MarkLabel(int Position) + public void MarkLabel(long Position) { if (LabelsToInsert.TryGetValue(Position, out ShaderIrLabel Label)) { -- cgit v1.2.3