diff options
author | gdk <gab.dark.100@gmail.com> | 2019-11-08 17:29:41 -0300 |
---|---|---|
committer | Thog <thog@protonmail.com> | 2020-01-09 02:13:00 +0100 |
commit | 769c02235f489f02b1791e6e76dc8b3ab18028ee (patch) | |
tree | ef0a2ffc5030360d5cef78e7c67e131e44348d50 /Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs | |
parent | 1e8bc29f32cde08616175f8f87405dfa7b8c4025 (diff) |
Add ATOMS, LDS, POPC, RED, STS and VOTE shader instructions, start changing the way how global memory is handled
Diffstat (limited to 'Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs')
-rw-r--r-- | Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs b/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs index ef8443ab..a81b3d12 100644 --- a/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs +++ b/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs @@ -51,8 +51,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr sources[index] = context.GetOperandUse(operation.GetSource(index)); } - int componentMask = 1 << operation.ComponentIndex; - AstTextureOperation GetAstTextureOperation(TextureOperation texOp) { return new AstTextureOperation( @@ -61,7 +59,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr texOp.Flags, texOp.Handle, 4, // TODO: Non-hardcoded array size. - componentMask, + texOp.Index, sources); } @@ -80,16 +78,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr context.Info.CBuffers.Add(slot.Value); } - else if (inst == Instruction.LoadStorage) + else if (UsesStorage(inst)) { - Operand slot = operation.GetSource(0); - - if (slot.Type != OperandType.Constant) - { - throw new InvalidOperationException("Found load or store with non-constant storage buffer slot."); - } - - context.Info.SBuffers.Add(slot.Value); + context.Info.SBuffers.Add(operation.Index); } AstAssignment assignment; @@ -141,7 +132,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr } else if (!isCopy) { - source = new AstOperation(inst, componentMask, sources); + source = new AstOperation(inst, operation.Index, sources); } else { @@ -166,19 +157,12 @@ namespace Ryujinx.Graphics.Shader.StructuredIr } else { - if (inst == Instruction.StoreStorage) + if (UsesStorage(inst)) { - Operand slot = operation.GetSource(0); - - if (slot.Type != OperandType.Constant) - { - throw new InvalidOperationException("Found load or store with non-constant storage buffer slot."); - } - - context.Info.SBuffers.Add(slot.Value); + context.Info.SBuffers.Add(operation.Index); } - context.AddNode(new AstOperation(inst, sources)); + context.AddNode(new AstOperation(inst, operation.Index, sources)); } // Those instructions needs to be emulated by using helper functions, @@ -186,6 +170,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr // decide which helper functions are needed on the final generated code. switch (operation.Inst) { + case Instruction.LoadGlobal: + case Instruction.StoreGlobal: + context.Info.HelperFunctionsMask |= HelperFunctionsMask.GlobalMemory; + break; case Instruction.Shuffle: context.Info.HelperFunctionsMask |= HelperFunctionsMask.Shuffle; break; @@ -320,5 +308,15 @@ namespace Ryujinx.Graphics.Shader.StructuredIr throw new ArgumentException($"Unexpected instruction \"{inst}\"."); } + + private static bool UsesStorage(Instruction inst) + { + if (inst == Instruction.LoadStorage || inst == Instruction.StoreStorage) + { + return true; + } + + return inst.IsAtomic() && (inst & Instruction.MrMask) == Instruction.MrStorage; + } } }
\ No newline at end of file |