aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader
diff options
context:
space:
mode:
authorgdk <gab.dark.100@gmail.com>2019-10-26 14:50:52 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commit8cba252b238ee6cf6599ad2fc57793e6f76c5e2e (patch)
tree5ee98eb374a46e210d4a960f5e1d58b42b3f27eb /Ryujinx.Graphics.Shader
parent1b7d95519569639135a68e7ebda5148f3263217c (diff)
Add per-source type memory change tracking, simplified state change tracking, other fixes
Diffstat (limited to 'Ryujinx.Graphics.Shader')
-rw-r--r--Ryujinx.Graphics.Shader/Decoders/ImageComponents.cs1
-rw-r--r--Ryujinx.Graphics.Shader/Decoders/SystemRegister.cs1
-rw-r--r--Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs14
-rw-r--r--Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs8
4 files changed, 22 insertions, 2 deletions
diff --git a/Ryujinx.Graphics.Shader/Decoders/ImageComponents.cs b/Ryujinx.Graphics.Shader/Decoders/ImageComponents.cs
index b8a4f6d5..348a4768 100644
--- a/Ryujinx.Graphics.Shader/Decoders/ImageComponents.cs
+++ b/Ryujinx.Graphics.Shader/Decoders/ImageComponents.cs
@@ -6,6 +6,5 @@ namespace Ryujinx.Graphics.Shader.Decoders
Green = 1 << 1,
Blue = 1 << 2,
Alpha = 1 << 3
-
}
} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Shader/Decoders/SystemRegister.cs b/Ryujinx.Graphics.Shader/Decoders/SystemRegister.cs
index 3948c899..1f51d93c 100644
--- a/Ryujinx.Graphics.Shader/Decoders/SystemRegister.cs
+++ b/Ryujinx.Graphics.Shader/Decoders/SystemRegister.cs
@@ -2,6 +2,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
{
enum SystemRegister
{
+ ThreadId = 0x20,
ThreadIdX = 0x21,
ThreadIdY = 0x22,
ThreadIdZ = 0x23,
diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs
index f66ebc9f..b9bb18d9 100644
--- a/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs
+++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs
@@ -27,6 +27,20 @@ namespace Ryujinx.Graphics.Shader.Instructions
switch (sysReg)
{
+ case SystemRegister.ThreadId:
+ {
+ Operand tidX = Attribute(AttributeConsts.ThreadIdX);
+ Operand tidY = Attribute(AttributeConsts.ThreadIdY);
+ Operand tidZ = Attribute(AttributeConsts.ThreadIdZ);
+
+ tidY = context.ShiftLeft(tidY, Const(16));
+ tidZ = context.ShiftLeft(tidZ, Const(26));
+
+ src = context.BitwiseOr(tidX, context.BitwiseOr(tidY, tidZ));
+
+ break;
+ }
+
case SystemRegister.ThreadIdX: src = Attribute(AttributeConsts.ThreadIdX); break;
case SystemRegister.ThreadIdY: src = Attribute(AttributeConsts.ThreadIdY); break;
case SystemRegister.ThreadIdZ: src = Attribute(AttributeConsts.ThreadIdZ); break;
diff --git a/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs b/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs
index cb08a213..d6ce76db 100644
--- a/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs
+++ b/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs
@@ -59,6 +59,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Add(Instruction.ExponentB2, VariableType.Scalar, VariableType.Scalar);
Add(Instruction.Floor, VariableType.F32, VariableType.F32);
Add(Instruction.FusedMultiplyAdd, VariableType.F32, VariableType.F32, VariableType.F32, VariableType.F32);
+ Add(Instruction.ImageLoad, VariableType.F32);
+ Add(Instruction.ImageStore, VariableType.None);
Add(Instruction.IsNan, VariableType.Bool, VariableType.F32);
Add(Instruction.LoadAttribute, VariableType.F32, VariableType.S32, VariableType.S32);
Add(Instruction.LoadConstant, VariableType.F32, VariableType.S32, VariableType.S32);
@@ -105,7 +107,11 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public static VariableType GetSrcVarType(Instruction inst, int index)
{
- if (inst == Instruction.TextureSample)
+ // TODO: Return correct type depending on source index,
+ // that can improve the decompiler output.
+ if (inst == Instruction.TextureSample ||
+ inst == Instruction.ImageLoad ||
+ inst == Instruction.ImageStore)
{
return VariableType.F32;
}