InstGenBallot.cs
1 using Ryujinx.Graphics.Shader.StructuredIr; 2 using Ryujinx.Graphics.Shader.Translation; 3 4 using static Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions.InstGenHelper; 5 using static Ryujinx.Graphics.Shader.StructuredIr.InstructionInfo; 6 7 namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions 8 { 9 static class InstGenBallot 10 { 11 public static string Ballot(CodeGenContext context, AstOperation operation) 12 { 13 AggregateType dstType = GetSrcVarType(operation.Inst, 0); 14 15 string arg = GetSourceExpr(context, operation.GetSource(0), dstType); 16 char component = "xyzw"[operation.Index]; 17 18 if (context.HostCapabilities.SupportsShaderBallot) 19 { 20 return $"unpackUint2x32(ballotARB({arg})).{component}"; 21 } 22 else 23 { 24 return $"subgroupBallot({arg}).{component}"; 25 } 26 } 27 } 28 }