diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2021-01-26 03:38:33 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-26 17:38:33 +1100 |
| commit | e453ba69f42057d36559b2c84b6ad9f01eaf4c86 (patch) | |
| tree | c7c62a2f40a2197bc9e1a41ab1e45a1a5c93a382 /Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions | |
| parent | c19cfca183cbbae8091688a292242032c3f337cb (diff) | |
Add support for shader atomic min/max (S32) (#1948)
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions')
| -rw-r--r-- | Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs | 14 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs | 4 |
2 files changed, 11 insertions, 7 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs index 388f0c25..7d0f1aa5 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs @@ -42,13 +42,18 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions for (int argIndex = 0; argIndex < arity; argIndex++) { + // For shared memory access, the second argument is unused and should be ignored. + // It is there to make both storage and shared access have the same number of arguments. + if (argIndex == 1 && (inst & Instruction.MrMask) == Instruction.MrShared) + { + continue; + } + if (argIndex != 0) { args += ", "; } - VariableType dstType = GetSrcVarType(inst, argIndex); - if (argIndex == 0 && atomic) { Instruction memRegion = inst & Instruction.MrMask; @@ -60,12 +65,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions default: throw new InvalidOperationException($"Invalid memory region \"{memRegion}\"."); } - - // We use the first 2 operands above. - argIndex++; } else { + VariableType dstType = GetSrcVarType(inst, argIndex); + args += GetSoureExpr(context, operation.GetSource(argIndex), dstType); } } diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs index 1b1efe9d..5f5574c3 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs @@ -16,9 +16,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions Add(Instruction.AtomicAdd, InstType.AtomicBinary, "atomicAdd"); Add(Instruction.AtomicAnd, InstType.AtomicBinary, "atomicAnd"); Add(Instruction.AtomicCompareAndSwap, InstType.AtomicTernary, "atomicCompSwap"); - Add(Instruction.AtomicMaxS32, InstType.AtomicBinary, "atomicMax"); + Add(Instruction.AtomicMaxS32, InstType.CallTernary, HelperFunctionNames.AtomicMaxS32); Add(Instruction.AtomicMaxU32, InstType.AtomicBinary, "atomicMax"); - Add(Instruction.AtomicMinS32, InstType.AtomicBinary, "atomicMin"); + Add(Instruction.AtomicMinS32, InstType.CallTernary, HelperFunctionNames.AtomicMinS32); Add(Instruction.AtomicMinU32, InstType.AtomicBinary, "atomicMin"); Add(Instruction.AtomicOr, InstType.AtomicBinary, "atomicOr"); Add(Instruction.AtomicSwap, InstType.AtomicBinary, "atomicExchange"); |
