diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2020-10-25 17:00:44 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-25 17:00:44 -0300 |
| commit | 49f970d5bd9163e2b4e26a33ef8f84529174d5de (patch) | |
| tree | eceaf9c0454d27413ca77689c06a24b47467d1a0 /Ryujinx.Graphics.Shader/IntermediateRepresentation | |
| parent | 973a615d405a83d5fc2f6a11ad12ba63c2a76465 (diff) | |
Implement CAL and RET shader instructions (#1618)
* Add support for CAL and RET shader instructions
* Remove unused stuff
* Fix a bug that could cause the wrong values to be passed to a function
* Avoid repopulating function id dictionary every time
* PR feedback
* Fix vertex shader A/B merge
Diffstat (limited to 'Ryujinx.Graphics.Shader/IntermediateRepresentation')
6 files changed, 51 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs b/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs index 94975337..1f7d2b25 100644 --- a/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs +++ b/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs @@ -24,6 +24,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation } public bool HasBranch => _branch != null; + public bool Reachable => Index == 0 || Predecessors.Count != 0; public List<BasicBlock> Predecessors { get; } diff --git a/Ryujinx.Graphics.Shader/IntermediateRepresentation/Function.cs b/Ryujinx.Graphics.Shader/IntermediateRepresentation/Function.cs new file mode 100644 index 00000000..e535c3fc --- /dev/null +++ b/Ryujinx.Graphics.Shader/IntermediateRepresentation/Function.cs @@ -0,0 +1,23 @@ +namespace Ryujinx.Graphics.Shader.IntermediateRepresentation +{ + class Function + { + public BasicBlock[] Blocks { get; } + + public string Name { get; } + + public bool ReturnsValue { get; } + + public int InArgumentsCount { get; } + public int OutArgumentsCount { get; } + + public Function(BasicBlock[] blocks, string name, bool returnsValue, int inArgumentsCount, int outArgumentsCount) + { + Blocks = blocks; + Name = name; + ReturnsValue = returnsValue; + InArgumentsCount = inArgumentsCount; + OutArgumentsCount = outArgumentsCount; + } + } +}
\ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs b/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs index 4a6c3a78..c0356e46 100644 --- a/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs +++ b/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs @@ -31,6 +31,8 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation Branch, BranchIfFalse, BranchIfTrue, + Call, + CallOutArgument, Ceiling, Clamp, ClampU32, diff --git a/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandHelper.cs b/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandHelper.cs index 6765f8a4..221e278f 100644 --- a/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandHelper.cs +++ b/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandHelper.cs @@ -5,6 +5,11 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation { static class OperandHelper { + public static Operand Argument(int value) + { + return new Operand(OperandType.Argument, value); + } + public static Operand Attribute(int value) { return new Operand(OperandType.Attribute, value); diff --git a/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandType.cs b/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandType.cs index 8f8df9e4..3427b103 100644 --- a/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandType.cs +++ b/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandType.cs @@ -2,6 +2,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation { enum OperandType { + Argument, Attribute, Constant, ConstantBuffer, diff --git a/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs b/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs index 2c4a88cd..a86a278a 100644 --- a/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs +++ b/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs @@ -48,6 +48,25 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation Index = index; } + public void AppendOperands(params Operand[] operands) + { + int startIndex = _sources.Length; + + Array.Resize(ref _sources, startIndex + operands.Length); + + for (int index = 0; index < operands.Length; index++) + { + Operand source = operands[index]; + + if (source.Type == OperandType.LocalVariable) + { + source.UseOps.Add(this); + } + + _sources[startIndex + index] = source; + } + } + private Operand AssignDest(Operand dest) { if (dest != null && dest.Type == OperandType.LocalVariable) |
