diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2021-09-19 09:38:39 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-19 14:38:39 +0200 |
| commit | f08a280adef015e9a9a0e9273b4edffeb1157f3a (patch) | |
| tree | 26baeacb8b094e77aa0d8cde15073d12e080305a /Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions | |
| parent | 7379bc2f39557929f283a423fe7f4b7390d08261 (diff) | |
Use shader subgroup extensions if shader ballot is not supported (#2627)
* Use shader subgroup extensions if shader ballot is not supported
* Shader cache version bump + cleanup
* The type is still required on the table
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions')
3 files changed, 32 insertions, 9 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs index 24d4cabd..3fa13eb5 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs @@ -2,6 +2,7 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.StructuredIr; using System; +using static Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions.InstGenBallot; using static Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions.InstGenCall; using static Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions.InstGenHelper; using static Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions.InstGenMemory; @@ -75,14 +76,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions } } - if (inst == Instruction.Ballot) - { - return $"unpackUint2x32({info.OpName}({args})).x"; - } - else - { - return info.OpName + "(" + args + ")"; - } + return info.OpName + '(' + args + ')'; } else if ((info.Type & InstType.Op) != 0) { @@ -128,6 +122,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions { switch (inst) { + case Instruction.Ballot: + return Ballot(context, operation); + case Instruction.Call: return Call(context, operation); diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenBallot.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenBallot.cs new file mode 100644 index 00000000..51e7bd21 --- /dev/null +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenBallot.cs @@ -0,0 +1,26 @@ +using Ryujinx.Graphics.Shader.StructuredIr; + +using static Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions.InstGenHelper; +using static Ryujinx.Graphics.Shader.StructuredIr.InstructionInfo; + +namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions +{ + static class InstGenBallot + { + public static string Ballot(CodeGenContext context, AstOperation operation) + { + VariableType dstType = GetSrcVarType(operation.Inst, 0); + + string arg = GetSoureExpr(context, operation.GetSource(0), dstType); + + if (context.Config.GpuAccessor.QueryHostSupportsShaderBallot()) + { + return $"unpackUint2x32(ballotARB({arg})).x"; + } + else + { + return $"subgroupBallot({arg}).x"; + } + } + } +}
\ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs index 6f4f0c4e..424a1c4f 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs @@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions Add(Instruction.AtomicXor, InstType.AtomicBinary, "atomicXor"); Add(Instruction.Absolute, InstType.CallUnary, "abs"); Add(Instruction.Add, InstType.OpBinaryCom, "+", 2); - Add(Instruction.Ballot, InstType.CallUnary, "ballotARB"); + Add(Instruction.Ballot, InstType.Special); Add(Instruction.Barrier, InstType.CallNullary, "barrier"); Add(Instruction.BitCount, InstType.CallUnary, "bitCount"); Add(Instruction.BitfieldExtractS32, InstType.CallTernary, "bitfieldExtract"); |
