diff options
author | gdkchan <gab.dark.100@gmail.com> | 2019-12-16 01:59:46 -0300 |
---|---|---|
committer | Thog <thog@protonmail.com> | 2020-01-09 02:13:00 +0100 |
commit | 9d7a142a48a5f804127fcae2265bb6ec5495d178 (patch) | |
tree | 4ba4de906d74404760fcbebe9aeb51460252f500 /Ryujinx.Graphics.Shader/Translation/Translator.cs | |
parent | 2eccc7023ae0d1247378516b14507d422e4915c5 (diff) |
Support texture rectangle targets (non-normalized coords)
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation/Translator.cs')
-rw-r--r-- | Ryujinx.Graphics.Shader/Translation/Translator.cs | 76 |
1 files changed, 15 insertions, 61 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/Translator.cs b/Ryujinx.Graphics.Shader/Translation/Translator.cs index 69e63ae1..af209edf 100644 --- a/Ryujinx.Graphics.Shader/Translation/Translator.cs +++ b/Ryujinx.Graphics.Shader/Translation/Translator.cs @@ -16,14 +16,7 @@ namespace Ryujinx.Graphics.Shader.Translation public static Span<byte> ExtractCode(Span<byte> code, bool compute, out int headerSize) { - if (compute) - { - headerSize = 0; - } - else - { - headerSize = HeaderSize; - } + headerSize = compute ? 0 : HeaderSize; Block[] cfg = Decoder.Decode(code, (ulong)headerSize); @@ -47,56 +40,21 @@ namespace Ryujinx.Graphics.Shader.Translation return code.Slice(0, headerSize + (int)endAddress); } - public static ShaderProgram Translate(Span<byte> code, ShaderCapabilities capabilities, TranslationFlags flags) + public static ShaderProgram Translate(Span<byte> code, QueryInfoCallback queryInfoCallback, TranslationFlags flags) { bool compute = (flags & TranslationFlags.Compute) != 0; - Operation[] ops = DecodeShader(code, capabilities, flags, out ShaderHeader header, out int size); - - ShaderStage stage; - - if (compute) - { - stage = ShaderStage.Compute; - } - else - { - stage = header.Stage; - } - - int maxOutputVertexCount = 0; - - OutputTopology outputTopology = OutputTopology.LineStrip; - - if (!compute) - { - maxOutputVertexCount = header.MaxOutputVertexCount; - outputTopology = header.OutputTopology; - } - - ShaderConfig config = new ShaderConfig( - stage, - capabilities, - flags, - maxOutputVertexCount, - outputTopology); + Operation[] ops = DecodeShader(code, queryInfoCallback, flags, out ShaderConfig config, out int size); return Translate(ops, config, size); } - public static ShaderProgram Translate(Span<byte> vpACode, Span<byte> vpBCode, ShaderCapabilities capabilities, TranslationFlags flags) + public static ShaderProgram Translate(Span<byte> vpACode, Span<byte> vpBCode, QueryInfoCallback queryInfoCallback, TranslationFlags flags) { bool debugMode = (flags & TranslationFlags.DebugMode) != 0; - Operation[] vpAOps = DecodeShader(vpACode, capabilities, flags, out _, out _); - Operation[] vpBOps = DecodeShader(vpBCode, capabilities, flags, out ShaderHeader header, out int sizeB); - - ShaderConfig config = new ShaderConfig( - header.Stage, - capabilities, - flags, - header.MaxOutputVertexCount, - header.OutputTopology); + Operation[] vpAOps = DecodeShader(vpACode, queryInfoCallback, flags, out _, out _); + Operation[] vpBOps = DecodeShader(vpBCode, queryInfoCallback, flags, out ShaderConfig config, out int sizeB); return Translate(Combine(vpAOps, vpBOps), config, sizeB); } @@ -136,31 +94,25 @@ namespace Ryujinx.Graphics.Shader.Translation } private static Operation[] DecodeShader( - Span<byte> code, - ShaderCapabilities capabilities, - TranslationFlags flags, - out ShaderHeader header, - out int size) + Span<byte> code, + QueryInfoCallback queryInfoCallback, + TranslationFlags flags, + out ShaderConfig config, + out int size) { Block[] cfg; - EmitterContext context; - if ((flags & TranslationFlags.Compute) != 0) { - header = null; + config = new ShaderConfig(flags, queryInfoCallback); cfg = Decoder.Decode(code, 0); - - context = new EmitterContext(ShaderStage.Compute, header, capabilities, flags); } else { - header = new ShaderHeader(code); + config = new ShaderConfig(new ShaderHeader(code), flags, queryInfoCallback); cfg = Decoder.Decode(code, HeaderSize); - - context = new EmitterContext(header.Stage, header, capabilities, flags); } if (cfg == null) @@ -172,6 +124,8 @@ namespace Ryujinx.Graphics.Shader.Translation return new Operation[0]; } + EmitterContext context = new EmitterContext(config); + ulong maxEndAddress = 0; for (int blkIndex = 0; blkIndex < cfg.Length; blkIndex++) |