InstGenPacking.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Ryujinx.Graphics.Shader.StructuredIr;
  2. using static Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions.InstGenHelper;
  3. using static Ryujinx.Graphics.Shader.StructuredIr.InstructionInfo;
  4. namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
  5. {
  6. static class InstGenPacking
  7. {
  8. public static string PackHalf2x16(CodeGenContext context, AstOperation operation)
  9. {
  10. IAstNode src0 = operation.GetSource(0);
  11. IAstNode src1 = operation.GetSource(1);
  12. string src0Expr = GetSoureExpr(context, src0, GetSrcVarType(operation.Inst, 0));
  13. string src1Expr = GetSoureExpr(context, src1, GetSrcVarType(operation.Inst, 1));
  14. return $"packHalf2x16(vec2({src0Expr}, {src1Expr}))";
  15. }
  16. public static string UnpackHalf2x16(CodeGenContext context, AstOperation operation)
  17. {
  18. IAstNode src = operation.GetSource(0);
  19. string srcExpr = GetSoureExpr(context, src, GetSrcVarType(operation.Inst, 0));
  20. return $"unpackHalf2x16({srcExpr}){GetMask(operation.Index)}";
  21. }
  22. private static string GetMask(int index)
  23. {
  24. return '.' + "xy".Substring(index, 1);
  25. }
  26. }
  27. }