aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Shader/IntermediateRepresentation
diff options
context:
space:
mode:
authorgdk <gab.dark.100@gmail.com>2019-10-13 03:02:07 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commit1876b346fea647e8284a66bb6d62c38801035cff (patch)
tree6eeff094298cda84d1613dc5ec0691e51d7b35f1 /Ryujinx.Graphics/Shader/IntermediateRepresentation
parentf617fb542a0e3d36012d77a4b5acbde7b08902f2 (diff)
Initial work
Diffstat (limited to 'Ryujinx.Graphics/Shader/IntermediateRepresentation')
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/BasicBlock.cs61
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/INode.cs13
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/Instruction.cs87
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/IrConsts.cs8
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/Operand.cs79
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/OperandHelper.cs62
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/OperandType.cs15
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/Operation.cs101
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/PhiNode.cs94
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureFlags.cs17
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureOperation.cs24
-rw-r--r--Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureType.cs35
12 files changed, 0 insertions, 596 deletions
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/BasicBlock.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/BasicBlock.cs
deleted file mode 100644
index 94975337..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/BasicBlock.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using System.Collections.Generic;
-
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- class BasicBlock
- {
- public int Index { get; set; }
-
- public LinkedList<INode> Operations { get; }
-
- private BasicBlock _next;
- private BasicBlock _branch;
-
- public BasicBlock Next
- {
- get => _next;
- set => _next = AddSuccessor(_next, value);
- }
-
- public BasicBlock Branch
- {
- get => _branch;
- set => _branch = AddSuccessor(_branch, value);
- }
-
- public bool HasBranch => _branch != null;
-
- public List<BasicBlock> Predecessors { get; }
-
- public HashSet<BasicBlock> DominanceFrontiers { get; }
-
- public BasicBlock ImmediateDominator { get; set; }
-
- public BasicBlock()
- {
- Operations = new LinkedList<INode>();
-
- Predecessors = new List<BasicBlock>();
-
- DominanceFrontiers = new HashSet<BasicBlock>();
- }
-
- public BasicBlock(int index) : this()
- {
- Index = index;
- }
-
- private BasicBlock AddSuccessor(BasicBlock oldBlock, BasicBlock newBlock)
- {
- oldBlock?.Predecessors.Remove(this);
- newBlock?.Predecessors.Add(this);
-
- return newBlock;
- }
-
- public INode GetLastOp()
- {
- return Operations.Last?.Value;
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/INode.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/INode.cs
deleted file mode 100644
index 48dda24b..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/INode.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- interface INode
- {
- Operand Dest { get; set; }
-
- int SourcesCount { get; }
-
- Operand GetSource(int index);
-
- void SetSource(int index, Operand operand);
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/Instruction.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/Instruction.cs
deleted file mode 100644
index ac0ebc2b..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/Instruction.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using System;
-
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- [Flags]
- enum Instruction
- {
- Absolute = 1,
- Add,
- BitfieldExtractS32,
- BitfieldExtractU32,
- BitfieldInsert,
- BitfieldReverse,
- BitwiseAnd,
- BitwiseExclusiveOr,
- BitwiseNot,
- BitwiseOr,
- Branch,
- BranchIfFalse,
- BranchIfTrue,
- Ceiling,
- Clamp,
- ClampU32,
- CompareEqual,
- CompareGreater,
- CompareGreaterOrEqual,
- CompareGreaterOrEqualU32,
- CompareGreaterU32,
- CompareLess,
- CompareLessOrEqual,
- CompareLessOrEqualU32,
- CompareLessU32,
- CompareNotEqual,
- ConditionalSelect,
- ConvertFPToS32,
- ConvertS32ToFP,
- ConvertU32ToFP,
- Copy,
- Cosine,
- Discard,
- Divide,
- EmitVertex,
- EndPrimitive,
- ExponentB2,
- Floor,
- FusedMultiplyAdd,
- IsNan,
- LoadConstant,
- LoadGlobal,
- LoadLocal,
- LogarithmB2,
- LogicalAnd,
- LogicalExclusiveOr,
- LogicalNot,
- LogicalOr,
- LoopBreak,
- LoopContinue,
- MarkLabel,
- Maximum,
- MaximumU32,
- Minimum,
- MinimumU32,
- Multiply,
- Negate,
- PackDouble2x32,
- PackHalf2x16,
- ReciprocalSquareRoot,
- Return,
- ShiftLeft,
- ShiftRightS32,
- ShiftRightU32,
- Sine,
- SquareRoot,
- StoreGlobal,
- StoreLocal,
- Subtract,
- TextureSample,
- TextureSize,
- Truncate,
- UnpackDouble2x32,
- UnpackHalf2x16,
-
- Count,
- FP = 1 << 16,
- Mask = 0xffff
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/IrConsts.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/IrConsts.cs
deleted file mode 100644
index c264e47d..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/IrConsts.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- static class IrConsts
- {
- public const int False = 0;
- public const int True = -1;
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/Operand.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/Operand.cs
deleted file mode 100644
index 1df88a3d..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/Operand.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-using Ryujinx.Graphics.Shader.Decoders;
-using System;
-using System.Collections.Generic;
-
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- class Operand
- {
- private const int CbufSlotBits = 5;
- private const int CbufSlotLsb = 32 - CbufSlotBits;
- private const int CbufSlotMask = (1 << CbufSlotBits) - 1;
-
- public OperandType Type { get; }
-
- public int Value { get; }
-
- public INode AsgOp { get; set; }
-
- public HashSet<INode> UseOps { get; }
-
- private Operand()
- {
- UseOps = new HashSet<INode>();
- }
-
- public Operand(OperandType type) : this()
- {
- Type = type;
- }
-
- public Operand(OperandType type, int value) : this()
- {
- Type = type;
- Value = value;
- }
-
- public Operand(Register reg) : this()
- {
- Type = OperandType.Register;
- Value = PackRegInfo(reg.Index, reg.Type);
- }
-
- public Operand(int slot, int offset) : this()
- {
- Type = OperandType.ConstantBuffer;
- Value = PackCbufInfo(slot, offset);
- }
-
- private static int PackCbufInfo(int slot, int offset)
- {
- return (slot << CbufSlotLsb) | offset;
- }
-
- private static int PackRegInfo(int index, RegisterType type)
- {
- return ((int)type << 24) | index;
- }
-
- public int GetCbufSlot()
- {
- return (Value >> CbufSlotLsb) & CbufSlotMask;
- }
-
- public int GetCbufOffset()
- {
- return Value & ~(CbufSlotMask << CbufSlotLsb);
- }
-
- public Register GetRegister()
- {
- return new Register(Value & 0xffffff, (RegisterType)(Value >> 24));
- }
-
- public float AsFloat()
- {
- return BitConverter.Int32BitsToSingle(Value);
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/OperandHelper.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/OperandHelper.cs
deleted file mode 100644
index 6765f8a4..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/OperandHelper.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using Ryujinx.Graphics.Shader.Decoders;
-using System;
-
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- static class OperandHelper
- {
- public static Operand Attribute(int value)
- {
- return new Operand(OperandType.Attribute, value);
- }
-
- public static Operand Cbuf(int slot, int offset)
- {
- return new Operand(slot, offset);
- }
-
- public static Operand Const(int value)
- {
- return new Operand(OperandType.Constant, value);
- }
-
- public static Operand ConstF(float value)
- {
- return new Operand(OperandType.Constant, BitConverter.SingleToInt32Bits(value));
- }
-
- public static Operand Label()
- {
- return new Operand(OperandType.Label);
- }
-
- public static Operand Local()
- {
- return new Operand(OperandType.LocalVariable);
- }
-
- public static Operand Register(int index, RegisterType type)
- {
- return Register(new Register(index, type));
- }
-
- public static Operand Register(Register reg)
- {
- if (reg.IsRZ)
- {
- return Const(0);
- }
- else if (reg.IsPT)
- {
- return Const(IrConsts.True);
- }
-
- return new Operand(reg);
- }
-
- public static Operand Undef()
- {
- return new Operand(OperandType.Undefined);
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/OperandType.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/OperandType.cs
deleted file mode 100644
index e0e2a667..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/OperandType.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- enum OperandType
- {
- Attribute,
- Constant,
- ConstantBuffer,
- GlobalMemory,
- Label,
- LocalMemory,
- LocalVariable,
- Register,
- Undefined
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/Operation.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/Operation.cs
deleted file mode 100644
index c60f393e..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/Operation.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- class Operation : INode
- {
- public Instruction Inst { get; private set; }
-
- private Operand _dest;
-
- public Operand Dest
- {
- get => _dest;
- set => _dest = AssignDest(value);
- }
-
- private Operand[] _sources;
-
- public int SourcesCount => _sources.Length;
-
- public int ComponentIndex { get; }
-
- public Operation(Instruction inst, Operand dest, params Operand[] sources)
- {
- Inst = inst;
- Dest = dest;
-
- // The array may be modified externally, so we store a copy.
- _sources = (Operand[])sources.Clone();
-
- for (int index = 0; index < _sources.Length; index++)
- {
- Operand source = _sources[index];
-
- if (source.Type == OperandType.LocalVariable)
- {
- source.UseOps.Add(this);
- }
- }
- }
-
- public Operation(
- Instruction inst,
- int compIndex,
- Operand dest,
- params Operand[] sources) : this(inst, dest, sources)
- {
- ComponentIndex = compIndex;
- }
-
- private Operand AssignDest(Operand dest)
- {
- if (dest != null && dest.Type == OperandType.LocalVariable)
- {
- dest.AsgOp = this;
- }
-
- return dest;
- }
-
- public Operand GetSource(int index)
- {
- return _sources[index];
- }
-
- public void SetSource(int index, Operand source)
- {
- Operand oldSrc = _sources[index];
-
- if (oldSrc != null && oldSrc.Type == OperandType.LocalVariable)
- {
- oldSrc.UseOps.Remove(this);
- }
-
- if (source.Type == OperandType.LocalVariable)
- {
- source.UseOps.Add(this);
- }
-
- _sources[index] = source;
- }
-
- public void TurnIntoCopy(Operand source)
- {
- Inst = Instruction.Copy;
-
- foreach (Operand oldSrc in _sources)
- {
- if (oldSrc.Type == OperandType.LocalVariable)
- {
- oldSrc.UseOps.Remove(this);
- }
- }
-
- if (source.Type == OperandType.LocalVariable)
- {
- source.UseOps.Add(this);
- }
-
- _sources = new Operand[] { source };
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/PhiNode.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/PhiNode.cs
deleted file mode 100644
index 13ff41bd..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/PhiNode.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-using System.Collections.Generic;
-
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- class PhiNode : INode
- {
- private Operand _dest;
-
- public Operand Dest
- {
- get => _dest;
- set => _dest = AssignDest(value);
- }
-
- private HashSet<BasicBlock> _blocks;
-
- private class PhiSource
- {
- public BasicBlock Block { get; }
- public Operand Operand { get; set; }
-
- public PhiSource(BasicBlock block, Operand operand)
- {
- Block = block;
- Operand = operand;
- }
- }
-
- private List<PhiSource> _sources;
-
- public int SourcesCount => _sources.Count;
-
- public PhiNode(Operand dest)
- {
- _blocks = new HashSet<BasicBlock>();
-
- _sources = new List<PhiSource>();
-
- dest.AsgOp = this;
-
- Dest = dest;
- }
-
- private Operand AssignDest(Operand dest)
- {
- if (dest != null && dest.Type == OperandType.LocalVariable)
- {
- dest.AsgOp = this;
- }
-
- return dest;
- }
-
- public void AddSource(BasicBlock block, Operand operand)
- {
- if (_blocks.Add(block))
- {
- if (operand.Type == OperandType.LocalVariable)
- {
- operand.UseOps.Add(this);
- }
-
- _sources.Add(new PhiSource(block, operand));
- }
- }
-
- public Operand GetSource(int index)
- {
- return _sources[index].Operand;
- }
-
- public BasicBlock GetBlock(int index)
- {
- return _sources[index].Block;
- }
-
- public void SetSource(int index, Operand source)
- {
- Operand oldSrc = _sources[index].Operand;
-
- if (oldSrc != null && oldSrc.Type == OperandType.LocalVariable)
- {
- oldSrc.UseOps.Remove(this);
- }
-
- if (source.Type == OperandType.LocalVariable)
- {
- source.UseOps.Add(this);
- }
-
- _sources[index].Operand = source;
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureFlags.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureFlags.cs
deleted file mode 100644
index 5f0a8427..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureFlags.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- [Flags]
- enum TextureFlags
- {
- None = 0,
- Bindless = 1 << 0,
- Gather = 1 << 1,
- IntCoords = 1 << 2,
- LodBias = 1 << 3,
- LodLevel = 1 << 4,
- Offset = 1 << 5,
- Offsets = 1 << 6
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureOperation.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureOperation.cs
deleted file mode 100644
index f5f2cc5c..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureOperation.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- class TextureOperation : Operation
- {
- public TextureType Type { get; }
- public TextureFlags Flags { get; }
-
- public int Handle { get; }
-
- public TextureOperation(
- Instruction inst,
- TextureType type,
- TextureFlags flags,
- int handle,
- int compIndex,
- Operand dest,
- params Operand[] sources) : base(inst, compIndex, dest, sources)
- {
- Type = type;
- Flags = flags;
- Handle = handle;
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureType.cs b/Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureType.cs
deleted file mode 100644
index bf207007..00000000
--- a/Ryujinx.Graphics/Shader/IntermediateRepresentation/TextureType.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-
-namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
-{
- [Flags]
- enum TextureType
- {
- Texture1D,
- Texture2D,
- Texture3D,
- TextureCube,
-
- Mask = 0xff,
-
- Array = 1 << 8,
- Multisample = 1 << 9,
- Shadow = 1 << 10
- }
-
- static class TextureTypeExtensions
- {
- public static int GetCoordsCount(this TextureType type)
- {
- switch (type & TextureType.Mask)
- {
- case TextureType.Texture1D: return 1;
- case TextureType.Texture2D: return 2;
- case TextureType.Texture3D: return 3;
- case TextureType.TextureCube: return 3;
- }
-
- throw new ArgumentException($"Invalid texture type \"{type}\".");
- }
- }
-} \ No newline at end of file