pan/bi: Squash LD_ATTR ops together
[mesa.git] / src / panfrost / bifrost / bifrost.h
1 /*
2 * Copyright (C) 2019 Connor Abbott <cwabbott0@gmail.com>
3 * Copyright (C) 2019 Lyude Paul <thatslyude@gmail.com>
4 * Copyright (C) 2019 Ryan Houdek <Sonicadvance1@gmail.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26 #ifndef __bifrost_h__
27 #define __bifrost_h__
28
29 #include <stdint.h>
30 #include <stdbool.h>
31
32 struct bifrost_header {
33 unsigned unk0 : 7;
34 // If true, convert any infinite result of any floating-point operation to
35 // the biggest representable number.
36 unsigned suppress_inf: 1;
37 // Convert any NaN results to 0.
38 unsigned suppress_nan : 1;
39 unsigned unk1 : 2;
40 // true if the execution mask of the next clause is the same as the mask of
41 // the current clause.
42 unsigned back_to_back : 1;
43 unsigned no_end_of_shader: 1;
44 unsigned unk2 : 2;
45 // Set to true for fragment shaders, to implement this bit of spec text
46 // from section 7.1.5 of the GLSL ES spec:
47 //
48 // "Stores to image and buffer variables performed by helper invocations
49 // have no effect on the underlying image or buffer memory."
50 //
51 // Helper invocations are threads (invocations) corresponding to pixels in
52 // a quad that aren't actually part of the triangle, but are included to
53 // make derivatives work correctly. They're usually turned on, but they
54 // need to be masked off for GLSL-level stores. This bit seems to be the
55 // only bit that's actually different between fragment shaders and other
56 // shaders, so this is probably what it's doing.
57 unsigned elide_writes : 1;
58 // If backToBack is off:
59 // - true for conditional branches and fallthrough
60 // - false for unconditional branches
61 // The blob seems to always set it to true if back-to-back is on.
62 unsigned branch_cond : 1;
63 // This bit is set when the next clause writes to the data register of some
64 // previous clause.
65 unsigned datareg_writebarrier: 1;
66 unsigned datareg : 6;
67 unsigned scoreboard_deps: 8;
68 unsigned scoreboard_index: 3;
69 unsigned clause_type: 4;
70 unsigned unk3 : 1; // part of clauseType?
71 unsigned next_clause_type: 4;
72 unsigned unk4 : 1; // part of nextClauseType?
73 };
74
75 struct bifrost_fma_inst {
76 unsigned src0 : 3;
77 unsigned op : 20;
78 };
79
80 struct bifrost_add_inst {
81 unsigned src0 : 3;
82 unsigned op : 17;
83 };
84
85 enum bifrost_csel_cond {
86 BIFROST_FEQ_F = 0x0,
87 BIFROST_FGT_F = 0x1,
88 BIFROST_FGE_F = 0x2,
89 BIFROST_IEQ_F = 0x3,
90 BIFROST_IGT_I = 0x4,
91 BIFROST_IGE_I = 0x5,
92 BIFROST_UGT_I = 0x6,
93 BIFROST_UGE_I = 0x7
94 };
95
96 struct bifrost_csel4 {
97 unsigned src0 : 3;
98 unsigned src1 : 3;
99 unsigned src2 : 3;
100 unsigned src3 : 3;
101 enum bifrost_csel_cond cond : 3;
102 unsigned op : 8;
103 };
104
105 struct bifrost_shift_fma {
106 unsigned src0 : 3;
107 unsigned src1 : 3;
108 unsigned src2 : 3;
109 unsigned half : 3; /* 000 for i32, 100 for i8, 111 for v2i16 */
110 unsigned unk : 1; /* always set? */
111 unsigned invert_1 : 1; /* Inverts sources to combining op */
112 /* For XOR, switches RSHIFT to LSHIFT since only one invert needed */
113 unsigned invert_2 : 1;
114 unsigned op : 8;
115 };
116
117 struct bifrost_shift_add {
118 unsigned src0 : 3;
119 unsigned src1 : 3;
120 unsigned src2 : 3;
121 unsigned zero : 2;
122
123 unsigned invert_1 : 1;
124 unsigned invert_2 : 1;
125
126 unsigned op : 7;
127 };
128
129 enum bifrost_ldst_type {
130 BIFROST_LDST_F16 = 0,
131 BIFROST_LDST_F32 = 1,
132 BIFROST_LDST_I32 = 2,
133 BIFROST_LDST_U32 = 3
134 };
135
136 struct bifrost_ld_var_addr {
137 unsigned src0 : 3;
138 unsigned src1 : 3;
139 unsigned location : 5;
140 enum bifrost_ldst_type type : 2;
141 unsigned op : 7;
142 };
143
144 struct bifrost_ld_attr {
145 unsigned src0 : 3;
146 unsigned src1 : 3;
147 unsigned location : 5;
148 unsigned channels : 2; /* MALI_POSITIVE */
149 enum bifrost_ldst_type type : 2;
150 unsigned op : 5;
151 };
152
153 #endif