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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
using Ryujinx.Graphics.Shader.Instructions;
namespace Ryujinx.Graphics.Shader.Decoders
{
class OpCodeVideo : OpCode, IOpCodeRd, IOpCodeRa, IOpCodeRc
{
public Register Rd { get; }
public Register Ra { get; }
public Register Rb { get; }
public Register Rc { get; }
public int Immediate { get; }
public int RaSelection { get; }
public int RbSelection { get; }
public bool SetCondCode { get; }
public bool HasRb { get; }
public VideoType RaType { get; }
public VideoType RbType { get; }
public VideoPostOp PostOp { get; }
public bool DstSigned { get; }
public bool Saturate { get; }
public OpCodeVideo(InstEmitter emitter, ulong address, long opCode) : base(emitter, address, opCode)
{
Rd = new Register(opCode.Extract(0, 8), RegisterType.Gpr);
Ra = new Register(opCode.Extract(8, 8), RegisterType.Gpr);
Rb = new Register(opCode.Extract(20, 8), RegisterType.Gpr);
Rc = new Register(opCode.Extract(39, 8), RegisterType.Gpr);
RaSelection = opCode.Extract(36, 2);
RbSelection = opCode.Extract(28, 2);
RaType = opCode.Extract(37, 2) switch
{
2 => VideoType.U16,
3 => VideoType.U32,
_ => VideoType.U8
};
RbType = opCode.Extract(29, 2) switch
{
2 => VideoType.U16,
3 => VideoType.U32,
_ => VideoType.U8
};
if (opCode.Extract(48))
{
RaType |= VideoType.Signed;
}
if (!opCode.Extract(50))
{
// Immediate variant.
Immediate = opCode.Extract(16, 20);
RbType = opCode.Extract(49) ? VideoType.S16 : VideoType.U16;
if (RbType == VideoType.S16)
{
Immediate = (Immediate << 12) >> 12;
}
}
else if (opCode.Extract(49))
{
RbType |= VideoType.Signed;
}
if (RaType == VideoType.U16)
{
RaSelection &= 1;
}
else if (RaType == VideoType.U32)
{
RaSelection = 0;
}
if (RbType == VideoType.U16)
{
RbSelection &= 1;
}
else if (RbType == VideoType.U32)
{
RbSelection = 0;
}
SetCondCode = opCode.Extract(47);
HasRb = opCode.Extract(50);
PostOp = (VideoPostOp)opCode.Extract(51, 3);
DstSigned = opCode.Extract(54);
Saturate = opCode.Extract(55);
}
}
}
|