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/Translation/Optimizations/GlobalToStorage.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/Translation/Optimizations/GlobalToStorage.cs')
| -rw-r--r-- | Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs b/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs index 3d89faf6..2fafa5ad 100644 --- a/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs +++ b/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs @@ -1,8 +1,6 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using System.Collections.Generic; -using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; - namespace Ryujinx.Graphics.Shader.Translation.Optimizations { static class GlobalToStorage @@ -27,7 +25,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations continue; } - if (operation.Inst == Instruction.LoadGlobal || + if (operation.Inst.IsAtomic() || + operation.Inst == Instruction.LoadGlobal || operation.Inst == Instruction.StoreGlobal) { Operand source = operation.GetSource(0); @@ -51,18 +50,31 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations Operation storageOp; - if (operation.Inst == Instruction.LoadGlobal) + if (operation.Inst.IsAtomic()) + { + Operand[] sources = new Operand[operation.SourcesCount]; + + for (int index = 0; index < operation.SourcesCount; index++) + { + sources[index] = operation.GetSource(index); + } + + Instruction inst = (operation.Inst & ~Instruction.MrMask) | Instruction.MrStorage; + + storageOp = new Operation(inst, storageIndex, operation.Dest, sources); + } + else if (operation.Inst == Instruction.LoadGlobal) { Operand source = operation.GetSource(0); - storageOp = new Operation(Instruction.LoadStorage, operation.Dest, Const(storageIndex), source); + storageOp = new Operation(Instruction.LoadStorage, storageIndex, operation.Dest, source); } else { Operand src1 = operation.GetSource(0); Operand src2 = operation.GetSource(1); - storageOp = new Operation(Instruction.StoreStorage, null, Const(storageIndex), src1, src2); + storageOp = new Operation(Instruction.StoreStorage, storageIndex, null, src1, src2); } for (int index = 0; index < operation.SourcesCount; index++) @@ -114,6 +126,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations return -1; } + public static int GetStorageCbOffset(ShaderStage stage, int slot) + { + return GetStorageBaseCbOffset(stage) + slot * StorageDescSize; + } + private static int GetStorageBaseCbOffset(ShaderStage stage) { switch (stage) |
