aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-04-08 16:17:35 -0300
committergdkchan <gab.dark.100@gmail.com>2018-04-08 16:41:38 -0300
commitb9aa3966c00b4bb3ff0292dc28ed53ad26cf284b (patch)
treecd2ab3d65c61ac6c6ceb312116e5d138868a3e18 /Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs
parent7acd0e01226d64d05b2675f6ae07507039a31835 (diff)
Merge shader branch, adding support for GLSL decompilation, a macro
interpreter, and a rewrite of the GPU code.
Diffstat (limited to 'Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs')
-rw-r--r--Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs b/Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs
new file mode 100644
index 00000000..779bbf92
--- /dev/null
+++ b/Ryujinx.Graphics/Gal/Shader/ShaderDecoder.cs
@@ -0,0 +1,41 @@
+namespace Ryujinx.Graphics.Gal.Shader
+{
+ static class ShaderDecoder
+ {
+ public static ShaderIrBlock DecodeBasicBlock(int[] Code, int Offset, GalShaderType ShaderType)
+ {
+ ShaderIrBlock Block = new ShaderIrBlock();
+
+ while (Offset + 2 <= Code.Length)
+ {
+ uint Word0 = (uint)Code[Offset++];
+ uint Word1 = (uint)Code[Offset++];
+
+ long OpCode = Word0 | (long)Word1 << 32;
+
+ ShaderDecodeFunc Decode = ShaderOpCodeTable.GetDecoder(OpCode);
+
+ if (Decode == null)
+ {
+ continue;
+ }
+
+ Decode(Block, OpCode);
+
+ if (Block.GetLastNode() is ShaderIrOp Op && IsFlowChange(Op.Inst))
+ {
+ break;
+ }
+ }
+
+ Block.RunOptimizationPasses(ShaderType);
+
+ return Block;
+ }
+
+ private static bool IsFlowChange(ShaderIrInst Inst)
+ {
+ return Inst == ShaderIrInst.Exit;
+ }
+ }
+} \ No newline at end of file