aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Instructions/InstEmitVote.cs
blob: 8f81ecb4df86bd43b678d75cbb44b16fb9e8dc38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Ryujinx.Graphics.Shader.Decoders;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;

using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;

namespace Ryujinx.Graphics.Shader.Instructions
{
    static partial class InstEmit
    {
        public static void Vote(EmitterContext context)
        {
            OpCodeVote op = (OpCodeVote)context.CurrOp;

            Operand pred = GetPredicate39(context);

            Operand res = null;

            switch (op.VoteOp)
            {
                case VoteOp.All:
                    res = context.VoteAll(pred);
                    break;
                case VoteOp.Any:
                    res = context.VoteAny(pred);
                    break;
                case VoteOp.AllEqual:
                    res = context.VoteAllEqual(pred);
                    break;
            }

            if (res != null)
            {
                context.Copy(Register(op.Predicate45), res);
            }
            else
            {
                context.Config.PrintLog($"Invalid vote operation: {op.VoteOp}.");
            }

            if (!op.Rd.IsRZ)
            {
                context.Copy(Register(op.Rd), context.Ballot(pred));
            }
        }
    }
}