1*61046927SAndroid Build Coastguard Worker /*
2*61046927SAndroid Build Coastguard Worker * Copyright © 2016 Broadcom
3*61046927SAndroid Build Coastguard Worker *
4*61046927SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining a
5*61046927SAndroid Build Coastguard Worker * copy of this software and associated documentation files (the "Software"),
6*61046927SAndroid Build Coastguard Worker * to deal in the Software without restriction, including without limitation
7*61046927SAndroid Build Coastguard Worker * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*61046927SAndroid Build Coastguard Worker * and/or sell copies of the Software, and to permit persons to whom the
9*61046927SAndroid Build Coastguard Worker * Software is furnished to do so, subject to the following conditions:
10*61046927SAndroid Build Coastguard Worker *
11*61046927SAndroid Build Coastguard Worker * The above copyright notice and this permission notice (including the next
12*61046927SAndroid Build Coastguard Worker * paragraph) shall be included in all copies or substantial portions of the
13*61046927SAndroid Build Coastguard Worker * Software.
14*61046927SAndroid Build Coastguard Worker *
15*61046927SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*61046927SAndroid Build Coastguard Worker * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*61046927SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18*61046927SAndroid Build Coastguard Worker * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*61046927SAndroid Build Coastguard Worker * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*61046927SAndroid Build Coastguard Worker * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21*61046927SAndroid Build Coastguard Worker * IN THE SOFTWARE.
22*61046927SAndroid Build Coastguard Worker */
23*61046927SAndroid Build Coastguard Worker
24*61046927SAndroid Build Coastguard Worker #ifndef V3D_COMPILER_H
25*61046927SAndroid Build Coastguard Worker #define V3D_COMPILER_H
26*61046927SAndroid Build Coastguard Worker
27*61046927SAndroid Build Coastguard Worker #include <assert.h>
28*61046927SAndroid Build Coastguard Worker #include <stdio.h>
29*61046927SAndroid Build Coastguard Worker #include <stdlib.h>
30*61046927SAndroid Build Coastguard Worker #include <stdbool.h>
31*61046927SAndroid Build Coastguard Worker #include <stdint.h>
32*61046927SAndroid Build Coastguard Worker #include <string.h>
33*61046927SAndroid Build Coastguard Worker
34*61046927SAndroid Build Coastguard Worker #include "util/blend.h"
35*61046927SAndroid Build Coastguard Worker #include "util/macros.h"
36*61046927SAndroid Build Coastguard Worker #include "common/v3d_debug.h"
37*61046927SAndroid Build Coastguard Worker #include "common/v3d_device_info.h"
38*61046927SAndroid Build Coastguard Worker #include "common/v3d_limits.h"
39*61046927SAndroid Build Coastguard Worker #include "compiler/nir/nir.h"
40*61046927SAndroid Build Coastguard Worker #include "util/list.h"
41*61046927SAndroid Build Coastguard Worker #include "util/u_math.h"
42*61046927SAndroid Build Coastguard Worker
43*61046927SAndroid Build Coastguard Worker #include "qpu/qpu_instr.h"
44*61046927SAndroid Build Coastguard Worker
45*61046927SAndroid Build Coastguard Worker /**
46*61046927SAndroid Build Coastguard Worker * Maximum number of outstanding TMU operations we can queue for execution.
47*61046927SAndroid Build Coastguard Worker *
48*61046927SAndroid Build Coastguard Worker * This is mostly limited by the size of the TMU fifos. The Input and Config
49*61046927SAndroid Build Coastguard Worker * fifos can stall, but we prefer that than injecting TMU flushes manually
50*61046927SAndroid Build Coastguard Worker * in the driver, so we can ignore these, but we can't overflow the Output fifo,
51*61046927SAndroid Build Coastguard Worker * which has 16 / threads per-thread entries, meaning that the maximum number
52*61046927SAndroid Build Coastguard Worker * of outstanding LDTMUs we can ever have is 8, for a 2-way threaded shader.
53*61046927SAndroid Build Coastguard Worker * This means that at most we can have 8 outstanding TMU loads, if each load
54*61046927SAndroid Build Coastguard Worker * is just one component.
55*61046927SAndroid Build Coastguard Worker *
56*61046927SAndroid Build Coastguard Worker * NOTE: we could actually have a larger value here because TMU stores don't
57*61046927SAndroid Build Coastguard Worker * consume any entries in the Output fifo (so we could have any number of
58*61046927SAndroid Build Coastguard Worker * outstanding stores) and the driver keeps track of used Output fifo entries
59*61046927SAndroid Build Coastguard Worker * and will flush if we ever needs more than 8, but since loads are much more
60*61046927SAndroid Build Coastguard Worker * common than stores, it is probably not worth it.
61*61046927SAndroid Build Coastguard Worker */
62*61046927SAndroid Build Coastguard Worker #define MAX_TMU_QUEUE_SIZE 8
63*61046927SAndroid Build Coastguard Worker
64*61046927SAndroid Build Coastguard Worker /**
65*61046927SAndroid Build Coastguard Worker * Maximum offset distance in bytes between two consecutive constant UBO loads
66*61046927SAndroid Build Coastguard Worker * for the same UBO where we would favor updating the unifa address by emitting
67*61046927SAndroid Build Coastguard Worker * dummy ldunifa instructions to avoid writing the unifa register.
68*61046927SAndroid Build Coastguard Worker */
69*61046927SAndroid Build Coastguard Worker #define MAX_UNIFA_SKIP_DISTANCE 16
70*61046927SAndroid Build Coastguard Worker
71*61046927SAndroid Build Coastguard Worker struct nir_builder;
72*61046927SAndroid Build Coastguard Worker
73*61046927SAndroid Build Coastguard Worker struct v3d_fs_inputs {
74*61046927SAndroid Build Coastguard Worker /**
75*61046927SAndroid Build Coastguard Worker * Array of the meanings of the VPM inputs this shader needs.
76*61046927SAndroid Build Coastguard Worker *
77*61046927SAndroid Build Coastguard Worker * It doesn't include those that aren't part of the VPM, like
78*61046927SAndroid Build Coastguard Worker * point/line coordinates.
79*61046927SAndroid Build Coastguard Worker */
80*61046927SAndroid Build Coastguard Worker struct v3d_varying_slot *input_slots;
81*61046927SAndroid Build Coastguard Worker uint32_t num_inputs;
82*61046927SAndroid Build Coastguard Worker };
83*61046927SAndroid Build Coastguard Worker
84*61046927SAndroid Build Coastguard Worker enum qfile {
85*61046927SAndroid Build Coastguard Worker /** An unused source or destination register. */
86*61046927SAndroid Build Coastguard Worker QFILE_NULL,
87*61046927SAndroid Build Coastguard Worker
88*61046927SAndroid Build Coastguard Worker /** A physical register, such as the W coordinate payload. */
89*61046927SAndroid Build Coastguard Worker QFILE_REG,
90*61046927SAndroid Build Coastguard Worker /** One of the registers for fixed function interactions. */
91*61046927SAndroid Build Coastguard Worker QFILE_MAGIC,
92*61046927SAndroid Build Coastguard Worker
93*61046927SAndroid Build Coastguard Worker /**
94*61046927SAndroid Build Coastguard Worker * A virtual register, that will be allocated to actual accumulator
95*61046927SAndroid Build Coastguard Worker * or physical registers later.
96*61046927SAndroid Build Coastguard Worker */
97*61046927SAndroid Build Coastguard Worker QFILE_TEMP,
98*61046927SAndroid Build Coastguard Worker
99*61046927SAndroid Build Coastguard Worker /**
100*61046927SAndroid Build Coastguard Worker * Stores an immediate value in the index field that will be used
101*61046927SAndroid Build Coastguard Worker * directly by qpu_load_imm().
102*61046927SAndroid Build Coastguard Worker */
103*61046927SAndroid Build Coastguard Worker QFILE_LOAD_IMM,
104*61046927SAndroid Build Coastguard Worker
105*61046927SAndroid Build Coastguard Worker /**
106*61046927SAndroid Build Coastguard Worker * Stores an immediate value in the index field that can be turned
107*61046927SAndroid Build Coastguard Worker * into a small immediate field by qpu_encode_small_immediate().
108*61046927SAndroid Build Coastguard Worker */
109*61046927SAndroid Build Coastguard Worker QFILE_SMALL_IMM,
110*61046927SAndroid Build Coastguard Worker };
111*61046927SAndroid Build Coastguard Worker
112*61046927SAndroid Build Coastguard Worker /**
113*61046927SAndroid Build Coastguard Worker * A reference to a QPU register or a virtual temp register.
114*61046927SAndroid Build Coastguard Worker */
115*61046927SAndroid Build Coastguard Worker struct qreg {
116*61046927SAndroid Build Coastguard Worker enum qfile file;
117*61046927SAndroid Build Coastguard Worker uint32_t index;
118*61046927SAndroid Build Coastguard Worker };
119*61046927SAndroid Build Coastguard Worker
vir_reg(enum qfile file,uint32_t index)120*61046927SAndroid Build Coastguard Worker static inline struct qreg vir_reg(enum qfile file, uint32_t index)
121*61046927SAndroid Build Coastguard Worker {
122*61046927SAndroid Build Coastguard Worker return (struct qreg){file, index};
123*61046927SAndroid Build Coastguard Worker }
124*61046927SAndroid Build Coastguard Worker
vir_magic_reg(uint32_t index)125*61046927SAndroid Build Coastguard Worker static inline struct qreg vir_magic_reg(uint32_t index)
126*61046927SAndroid Build Coastguard Worker {
127*61046927SAndroid Build Coastguard Worker return (struct qreg){QFILE_MAGIC, index};
128*61046927SAndroid Build Coastguard Worker }
129*61046927SAndroid Build Coastguard Worker
vir_nop_reg(void)130*61046927SAndroid Build Coastguard Worker static inline struct qreg vir_nop_reg(void)
131*61046927SAndroid Build Coastguard Worker {
132*61046927SAndroid Build Coastguard Worker return (struct qreg){QFILE_NULL, 0};
133*61046927SAndroid Build Coastguard Worker }
134*61046927SAndroid Build Coastguard Worker
135*61046927SAndroid Build Coastguard Worker /**
136*61046927SAndroid Build Coastguard Worker * A reference to an actual register at the QPU level, for register
137*61046927SAndroid Build Coastguard Worker * allocation.
138*61046927SAndroid Build Coastguard Worker */
139*61046927SAndroid Build Coastguard Worker struct qpu_reg {
140*61046927SAndroid Build Coastguard Worker bool magic;
141*61046927SAndroid Build Coastguard Worker bool smimm;
142*61046927SAndroid Build Coastguard Worker int index;
143*61046927SAndroid Build Coastguard Worker };
144*61046927SAndroid Build Coastguard Worker
145*61046927SAndroid Build Coastguard Worker struct qinst {
146*61046927SAndroid Build Coastguard Worker /** Entry in qblock->instructions */
147*61046927SAndroid Build Coastguard Worker struct list_head link;
148*61046927SAndroid Build Coastguard Worker
149*61046927SAndroid Build Coastguard Worker /**
150*61046927SAndroid Build Coastguard Worker * The instruction being wrapped. Its condition codes, pack flags,
151*61046927SAndroid Build Coastguard Worker * signals, etc. will all be used, with just the register references
152*61046927SAndroid Build Coastguard Worker * being replaced by the contents of qinst->dst and qinst->src[].
153*61046927SAndroid Build Coastguard Worker */
154*61046927SAndroid Build Coastguard Worker struct v3d_qpu_instr qpu;
155*61046927SAndroid Build Coastguard Worker
156*61046927SAndroid Build Coastguard Worker /* Pre-register-allocation references to src/dst registers */
157*61046927SAndroid Build Coastguard Worker struct qreg dst;
158*61046927SAndroid Build Coastguard Worker struct qreg src[3];
159*61046927SAndroid Build Coastguard Worker bool is_last_thrsw;
160*61046927SAndroid Build Coastguard Worker
161*61046927SAndroid Build Coastguard Worker /* If the instruction reads a uniform (other than through src[i].file
162*61046927SAndroid Build Coastguard Worker * == QFILE_UNIF), that uniform's index in c->uniform_contents. ~0
163*61046927SAndroid Build Coastguard Worker * otherwise.
164*61046927SAndroid Build Coastguard Worker */
165*61046927SAndroid Build Coastguard Worker int uniform;
166*61046927SAndroid Build Coastguard Worker
167*61046927SAndroid Build Coastguard Worker /* If this is a a TLB Z write */
168*61046927SAndroid Build Coastguard Worker bool is_tlb_z_write;
169*61046927SAndroid Build Coastguard Worker
170*61046927SAndroid Build Coastguard Worker /* If this is a retiring TMU instruction (the last in a lookup sequence),
171*61046927SAndroid Build Coastguard Worker * how many ldtmu instructions are required to read the results.
172*61046927SAndroid Build Coastguard Worker */
173*61046927SAndroid Build Coastguard Worker uint32_t ldtmu_count;
174*61046927SAndroid Build Coastguard Worker
175*61046927SAndroid Build Coastguard Worker /* Position of this instruction in the program. Filled in during
176*61046927SAndroid Build Coastguard Worker * register allocation.
177*61046927SAndroid Build Coastguard Worker */
178*61046927SAndroid Build Coastguard Worker int32_t ip;
179*61046927SAndroid Build Coastguard Worker };
180*61046927SAndroid Build Coastguard Worker
181*61046927SAndroid Build Coastguard Worker enum quniform_contents {
182*61046927SAndroid Build Coastguard Worker /**
183*61046927SAndroid Build Coastguard Worker * Indicates that a constant 32-bit value is copied from the program's
184*61046927SAndroid Build Coastguard Worker * uniform contents.
185*61046927SAndroid Build Coastguard Worker */
186*61046927SAndroid Build Coastguard Worker QUNIFORM_CONSTANT,
187*61046927SAndroid Build Coastguard Worker /**
188*61046927SAndroid Build Coastguard Worker * Indicates that the program's uniform contents are used as an index
189*61046927SAndroid Build Coastguard Worker * into the GL uniform storage.
190*61046927SAndroid Build Coastguard Worker */
191*61046927SAndroid Build Coastguard Worker QUNIFORM_UNIFORM,
192*61046927SAndroid Build Coastguard Worker
193*61046927SAndroid Build Coastguard Worker /** @{
194*61046927SAndroid Build Coastguard Worker * Scaling factors from clip coordinates to relative to the viewport
195*61046927SAndroid Build Coastguard Worker * center.
196*61046927SAndroid Build Coastguard Worker *
197*61046927SAndroid Build Coastguard Worker * This is used by the coordinate and vertex shaders to produce the
198*61046927SAndroid Build Coastguard Worker * 32-bit entry consisting of 2 16-bit fields with 12.4 signed fixed
199*61046927SAndroid Build Coastguard Worker * point offsets from the viewport ccenter.
200*61046927SAndroid Build Coastguard Worker */
201*61046927SAndroid Build Coastguard Worker QUNIFORM_VIEWPORT_X_SCALE,
202*61046927SAndroid Build Coastguard Worker QUNIFORM_VIEWPORT_Y_SCALE,
203*61046927SAndroid Build Coastguard Worker /** @} */
204*61046927SAndroid Build Coastguard Worker
205*61046927SAndroid Build Coastguard Worker QUNIFORM_VIEWPORT_Z_OFFSET,
206*61046927SAndroid Build Coastguard Worker QUNIFORM_VIEWPORT_Z_SCALE,
207*61046927SAndroid Build Coastguard Worker
208*61046927SAndroid Build Coastguard Worker QUNIFORM_USER_CLIP_PLANE,
209*61046927SAndroid Build Coastguard Worker
210*61046927SAndroid Build Coastguard Worker /**
211*61046927SAndroid Build Coastguard Worker * A reference to a V3D 3.x texture config parameter 0 uniform.
212*61046927SAndroid Build Coastguard Worker *
213*61046927SAndroid Build Coastguard Worker * This is a uniform implicitly loaded with a QPU_W_TMU* write, which
214*61046927SAndroid Build Coastguard Worker * defines texture type, miplevels, and such. It will be found as a
215*61046927SAndroid Build Coastguard Worker * parameter to the first QOP_TEX_[STRB] instruction in a sequence.
216*61046927SAndroid Build Coastguard Worker */
217*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_0,
218*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_1,
219*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_2,
220*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_3,
221*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_4,
222*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_5,
223*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_6,
224*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_7,
225*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_8,
226*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_9,
227*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_10,
228*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_11,
229*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_12,
230*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_13,
231*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_14,
232*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_15,
233*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_16,
234*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_17,
235*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_18,
236*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_19,
237*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_20,
238*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_21,
239*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_22,
240*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_23,
241*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_24,
242*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_25,
243*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_26,
244*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_27,
245*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_28,
246*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_29,
247*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_30,
248*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_31,
249*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P0_32,
250*61046927SAndroid Build Coastguard Worker
251*61046927SAndroid Build Coastguard Worker /**
252*61046927SAndroid Build Coastguard Worker * A reference to a V3D 3.x texture config parameter 1 uniform.
253*61046927SAndroid Build Coastguard Worker *
254*61046927SAndroid Build Coastguard Worker * This is a uniform implicitly loaded with a QPU_W_TMU* write, which
255*61046927SAndroid Build Coastguard Worker * has the pointer to the indirect texture state. Our data[] field
256*61046927SAndroid Build Coastguard Worker * will have a packed p1 value, but the address field will be just
257*61046927SAndroid Build Coastguard Worker * which texture unit's texture should be referenced.
258*61046927SAndroid Build Coastguard Worker */
259*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_CONFIG_P1,
260*61046927SAndroid Build Coastguard Worker
261*61046927SAndroid Build Coastguard Worker /* A V3D 4.x texture config parameter. The high 8 bits will be
262*61046927SAndroid Build Coastguard Worker * which texture or sampler is being sampled, and the driver must
263*61046927SAndroid Build Coastguard Worker * replace the address field with the appropriate address.
264*61046927SAndroid Build Coastguard Worker */
265*61046927SAndroid Build Coastguard Worker QUNIFORM_TMU_CONFIG_P0,
266*61046927SAndroid Build Coastguard Worker QUNIFORM_TMU_CONFIG_P1,
267*61046927SAndroid Build Coastguard Worker
268*61046927SAndroid Build Coastguard Worker QUNIFORM_IMAGE_TMU_CONFIG_P0,
269*61046927SAndroid Build Coastguard Worker
270*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_FIRST_LEVEL,
271*61046927SAndroid Build Coastguard Worker
272*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_WIDTH,
273*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_HEIGHT,
274*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_DEPTH,
275*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_ARRAY_SIZE,
276*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_LEVELS,
277*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXTURE_SAMPLES,
278*61046927SAndroid Build Coastguard Worker
279*61046927SAndroid Build Coastguard Worker QUNIFORM_UBO_ADDR,
280*61046927SAndroid Build Coastguard Worker
281*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXRECT_SCALE_X,
282*61046927SAndroid Build Coastguard Worker QUNIFORM_TEXRECT_SCALE_Y,
283*61046927SAndroid Build Coastguard Worker
284*61046927SAndroid Build Coastguard Worker /* Returns the base offset of the SSBO given by the data value. */
285*61046927SAndroid Build Coastguard Worker QUNIFORM_SSBO_OFFSET,
286*61046927SAndroid Build Coastguard Worker
287*61046927SAndroid Build Coastguard Worker /* Returns the size of the SSBO or UBO given by the data value. */
288*61046927SAndroid Build Coastguard Worker QUNIFORM_GET_SSBO_SIZE,
289*61046927SAndroid Build Coastguard Worker QUNIFORM_GET_UBO_SIZE,
290*61046927SAndroid Build Coastguard Worker
291*61046927SAndroid Build Coastguard Worker /* Sizes (in pixels) of a shader image given by the data value. */
292*61046927SAndroid Build Coastguard Worker QUNIFORM_IMAGE_WIDTH,
293*61046927SAndroid Build Coastguard Worker QUNIFORM_IMAGE_HEIGHT,
294*61046927SAndroid Build Coastguard Worker QUNIFORM_IMAGE_DEPTH,
295*61046927SAndroid Build Coastguard Worker QUNIFORM_IMAGE_ARRAY_SIZE,
296*61046927SAndroid Build Coastguard Worker
297*61046927SAndroid Build Coastguard Worker QUNIFORM_LINE_WIDTH,
298*61046927SAndroid Build Coastguard Worker
299*61046927SAndroid Build Coastguard Worker /* The line width sent to hardware. This includes the expanded width
300*61046927SAndroid Build Coastguard Worker * when anti-aliasing is enabled.
301*61046927SAndroid Build Coastguard Worker */
302*61046927SAndroid Build Coastguard Worker QUNIFORM_AA_LINE_WIDTH,
303*61046927SAndroid Build Coastguard Worker
304*61046927SAndroid Build Coastguard Worker /* Number of workgroups passed to glDispatchCompute in the dimension
305*61046927SAndroid Build Coastguard Worker * selected by the data value.
306*61046927SAndroid Build Coastguard Worker */
307*61046927SAndroid Build Coastguard Worker QUNIFORM_NUM_WORK_GROUPS,
308*61046927SAndroid Build Coastguard Worker
309*61046927SAndroid Build Coastguard Worker /* Base workgroup offset passed to vkCmdDispatchBase in the dimension
310*61046927SAndroid Build Coastguard Worker * selected by the data value.
311*61046927SAndroid Build Coastguard Worker */
312*61046927SAndroid Build Coastguard Worker QUNIFORM_WORK_GROUP_BASE,
313*61046927SAndroid Build Coastguard Worker
314*61046927SAndroid Build Coastguard Worker /* Workgroup size for variable workgroup support */
315*61046927SAndroid Build Coastguard Worker QUNIFORM_WORK_GROUP_SIZE,
316*61046927SAndroid Build Coastguard Worker
317*61046927SAndroid Build Coastguard Worker /**
318*61046927SAndroid Build Coastguard Worker * Returns the the offset of the scratch buffer for register spilling.
319*61046927SAndroid Build Coastguard Worker */
320*61046927SAndroid Build Coastguard Worker QUNIFORM_SPILL_OFFSET,
321*61046927SAndroid Build Coastguard Worker QUNIFORM_SPILL_SIZE_PER_THREAD,
322*61046927SAndroid Build Coastguard Worker
323*61046927SAndroid Build Coastguard Worker /**
324*61046927SAndroid Build Coastguard Worker * Returns the offset of the shared memory for compute shaders.
325*61046927SAndroid Build Coastguard Worker *
326*61046927SAndroid Build Coastguard Worker * This will be accessed using TMU general memory operations, so the
327*61046927SAndroid Build Coastguard Worker * L2T cache will effectively be the shared memory area.
328*61046927SAndroid Build Coastguard Worker */
329*61046927SAndroid Build Coastguard Worker QUNIFORM_SHARED_OFFSET,
330*61046927SAndroid Build Coastguard Worker
331*61046927SAndroid Build Coastguard Worker /**
332*61046927SAndroid Build Coastguard Worker * OpenCL variable shared memory
333*61046927SAndroid Build Coastguard Worker *
334*61046927SAndroid Build Coastguard Worker * This will only be used when the shader declares variable_shared_memory.
335*61046927SAndroid Build Coastguard Worker */
336*61046927SAndroid Build Coastguard Worker QUNIFORM_SHARED_SIZE,
337*61046927SAndroid Build Coastguard Worker
338*61046927SAndroid Build Coastguard Worker /**
339*61046927SAndroid Build Coastguard Worker * Returns the number of layers in the framebuffer.
340*61046927SAndroid Build Coastguard Worker *
341*61046927SAndroid Build Coastguard Worker * This is used to cap gl_Layer in geometry shaders to avoid
342*61046927SAndroid Build Coastguard Worker * out-of-bounds accesses into the tile state during binning.
343*61046927SAndroid Build Coastguard Worker */
344*61046927SAndroid Build Coastguard Worker QUNIFORM_FB_LAYERS,
345*61046927SAndroid Build Coastguard Worker
346*61046927SAndroid Build Coastguard Worker /**
347*61046927SAndroid Build Coastguard Worker * Current value of gl_ViewIndex for Multiview rendering.
348*61046927SAndroid Build Coastguard Worker */
349*61046927SAndroid Build Coastguard Worker QUNIFORM_VIEW_INDEX,
350*61046927SAndroid Build Coastguard Worker
351*61046927SAndroid Build Coastguard Worker /**
352*61046927SAndroid Build Coastguard Worker * Inline uniform buffers
353*61046927SAndroid Build Coastguard Worker */
354*61046927SAndroid Build Coastguard Worker QUNIFORM_INLINE_UBO_0,
355*61046927SAndroid Build Coastguard Worker QUNIFORM_INLINE_UBO_1,
356*61046927SAndroid Build Coastguard Worker QUNIFORM_INLINE_UBO_2,
357*61046927SAndroid Build Coastguard Worker QUNIFORM_INLINE_UBO_3,
358*61046927SAndroid Build Coastguard Worker
359*61046927SAndroid Build Coastguard Worker /**
360*61046927SAndroid Build Coastguard Worker * Current value of DrawIndex for Multidraw
361*61046927SAndroid Build Coastguard Worker */
362*61046927SAndroid Build Coastguard Worker QUNIFORM_DRAW_ID,
363*61046927SAndroid Build Coastguard Worker };
364*61046927SAndroid Build Coastguard Worker
v3d_unit_data_create(uint32_t unit,uint32_t value)365*61046927SAndroid Build Coastguard Worker static inline uint32_t v3d_unit_data_create(uint32_t unit, uint32_t value)
366*61046927SAndroid Build Coastguard Worker {
367*61046927SAndroid Build Coastguard Worker assert(value < (1 << 24));
368*61046927SAndroid Build Coastguard Worker return unit << 24 | value;
369*61046927SAndroid Build Coastguard Worker }
370*61046927SAndroid Build Coastguard Worker
v3d_unit_data_get_unit(uint32_t data)371*61046927SAndroid Build Coastguard Worker static inline uint32_t v3d_unit_data_get_unit(uint32_t data)
372*61046927SAndroid Build Coastguard Worker {
373*61046927SAndroid Build Coastguard Worker return data >> 24;
374*61046927SAndroid Build Coastguard Worker }
375*61046927SAndroid Build Coastguard Worker
v3d_unit_data_get_offset(uint32_t data)376*61046927SAndroid Build Coastguard Worker static inline uint32_t v3d_unit_data_get_offset(uint32_t data)
377*61046927SAndroid Build Coastguard Worker {
378*61046927SAndroid Build Coastguard Worker return data & 0xffffff;
379*61046927SAndroid Build Coastguard Worker }
380*61046927SAndroid Build Coastguard Worker
381*61046927SAndroid Build Coastguard Worker struct v3d_varying_slot {
382*61046927SAndroid Build Coastguard Worker uint8_t slot_and_component;
383*61046927SAndroid Build Coastguard Worker };
384*61046927SAndroid Build Coastguard Worker
385*61046927SAndroid Build Coastguard Worker static inline struct v3d_varying_slot
v3d_slot_from_slot_and_component(uint8_t slot,uint8_t component)386*61046927SAndroid Build Coastguard Worker v3d_slot_from_slot_and_component(uint8_t slot, uint8_t component)
387*61046927SAndroid Build Coastguard Worker {
388*61046927SAndroid Build Coastguard Worker assert(slot < 255 / 4);
389*61046927SAndroid Build Coastguard Worker return (struct v3d_varying_slot){ (slot << 2) + component };
390*61046927SAndroid Build Coastguard Worker }
391*61046927SAndroid Build Coastguard Worker
v3d_slot_get_slot(struct v3d_varying_slot slot)392*61046927SAndroid Build Coastguard Worker static inline uint8_t v3d_slot_get_slot(struct v3d_varying_slot slot)
393*61046927SAndroid Build Coastguard Worker {
394*61046927SAndroid Build Coastguard Worker return slot.slot_and_component >> 2;
395*61046927SAndroid Build Coastguard Worker }
396*61046927SAndroid Build Coastguard Worker
v3d_slot_get_component(struct v3d_varying_slot slot)397*61046927SAndroid Build Coastguard Worker static inline uint8_t v3d_slot_get_component(struct v3d_varying_slot slot)
398*61046927SAndroid Build Coastguard Worker {
399*61046927SAndroid Build Coastguard Worker return slot.slot_and_component & 3;
400*61046927SAndroid Build Coastguard Worker }
401*61046927SAndroid Build Coastguard Worker
402*61046927SAndroid Build Coastguard Worker struct v3d_key {
403*61046927SAndroid Build Coastguard Worker struct {
404*61046927SAndroid Build Coastguard Worker uint8_t swizzle[4];
405*61046927SAndroid Build Coastguard Worker } tex[V3D_MAX_TEXTURE_SAMPLERS];
406*61046927SAndroid Build Coastguard Worker struct {
407*61046927SAndroid Build Coastguard Worker uint8_t return_size;
408*61046927SAndroid Build Coastguard Worker uint8_t return_channels;
409*61046927SAndroid Build Coastguard Worker } sampler[V3D_MAX_TEXTURE_SAMPLERS];
410*61046927SAndroid Build Coastguard Worker
411*61046927SAndroid Build Coastguard Worker uint8_t num_tex_used;
412*61046927SAndroid Build Coastguard Worker uint8_t num_samplers_used;
413*61046927SAndroid Build Coastguard Worker uint8_t ucp_enables;
414*61046927SAndroid Build Coastguard Worker bool is_last_geometry_stage;
415*61046927SAndroid Build Coastguard Worker bool robust_uniform_access;
416*61046927SAndroid Build Coastguard Worker bool robust_storage_access;
417*61046927SAndroid Build Coastguard Worker bool robust_image_access;
418*61046927SAndroid Build Coastguard Worker };
419*61046927SAndroid Build Coastguard Worker
420*61046927SAndroid Build Coastguard Worker struct v3d_fs_key {
421*61046927SAndroid Build Coastguard Worker struct v3d_key base;
422*61046927SAndroid Build Coastguard Worker bool is_points;
423*61046927SAndroid Build Coastguard Worker bool is_lines;
424*61046927SAndroid Build Coastguard Worker bool line_smoothing;
425*61046927SAndroid Build Coastguard Worker bool point_coord_upper_left;
426*61046927SAndroid Build Coastguard Worker bool msaa;
427*61046927SAndroid Build Coastguard Worker bool sample_alpha_to_coverage;
428*61046927SAndroid Build Coastguard Worker bool sample_alpha_to_one;
429*61046927SAndroid Build Coastguard Worker /* Mask of which color render targets are present. */
430*61046927SAndroid Build Coastguard Worker uint8_t cbufs;
431*61046927SAndroid Build Coastguard Worker uint8_t swap_color_rb;
432*61046927SAndroid Build Coastguard Worker /* Mask of which render targets need to be written as 32-bit floats */
433*61046927SAndroid Build Coastguard Worker uint8_t f32_color_rb;
434*61046927SAndroid Build Coastguard Worker /* Masks of which render targets need to be written as ints/uints.
435*61046927SAndroid Build Coastguard Worker * Used by gallium to work around lost information in TGSI.
436*61046927SAndroid Build Coastguard Worker */
437*61046927SAndroid Build Coastguard Worker uint8_t int_color_rb;
438*61046927SAndroid Build Coastguard Worker uint8_t uint_color_rb;
439*61046927SAndroid Build Coastguard Worker
440*61046927SAndroid Build Coastguard Worker /* Color format information per render target. Only set when logic
441*61046927SAndroid Build Coastguard Worker * operations are enabled.
442*61046927SAndroid Build Coastguard Worker */
443*61046927SAndroid Build Coastguard Worker struct {
444*61046927SAndroid Build Coastguard Worker enum pipe_format format;
445*61046927SAndroid Build Coastguard Worker uint8_t swizzle[4];
446*61046927SAndroid Build Coastguard Worker } color_fmt[V3D_MAX_DRAW_BUFFERS];
447*61046927SAndroid Build Coastguard Worker
448*61046927SAndroid Build Coastguard Worker enum pipe_logicop logicop_func;
449*61046927SAndroid Build Coastguard Worker uint32_t point_sprite_mask;
450*61046927SAndroid Build Coastguard Worker
451*61046927SAndroid Build Coastguard Worker /* If the fragment shader reads gl_PrimitiveID then we have 2 scenarios:
452*61046927SAndroid Build Coastguard Worker *
453*61046927SAndroid Build Coastguard Worker * - If there is a geometry shader, then gl_PrimitiveID must be written
454*61046927SAndroid Build Coastguard Worker * by it and the fragment shader loads it as a regular explicit input
455*61046927SAndroid Build Coastguard Worker * varying. This is the only valid use case in GLES 3.1.
456*61046927SAndroid Build Coastguard Worker *
457*61046927SAndroid Build Coastguard Worker * - If there is not a geometry shader (allowed since GLES 3.2 and
458*61046927SAndroid Build Coastguard Worker * Vulkan 1.0), then gl_PrimitiveID must be implicitly written by
459*61046927SAndroid Build Coastguard Worker * hardware and is considered an implicit input varying in the
460*61046927SAndroid Build Coastguard Worker * fragment shader.
461*61046927SAndroid Build Coastguard Worker */
462*61046927SAndroid Build Coastguard Worker bool has_gs;
463*61046927SAndroid Build Coastguard Worker };
464*61046927SAndroid Build Coastguard Worker
465*61046927SAndroid Build Coastguard Worker struct v3d_gs_key {
466*61046927SAndroid Build Coastguard Worker struct v3d_key base;
467*61046927SAndroid Build Coastguard Worker
468*61046927SAndroid Build Coastguard Worker struct v3d_varying_slot used_outputs[V3D_MAX_FS_INPUTS];
469*61046927SAndroid Build Coastguard Worker uint8_t num_used_outputs;
470*61046927SAndroid Build Coastguard Worker
471*61046927SAndroid Build Coastguard Worker bool is_coord;
472*61046927SAndroid Build Coastguard Worker bool per_vertex_point_size;
473*61046927SAndroid Build Coastguard Worker };
474*61046927SAndroid Build Coastguard Worker
475*61046927SAndroid Build Coastguard Worker struct v3d_vs_key {
476*61046927SAndroid Build Coastguard Worker struct v3d_key base;
477*61046927SAndroid Build Coastguard Worker
478*61046927SAndroid Build Coastguard Worker struct v3d_varying_slot used_outputs[V3D_MAX_ANY_STAGE_INPUTS];
479*61046927SAndroid Build Coastguard Worker uint8_t num_used_outputs;
480*61046927SAndroid Build Coastguard Worker
481*61046927SAndroid Build Coastguard Worker /* A bit-mask indicating if we need to swap the R/B channels for
482*61046927SAndroid Build Coastguard Worker * vertex attributes. Since the hardware doesn't provide any
483*61046927SAndroid Build Coastguard Worker * means to swizzle vertex attributes we need to do it in the shader.
484*61046927SAndroid Build Coastguard Worker */
485*61046927SAndroid Build Coastguard Worker uint32_t va_swap_rb_mask;
486*61046927SAndroid Build Coastguard Worker
487*61046927SAndroid Build Coastguard Worker bool is_coord;
488*61046927SAndroid Build Coastguard Worker bool per_vertex_point_size;
489*61046927SAndroid Build Coastguard Worker bool clamp_color;
490*61046927SAndroid Build Coastguard Worker };
491*61046927SAndroid Build Coastguard Worker
492*61046927SAndroid Build Coastguard Worker /** A basic block of VIR instructions. */
493*61046927SAndroid Build Coastguard Worker struct qblock {
494*61046927SAndroid Build Coastguard Worker struct list_head link;
495*61046927SAndroid Build Coastguard Worker
496*61046927SAndroid Build Coastguard Worker struct list_head instructions;
497*61046927SAndroid Build Coastguard Worker
498*61046927SAndroid Build Coastguard Worker struct set *predecessors;
499*61046927SAndroid Build Coastguard Worker struct qblock *successors[2];
500*61046927SAndroid Build Coastguard Worker
501*61046927SAndroid Build Coastguard Worker int index;
502*61046927SAndroid Build Coastguard Worker
503*61046927SAndroid Build Coastguard Worker /* Instruction IPs for the first and last instruction of the block.
504*61046927SAndroid Build Coastguard Worker * Set by qpu_schedule.c.
505*61046927SAndroid Build Coastguard Worker */
506*61046927SAndroid Build Coastguard Worker uint32_t start_qpu_ip;
507*61046927SAndroid Build Coastguard Worker uint32_t end_qpu_ip;
508*61046927SAndroid Build Coastguard Worker
509*61046927SAndroid Build Coastguard Worker /* Instruction IP for the branch instruction of the block. Set by
510*61046927SAndroid Build Coastguard Worker * qpu_schedule.c.
511*61046927SAndroid Build Coastguard Worker */
512*61046927SAndroid Build Coastguard Worker uint32_t branch_qpu_ip;
513*61046927SAndroid Build Coastguard Worker
514*61046927SAndroid Build Coastguard Worker /** Offset within the uniform stream at the start of the block. */
515*61046927SAndroid Build Coastguard Worker uint32_t start_uniform;
516*61046927SAndroid Build Coastguard Worker /** Offset within the uniform stream of the branch instruction */
517*61046927SAndroid Build Coastguard Worker uint32_t branch_uniform;
518*61046927SAndroid Build Coastguard Worker
519*61046927SAndroid Build Coastguard Worker /**
520*61046927SAndroid Build Coastguard Worker * Has the terminating branch of this block already been emitted
521*61046927SAndroid Build Coastguard Worker * by a break or continue?
522*61046927SAndroid Build Coastguard Worker */
523*61046927SAndroid Build Coastguard Worker bool branch_emitted;
524*61046927SAndroid Build Coastguard Worker
525*61046927SAndroid Build Coastguard Worker /** @{ used by v3d_vir_live_variables.c */
526*61046927SAndroid Build Coastguard Worker BITSET_WORD *def;
527*61046927SAndroid Build Coastguard Worker BITSET_WORD *defin;
528*61046927SAndroid Build Coastguard Worker BITSET_WORD *defout;
529*61046927SAndroid Build Coastguard Worker BITSET_WORD *use;
530*61046927SAndroid Build Coastguard Worker BITSET_WORD *live_in;
531*61046927SAndroid Build Coastguard Worker BITSET_WORD *live_out;
532*61046927SAndroid Build Coastguard Worker int start_ip, end_ip;
533*61046927SAndroid Build Coastguard Worker /** @} */
534*61046927SAndroid Build Coastguard Worker };
535*61046927SAndroid Build Coastguard Worker
536*61046927SAndroid Build Coastguard Worker /** Which util/list.h add mode we should use when inserting an instruction. */
537*61046927SAndroid Build Coastguard Worker enum vir_cursor_mode {
538*61046927SAndroid Build Coastguard Worker vir_cursor_add,
539*61046927SAndroid Build Coastguard Worker vir_cursor_addtail,
540*61046927SAndroid Build Coastguard Worker };
541*61046927SAndroid Build Coastguard Worker
542*61046927SAndroid Build Coastguard Worker /**
543*61046927SAndroid Build Coastguard Worker * Tracking structure for where new instructions should be inserted. Create
544*61046927SAndroid Build Coastguard Worker * with one of the vir_after_inst()-style helper functions.
545*61046927SAndroid Build Coastguard Worker *
546*61046927SAndroid Build Coastguard Worker * This does not protect against removal of the block or instruction, so we
547*61046927SAndroid Build Coastguard Worker * have an assert in instruction removal to try to catch it.
548*61046927SAndroid Build Coastguard Worker */
549*61046927SAndroid Build Coastguard Worker struct vir_cursor {
550*61046927SAndroid Build Coastguard Worker enum vir_cursor_mode mode;
551*61046927SAndroid Build Coastguard Worker struct list_head *link;
552*61046927SAndroid Build Coastguard Worker };
553*61046927SAndroid Build Coastguard Worker
554*61046927SAndroid Build Coastguard Worker static inline struct vir_cursor
vir_before_inst(struct qinst * inst)555*61046927SAndroid Build Coastguard Worker vir_before_inst(struct qinst *inst)
556*61046927SAndroid Build Coastguard Worker {
557*61046927SAndroid Build Coastguard Worker return (struct vir_cursor){ vir_cursor_addtail, &inst->link };
558*61046927SAndroid Build Coastguard Worker }
559*61046927SAndroid Build Coastguard Worker
560*61046927SAndroid Build Coastguard Worker static inline struct vir_cursor
vir_after_inst(struct qinst * inst)561*61046927SAndroid Build Coastguard Worker vir_after_inst(struct qinst *inst)
562*61046927SAndroid Build Coastguard Worker {
563*61046927SAndroid Build Coastguard Worker return (struct vir_cursor){ vir_cursor_add, &inst->link };
564*61046927SAndroid Build Coastguard Worker }
565*61046927SAndroid Build Coastguard Worker
566*61046927SAndroid Build Coastguard Worker static inline struct vir_cursor
vir_before_block(struct qblock * block)567*61046927SAndroid Build Coastguard Worker vir_before_block(struct qblock *block)
568*61046927SAndroid Build Coastguard Worker {
569*61046927SAndroid Build Coastguard Worker return (struct vir_cursor){ vir_cursor_add, &block->instructions };
570*61046927SAndroid Build Coastguard Worker }
571*61046927SAndroid Build Coastguard Worker
572*61046927SAndroid Build Coastguard Worker static inline struct vir_cursor
vir_after_block(struct qblock * block)573*61046927SAndroid Build Coastguard Worker vir_after_block(struct qblock *block)
574*61046927SAndroid Build Coastguard Worker {
575*61046927SAndroid Build Coastguard Worker return (struct vir_cursor){ vir_cursor_addtail, &block->instructions };
576*61046927SAndroid Build Coastguard Worker }
577*61046927SAndroid Build Coastguard Worker
578*61046927SAndroid Build Coastguard Worker enum v3d_compilation_result {
579*61046927SAndroid Build Coastguard Worker V3D_COMPILATION_SUCCEEDED,
580*61046927SAndroid Build Coastguard Worker V3D_COMPILATION_FAILED_REGISTER_ALLOCATION,
581*61046927SAndroid Build Coastguard Worker V3D_COMPILATION_FAILED,
582*61046927SAndroid Build Coastguard Worker };
583*61046927SAndroid Build Coastguard Worker
584*61046927SAndroid Build Coastguard Worker /**
585*61046927SAndroid Build Coastguard Worker * Compiler state saved across compiler invocations, for any expensive global
586*61046927SAndroid Build Coastguard Worker * setup.
587*61046927SAndroid Build Coastguard Worker */
588*61046927SAndroid Build Coastguard Worker struct v3d_compiler {
589*61046927SAndroid Build Coastguard Worker const struct v3d_device_info *devinfo;
590*61046927SAndroid Build Coastguard Worker uint32_t max_inline_uniform_buffers;
591*61046927SAndroid Build Coastguard Worker struct ra_regs *regs;
592*61046927SAndroid Build Coastguard Worker struct ra_class *reg_class_any[3];
593*61046927SAndroid Build Coastguard Worker struct ra_class *reg_class_r5[3];
594*61046927SAndroid Build Coastguard Worker struct ra_class *reg_class_phys[3];
595*61046927SAndroid Build Coastguard Worker struct ra_class *reg_class_phys_or_acc[3];
596*61046927SAndroid Build Coastguard Worker };
597*61046927SAndroid Build Coastguard Worker
598*61046927SAndroid Build Coastguard Worker /**
599*61046927SAndroid Build Coastguard Worker * This holds partially interpolated inputs as provided by hardware
600*61046927SAndroid Build Coastguard Worker * (The Vp = A*(x - x0) + B*(y - y0) term), as well as the C coefficient
601*61046927SAndroid Build Coastguard Worker * required to compute the final interpolated value.
602*61046927SAndroid Build Coastguard Worker */
603*61046927SAndroid Build Coastguard Worker struct v3d_interp_input {
604*61046927SAndroid Build Coastguard Worker struct qreg vp;
605*61046927SAndroid Build Coastguard Worker struct qreg C;
606*61046927SAndroid Build Coastguard Worker unsigned mode; /* interpolation mode */
607*61046927SAndroid Build Coastguard Worker };
608*61046927SAndroid Build Coastguard Worker
609*61046927SAndroid Build Coastguard Worker struct v3d_ra_node_info {
610*61046927SAndroid Build Coastguard Worker struct {
611*61046927SAndroid Build Coastguard Worker uint32_t priority;
612*61046927SAndroid Build Coastguard Worker uint8_t class_bits;
613*61046927SAndroid Build Coastguard Worker bool is_program_end;
614*61046927SAndroid Build Coastguard Worker bool unused;
615*61046927SAndroid Build Coastguard Worker
616*61046927SAndroid Build Coastguard Worker /* If this node may have an allocation conflict with a
617*61046927SAndroid Build Coastguard Worker * payload register.
618*61046927SAndroid Build Coastguard Worker */
619*61046927SAndroid Build Coastguard Worker bool payload_conflict;
620*61046927SAndroid Build Coastguard Worker
621*61046927SAndroid Build Coastguard Worker /* V3D 7.x */
622*61046927SAndroid Build Coastguard Worker bool is_ldunif_dst;
623*61046927SAndroid Build Coastguard Worker } *info;
624*61046927SAndroid Build Coastguard Worker uint32_t alloc_count;
625*61046927SAndroid Build Coastguard Worker };
626*61046927SAndroid Build Coastguard Worker
627*61046927SAndroid Build Coastguard Worker struct v3d_compile {
628*61046927SAndroid Build Coastguard Worker const struct v3d_device_info *devinfo;
629*61046927SAndroid Build Coastguard Worker nir_shader *s;
630*61046927SAndroid Build Coastguard Worker nir_function_impl *impl;
631*61046927SAndroid Build Coastguard Worker struct exec_list *cf_node_list;
632*61046927SAndroid Build Coastguard Worker const struct v3d_compiler *compiler;
633*61046927SAndroid Build Coastguard Worker
634*61046927SAndroid Build Coastguard Worker void (*debug_output)(const char *msg,
635*61046927SAndroid Build Coastguard Worker void *debug_output_data);
636*61046927SAndroid Build Coastguard Worker void *debug_output_data;
637*61046927SAndroid Build Coastguard Worker
638*61046927SAndroid Build Coastguard Worker /**
639*61046927SAndroid Build Coastguard Worker * Mapping from nir_register * or nir_def * to array of struct
640*61046927SAndroid Build Coastguard Worker * qreg for the values.
641*61046927SAndroid Build Coastguard Worker */
642*61046927SAndroid Build Coastguard Worker struct hash_table *def_ht;
643*61046927SAndroid Build Coastguard Worker
644*61046927SAndroid Build Coastguard Worker /* For each temp, the instruction generating its value. */
645*61046927SAndroid Build Coastguard Worker struct qinst **defs;
646*61046927SAndroid Build Coastguard Worker uint32_t defs_array_size;
647*61046927SAndroid Build Coastguard Worker
648*61046927SAndroid Build Coastguard Worker /* TMU pipelining tracking */
649*61046927SAndroid Build Coastguard Worker struct {
650*61046927SAndroid Build Coastguard Worker /* NIR registers that have been updated with a TMU operation
651*61046927SAndroid Build Coastguard Worker * that has not been flushed yet.
652*61046927SAndroid Build Coastguard Worker */
653*61046927SAndroid Build Coastguard Worker struct set *outstanding_regs;
654*61046927SAndroid Build Coastguard Worker
655*61046927SAndroid Build Coastguard Worker uint32_t output_fifo_size;
656*61046927SAndroid Build Coastguard Worker
657*61046927SAndroid Build Coastguard Worker struct {
658*61046927SAndroid Build Coastguard Worker nir_def *def;
659*61046927SAndroid Build Coastguard Worker uint8_t num_components;
660*61046927SAndroid Build Coastguard Worker uint8_t component_mask;
661*61046927SAndroid Build Coastguard Worker } flush[MAX_TMU_QUEUE_SIZE];
662*61046927SAndroid Build Coastguard Worker uint32_t flush_count;
663*61046927SAndroid Build Coastguard Worker uint32_t total_count;
664*61046927SAndroid Build Coastguard Worker } tmu;
665*61046927SAndroid Build Coastguard Worker
666*61046927SAndroid Build Coastguard Worker /**
667*61046927SAndroid Build Coastguard Worker * Inputs to the shader, arranged by TGSI declaration order.
668*61046927SAndroid Build Coastguard Worker *
669*61046927SAndroid Build Coastguard Worker * Not all fragment shader QFILE_VARY reads are present in this array.
670*61046927SAndroid Build Coastguard Worker */
671*61046927SAndroid Build Coastguard Worker struct qreg *inputs;
672*61046927SAndroid Build Coastguard Worker /**
673*61046927SAndroid Build Coastguard Worker * Partially interpolated inputs to the shader.
674*61046927SAndroid Build Coastguard Worker */
675*61046927SAndroid Build Coastguard Worker struct v3d_interp_input *interp;
676*61046927SAndroid Build Coastguard Worker struct qreg *outputs;
677*61046927SAndroid Build Coastguard Worker bool msaa_per_sample_output;
678*61046927SAndroid Build Coastguard Worker struct qreg color_reads[V3D_MAX_DRAW_BUFFERS * V3D_MAX_SAMPLES * 4];
679*61046927SAndroid Build Coastguard Worker struct qreg sample_colors[V3D_MAX_DRAW_BUFFERS * V3D_MAX_SAMPLES * 4];
680*61046927SAndroid Build Coastguard Worker uint32_t inputs_array_size;
681*61046927SAndroid Build Coastguard Worker uint32_t outputs_array_size;
682*61046927SAndroid Build Coastguard Worker uint32_t uniforms_array_size;
683*61046927SAndroid Build Coastguard Worker
684*61046927SAndroid Build Coastguard Worker /* Booleans for whether the corresponding QFILE_VARY[i] is
685*61046927SAndroid Build Coastguard Worker * flat-shaded. This includes gl_FragColor flat-shading, which is
686*61046927SAndroid Build Coastguard Worker * customized based on the shademodel_flat shader key.
687*61046927SAndroid Build Coastguard Worker */
688*61046927SAndroid Build Coastguard Worker uint32_t flat_shade_flags[BITSET_WORDS(V3D_MAX_FS_INPUTS)];
689*61046927SAndroid Build Coastguard Worker
690*61046927SAndroid Build Coastguard Worker uint32_t noperspective_flags[BITSET_WORDS(V3D_MAX_FS_INPUTS)];
691*61046927SAndroid Build Coastguard Worker
692*61046927SAndroid Build Coastguard Worker uint32_t centroid_flags[BITSET_WORDS(V3D_MAX_FS_INPUTS)];
693*61046927SAndroid Build Coastguard Worker
694*61046927SAndroid Build Coastguard Worker bool uses_center_w;
695*61046927SAndroid Build Coastguard Worker bool writes_z;
696*61046927SAndroid Build Coastguard Worker bool writes_z_from_fep;
697*61046927SAndroid Build Coastguard Worker bool reads_z;
698*61046927SAndroid Build Coastguard Worker bool uses_implicit_point_line_varyings;
699*61046927SAndroid Build Coastguard Worker
700*61046927SAndroid Build Coastguard Worker /* True if a fragment shader reads gl_PrimitiveID */
701*61046927SAndroid Build Coastguard Worker bool fs_uses_primitive_id;
702*61046927SAndroid Build Coastguard Worker
703*61046927SAndroid Build Coastguard Worker /* Whether we are using the fallback scheduler. This will be set after
704*61046927SAndroid Build Coastguard Worker * register allocation has failed once.
705*61046927SAndroid Build Coastguard Worker */
706*61046927SAndroid Build Coastguard Worker bool fallback_scheduler;
707*61046927SAndroid Build Coastguard Worker
708*61046927SAndroid Build Coastguard Worker /* Disable TMU pipelining. This may increase the chances of being able
709*61046927SAndroid Build Coastguard Worker * to compile shaders with high register pressure that require to emit
710*61046927SAndroid Build Coastguard Worker * TMU spills.
711*61046927SAndroid Build Coastguard Worker */
712*61046927SAndroid Build Coastguard Worker bool disable_tmu_pipelining;
713*61046927SAndroid Build Coastguard Worker bool pipelined_any_tmu;
714*61046927SAndroid Build Coastguard Worker
715*61046927SAndroid Build Coastguard Worker /* Disable sorting of UBO loads with constant offset. This may
716*61046927SAndroid Build Coastguard Worker * increase the chances of being able to compile shaders with high
717*61046927SAndroid Build Coastguard Worker * register pressure.
718*61046927SAndroid Build Coastguard Worker */
719*61046927SAndroid Build Coastguard Worker bool disable_constant_ubo_load_sorting;
720*61046927SAndroid Build Coastguard Worker bool sorted_any_ubo_loads;
721*61046927SAndroid Build Coastguard Worker
722*61046927SAndroid Build Coastguard Worker /* Moves UBO/SSBO loads right before their first user (nir_opt_move).
723*61046927SAndroid Build Coastguard Worker * This can reduce register pressure.
724*61046927SAndroid Build Coastguard Worker */
725*61046927SAndroid Build Coastguard Worker bool move_buffer_loads;
726*61046927SAndroid Build Coastguard Worker
727*61046927SAndroid Build Coastguard Worker /* Emits ldunif for each new uniform, even if the uniform was already
728*61046927SAndroid Build Coastguard Worker * emitted in the same block. Useful to compile shaders with high
729*61046927SAndroid Build Coastguard Worker * register pressure or to disable the optimization during uniform
730*61046927SAndroid Build Coastguard Worker * spills.
731*61046927SAndroid Build Coastguard Worker */
732*61046927SAndroid Build Coastguard Worker bool disable_ldunif_opt;
733*61046927SAndroid Build Coastguard Worker
734*61046927SAndroid Build Coastguard Worker /* Disables loop unrolling to reduce register pressure. */
735*61046927SAndroid Build Coastguard Worker bool disable_loop_unrolling;
736*61046927SAndroid Build Coastguard Worker bool unrolled_any_loops;
737*61046927SAndroid Build Coastguard Worker
738*61046927SAndroid Build Coastguard Worker /* Disables nir_opt_gcm to reduce register pressure. */
739*61046927SAndroid Build Coastguard Worker bool disable_gcm;
740*61046927SAndroid Build Coastguard Worker
741*61046927SAndroid Build Coastguard Worker /* If calling nir_opt_gcm made any progress. Used to skip new rebuilds
742*61046927SAndroid Build Coastguard Worker * if possible
743*61046927SAndroid Build Coastguard Worker */
744*61046927SAndroid Build Coastguard Worker bool gcm_progress;
745*61046927SAndroid Build Coastguard Worker
746*61046927SAndroid Build Coastguard Worker /* Disables scheduling of general TMU loads (and unfiltered image load).
747*61046927SAndroid Build Coastguard Worker */
748*61046927SAndroid Build Coastguard Worker bool disable_general_tmu_sched;
749*61046927SAndroid Build Coastguard Worker bool has_general_tmu_load;
750*61046927SAndroid Build Coastguard Worker
751*61046927SAndroid Build Coastguard Worker /* Minimum number of threads we are willing to use to register allocate
752*61046927SAndroid Build Coastguard Worker * a shader with the current compilation strategy. This only prevents
753*61046927SAndroid Build Coastguard Worker * us from lowering the thread count to register allocate successfully,
754*61046927SAndroid Build Coastguard Worker * which can be useful when we prefer doing other changes to the
755*61046927SAndroid Build Coastguard Worker * compilation strategy before dropping thread count.
756*61046927SAndroid Build Coastguard Worker */
757*61046927SAndroid Build Coastguard Worker uint32_t min_threads_for_reg_alloc;
758*61046927SAndroid Build Coastguard Worker
759*61046927SAndroid Build Coastguard Worker /* Whether TMU spills are allowed. If this is disabled it may cause
760*61046927SAndroid Build Coastguard Worker * register allocation to fail. We set this to favor other compilation
761*61046927SAndroid Build Coastguard Worker * strategies that can reduce register pressure and hopefully reduce or
762*61046927SAndroid Build Coastguard Worker * eliminate TMU spills in the shader.
763*61046927SAndroid Build Coastguard Worker */
764*61046927SAndroid Build Coastguard Worker uint32_t max_tmu_spills;
765*61046927SAndroid Build Coastguard Worker
766*61046927SAndroid Build Coastguard Worker uint32_t compile_strategy_idx;
767*61046927SAndroid Build Coastguard Worker
768*61046927SAndroid Build Coastguard Worker /* The UBO index and block used with the last unifa load, as well as the
769*61046927SAndroid Build Coastguard Worker * current unifa offset *after* emitting that load. This is used to skip
770*61046927SAndroid Build Coastguard Worker * unifa writes (and their 3 delay slot) when the next UBO load reads
771*61046927SAndroid Build Coastguard Worker * right after the previous one in the same block.
772*61046927SAndroid Build Coastguard Worker */
773*61046927SAndroid Build Coastguard Worker struct qblock *current_unifa_block;
774*61046927SAndroid Build Coastguard Worker int32_t current_unifa_index;
775*61046927SAndroid Build Coastguard Worker uint32_t current_unifa_offset;
776*61046927SAndroid Build Coastguard Worker bool current_unifa_is_ubo;
777*61046927SAndroid Build Coastguard Worker
778*61046927SAndroid Build Coastguard Worker /* State for whether we're executing on each channel currently. 0 if
779*61046927SAndroid Build Coastguard Worker * yes, otherwise a block number + 1 that the channel jumped to.
780*61046927SAndroid Build Coastguard Worker */
781*61046927SAndroid Build Coastguard Worker struct qreg execute;
782*61046927SAndroid Build Coastguard Worker bool in_control_flow;
783*61046927SAndroid Build Coastguard Worker
784*61046927SAndroid Build Coastguard Worker struct qreg line_x, point_x, point_y, primitive_id;
785*61046927SAndroid Build Coastguard Worker
786*61046927SAndroid Build Coastguard Worker /**
787*61046927SAndroid Build Coastguard Worker * Instance ID, which comes in before the vertex attribute payload if
788*61046927SAndroid Build Coastguard Worker * the shader record requests it.
789*61046927SAndroid Build Coastguard Worker */
790*61046927SAndroid Build Coastguard Worker struct qreg iid;
791*61046927SAndroid Build Coastguard Worker
792*61046927SAndroid Build Coastguard Worker /**
793*61046927SAndroid Build Coastguard Worker * Base Instance ID, which comes in before the vertex attribute payload
794*61046927SAndroid Build Coastguard Worker * (after Instance ID) if the shader record requests it.
795*61046927SAndroid Build Coastguard Worker */
796*61046927SAndroid Build Coastguard Worker struct qreg biid;
797*61046927SAndroid Build Coastguard Worker
798*61046927SAndroid Build Coastguard Worker /**
799*61046927SAndroid Build Coastguard Worker * Vertex ID, which comes in before the vertex attribute payload
800*61046927SAndroid Build Coastguard Worker * (after Base Instance) if the shader record requests it.
801*61046927SAndroid Build Coastguard Worker */
802*61046927SAndroid Build Coastguard Worker struct qreg vid;
803*61046927SAndroid Build Coastguard Worker
804*61046927SAndroid Build Coastguard Worker /* Fragment shader payload regs. */
805*61046927SAndroid Build Coastguard Worker struct qreg payload_w, payload_w_centroid, payload_z;
806*61046927SAndroid Build Coastguard Worker
807*61046927SAndroid Build Coastguard Worker struct qreg cs_payload[2];
808*61046927SAndroid Build Coastguard Worker struct qreg cs_shared_offset;
809*61046927SAndroid Build Coastguard Worker int local_invocation_index_bits;
810*61046927SAndroid Build Coastguard Worker
811*61046927SAndroid Build Coastguard Worker /* Starting value of the sample mask in a fragment shader. We use
812*61046927SAndroid Build Coastguard Worker * this to identify lanes that have been terminated/discarded.
813*61046927SAndroid Build Coastguard Worker */
814*61046927SAndroid Build Coastguard Worker struct qreg start_msf;
815*61046927SAndroid Build Coastguard Worker
816*61046927SAndroid Build Coastguard Worker /* If the shader uses subgroup functionality */
817*61046927SAndroid Build Coastguard Worker bool has_subgroups;
818*61046927SAndroid Build Coastguard Worker
819*61046927SAndroid Build Coastguard Worker uint8_t vattr_sizes[V3D_MAX_VS_INPUTS / 4];
820*61046927SAndroid Build Coastguard Worker uint32_t vpm_output_size;
821*61046927SAndroid Build Coastguard Worker
822*61046927SAndroid Build Coastguard Worker /* Size in bytes of registers that have been spilled. This is how much
823*61046927SAndroid Build Coastguard Worker * space needs to be available in the spill BO per thread per QPU.
824*61046927SAndroid Build Coastguard Worker */
825*61046927SAndroid Build Coastguard Worker uint32_t spill_size;
826*61046927SAndroid Build Coastguard Worker /* Shader-db stats */
827*61046927SAndroid Build Coastguard Worker uint32_t spills, fills, loops;
828*61046927SAndroid Build Coastguard Worker
829*61046927SAndroid Build Coastguard Worker /* Whether we are in the process of spilling registers for
830*61046927SAndroid Build Coastguard Worker * register allocation
831*61046927SAndroid Build Coastguard Worker */
832*61046927SAndroid Build Coastguard Worker bool spilling;
833*61046927SAndroid Build Coastguard Worker
834*61046927SAndroid Build Coastguard Worker /**
835*61046927SAndroid Build Coastguard Worker * Register spilling's per-thread base address, shared between each
836*61046927SAndroid Build Coastguard Worker * spill/fill's addressing calculations (also used for scratch
837*61046927SAndroid Build Coastguard Worker * access).
838*61046927SAndroid Build Coastguard Worker */
839*61046927SAndroid Build Coastguard Worker struct qreg spill_base;
840*61046927SAndroid Build Coastguard Worker
841*61046927SAndroid Build Coastguard Worker /* Bit vector of which temps may be spilled */
842*61046927SAndroid Build Coastguard Worker BITSET_WORD *spillable;
843*61046927SAndroid Build Coastguard Worker
844*61046927SAndroid Build Coastguard Worker /* Used during register allocation */
845*61046927SAndroid Build Coastguard Worker int thread_index;
846*61046927SAndroid Build Coastguard Worker struct v3d_ra_node_info nodes;
847*61046927SAndroid Build Coastguard Worker struct ra_graph *g;
848*61046927SAndroid Build Coastguard Worker
849*61046927SAndroid Build Coastguard Worker /**
850*61046927SAndroid Build Coastguard Worker * Array of the VARYING_SLOT_* of all FS QFILE_VARY reads.
851*61046927SAndroid Build Coastguard Worker *
852*61046927SAndroid Build Coastguard Worker * This includes those that aren't part of the VPM varyings, like
853*61046927SAndroid Build Coastguard Worker * point/line coordinates.
854*61046927SAndroid Build Coastguard Worker */
855*61046927SAndroid Build Coastguard Worker struct v3d_varying_slot input_slots[V3D_MAX_FS_INPUTS];
856*61046927SAndroid Build Coastguard Worker
857*61046927SAndroid Build Coastguard Worker /**
858*61046927SAndroid Build Coastguard Worker * An entry per outputs[] in the VS indicating what the VARYING_SLOT_*
859*61046927SAndroid Build Coastguard Worker * of the output is. Used to emit from the VS in the order that the
860*61046927SAndroid Build Coastguard Worker * FS needs.
861*61046927SAndroid Build Coastguard Worker */
862*61046927SAndroid Build Coastguard Worker struct v3d_varying_slot *output_slots;
863*61046927SAndroid Build Coastguard Worker
864*61046927SAndroid Build Coastguard Worker struct pipe_shader_state *shader_state;
865*61046927SAndroid Build Coastguard Worker struct v3d_key *key;
866*61046927SAndroid Build Coastguard Worker struct v3d_fs_key *fs_key;
867*61046927SAndroid Build Coastguard Worker struct v3d_gs_key *gs_key;
868*61046927SAndroid Build Coastguard Worker struct v3d_vs_key *vs_key;
869*61046927SAndroid Build Coastguard Worker
870*61046927SAndroid Build Coastguard Worker /* Live ranges of temps. */
871*61046927SAndroid Build Coastguard Worker int *temp_start, *temp_end;
872*61046927SAndroid Build Coastguard Worker bool live_intervals_valid;
873*61046927SAndroid Build Coastguard Worker
874*61046927SAndroid Build Coastguard Worker uint32_t *uniform_data;
875*61046927SAndroid Build Coastguard Worker enum quniform_contents *uniform_contents;
876*61046927SAndroid Build Coastguard Worker uint32_t uniform_array_size;
877*61046927SAndroid Build Coastguard Worker uint32_t num_uniforms;
878*61046927SAndroid Build Coastguard Worker uint32_t output_position_index;
879*61046927SAndroid Build Coastguard Worker nir_variable *output_color_var[V3D_MAX_DRAW_BUFFERS];
880*61046927SAndroid Build Coastguard Worker uint32_t output_sample_mask_index;
881*61046927SAndroid Build Coastguard Worker
882*61046927SAndroid Build Coastguard Worker struct qreg undef;
883*61046927SAndroid Build Coastguard Worker uint32_t num_temps;
884*61046927SAndroid Build Coastguard Worker /* Number of temps in the program right before we spill a new temp. We
885*61046927SAndroid Build Coastguard Worker * use this to know which temps existed before a spill and which were
886*61046927SAndroid Build Coastguard Worker * added with the spill itself.
887*61046927SAndroid Build Coastguard Worker */
888*61046927SAndroid Build Coastguard Worker uint32_t spill_start_num_temps;
889*61046927SAndroid Build Coastguard Worker
890*61046927SAndroid Build Coastguard Worker struct vir_cursor cursor;
891*61046927SAndroid Build Coastguard Worker struct list_head blocks;
892*61046927SAndroid Build Coastguard Worker int next_block_index;
893*61046927SAndroid Build Coastguard Worker struct qblock *cur_block;
894*61046927SAndroid Build Coastguard Worker struct qblock *loop_cont_block;
895*61046927SAndroid Build Coastguard Worker struct qblock *loop_break_block;
896*61046927SAndroid Build Coastguard Worker /**
897*61046927SAndroid Build Coastguard Worker * Which temp, if any, do we currently have in the flags?
898*61046927SAndroid Build Coastguard Worker * This is set when processing a comparison instruction, and
899*61046927SAndroid Build Coastguard Worker * reset to -1 by anything else that touches the flags.
900*61046927SAndroid Build Coastguard Worker */
901*61046927SAndroid Build Coastguard Worker int32_t flags_temp;
902*61046927SAndroid Build Coastguard Worker enum v3d_qpu_cond flags_cond;
903*61046927SAndroid Build Coastguard Worker
904*61046927SAndroid Build Coastguard Worker uint64_t *qpu_insts;
905*61046927SAndroid Build Coastguard Worker uint32_t qpu_inst_count;
906*61046927SAndroid Build Coastguard Worker uint32_t qpu_inst_size;
907*61046927SAndroid Build Coastguard Worker uint32_t qpu_inst_stalled_count;
908*61046927SAndroid Build Coastguard Worker uint32_t nop_count;
909*61046927SAndroid Build Coastguard Worker
910*61046927SAndroid Build Coastguard Worker /* For the FS, the number of varying inputs not counting the
911*61046927SAndroid Build Coastguard Worker * point/line varyings payload
912*61046927SAndroid Build Coastguard Worker */
913*61046927SAndroid Build Coastguard Worker uint32_t num_inputs;
914*61046927SAndroid Build Coastguard Worker
915*61046927SAndroid Build Coastguard Worker uint32_t program_id;
916*61046927SAndroid Build Coastguard Worker uint32_t variant_id;
917*61046927SAndroid Build Coastguard Worker
918*61046927SAndroid Build Coastguard Worker /* Set to compile program in in 1x, 2x, or 4x threaded mode, where
919*61046927SAndroid Build Coastguard Worker * SIG_THREAD_SWITCH is used to hide texturing latency at the cost of
920*61046927SAndroid Build Coastguard Worker * limiting ourselves to the part of the physical reg space.
921*61046927SAndroid Build Coastguard Worker *
922*61046927SAndroid Build Coastguard Worker * On V3D 3.x, 2x or 4x divide the physical reg space by 2x or 4x. On
923*61046927SAndroid Build Coastguard Worker * V3D 4.x, all shaders are 2x threaded, and 4x only divides the
924*61046927SAndroid Build Coastguard Worker * physical reg space in half.
925*61046927SAndroid Build Coastguard Worker */
926*61046927SAndroid Build Coastguard Worker uint8_t threads;
927*61046927SAndroid Build Coastguard Worker struct qinst *last_thrsw;
928*61046927SAndroid Build Coastguard Worker bool last_thrsw_at_top_level;
929*61046927SAndroid Build Coastguard Worker
930*61046927SAndroid Build Coastguard Worker bool emitted_tlb_load;
931*61046927SAndroid Build Coastguard Worker bool lock_scoreboard_on_first_thrsw;
932*61046927SAndroid Build Coastguard Worker
933*61046927SAndroid Build Coastguard Worker enum v3d_compilation_result compilation_result;
934*61046927SAndroid Build Coastguard Worker
935*61046927SAndroid Build Coastguard Worker bool tmu_dirty_rcl;
936*61046927SAndroid Build Coastguard Worker bool has_global_address;
937*61046927SAndroid Build Coastguard Worker
938*61046927SAndroid Build Coastguard Worker /* If we have processed a discard/terminate instruction. This may
939*61046927SAndroid Build Coastguard Worker * cause some lanes to be inactive even during uniform control
940*61046927SAndroid Build Coastguard Worker * flow.
941*61046927SAndroid Build Coastguard Worker */
942*61046927SAndroid Build Coastguard Worker bool emitted_discard;
943*61046927SAndroid Build Coastguard Worker };
944*61046927SAndroid Build Coastguard Worker
945*61046927SAndroid Build Coastguard Worker struct v3d_uniform_list {
946*61046927SAndroid Build Coastguard Worker enum quniform_contents *contents;
947*61046927SAndroid Build Coastguard Worker uint32_t *data;
948*61046927SAndroid Build Coastguard Worker uint32_t count;
949*61046927SAndroid Build Coastguard Worker };
950*61046927SAndroid Build Coastguard Worker
951*61046927SAndroid Build Coastguard Worker struct v3d_prog_data {
952*61046927SAndroid Build Coastguard Worker struct v3d_uniform_list uniforms;
953*61046927SAndroid Build Coastguard Worker
954*61046927SAndroid Build Coastguard Worker uint32_t spill_size;
955*61046927SAndroid Build Coastguard Worker uint32_t tmu_spills;
956*61046927SAndroid Build Coastguard Worker uint32_t tmu_fills;
957*61046927SAndroid Build Coastguard Worker uint32_t tmu_count;
958*61046927SAndroid Build Coastguard Worker
959*61046927SAndroid Build Coastguard Worker uint32_t qpu_read_stalls;
960*61046927SAndroid Build Coastguard Worker
961*61046927SAndroid Build Coastguard Worker uint8_t compile_strategy_idx;
962*61046927SAndroid Build Coastguard Worker
963*61046927SAndroid Build Coastguard Worker uint8_t threads;
964*61046927SAndroid Build Coastguard Worker
965*61046927SAndroid Build Coastguard Worker /* For threads > 1, whether the program should be dispatched in the
966*61046927SAndroid Build Coastguard Worker * after-final-THRSW state.
967*61046927SAndroid Build Coastguard Worker */
968*61046927SAndroid Build Coastguard Worker bool single_seg;
969*61046927SAndroid Build Coastguard Worker
970*61046927SAndroid Build Coastguard Worker bool tmu_dirty_rcl;
971*61046927SAndroid Build Coastguard Worker
972*61046927SAndroid Build Coastguard Worker bool has_control_barrier;
973*61046927SAndroid Build Coastguard Worker
974*61046927SAndroid Build Coastguard Worker bool has_global_address;
975*61046927SAndroid Build Coastguard Worker };
976*61046927SAndroid Build Coastguard Worker
977*61046927SAndroid Build Coastguard Worker struct v3d_vs_prog_data {
978*61046927SAndroid Build Coastguard Worker struct v3d_prog_data base;
979*61046927SAndroid Build Coastguard Worker
980*61046927SAndroid Build Coastguard Worker bool uses_iid, uses_biid, uses_vid;
981*61046927SAndroid Build Coastguard Worker
982*61046927SAndroid Build Coastguard Worker /* Number of components read from each vertex attribute. */
983*61046927SAndroid Build Coastguard Worker uint8_t vattr_sizes[V3D_MAX_VS_INPUTS / 4];
984*61046927SAndroid Build Coastguard Worker
985*61046927SAndroid Build Coastguard Worker /* Total number of components read, for the shader state record. */
986*61046927SAndroid Build Coastguard Worker uint32_t vpm_input_size;
987*61046927SAndroid Build Coastguard Worker
988*61046927SAndroid Build Coastguard Worker /* Total number of components written, for the shader state record. */
989*61046927SAndroid Build Coastguard Worker uint32_t vpm_output_size;
990*61046927SAndroid Build Coastguard Worker
991*61046927SAndroid Build Coastguard Worker /* Set if there should be separate VPM segments for input and output.
992*61046927SAndroid Build Coastguard Worker * If unset, vpm_input_size will be 0.
993*61046927SAndroid Build Coastguard Worker */
994*61046927SAndroid Build Coastguard Worker bool separate_segments;
995*61046927SAndroid Build Coastguard Worker
996*61046927SAndroid Build Coastguard Worker /* Value to be programmed in VCM_CACHE_SIZE. */
997*61046927SAndroid Build Coastguard Worker uint8_t vcm_cache_size;
998*61046927SAndroid Build Coastguard Worker
999*61046927SAndroid Build Coastguard Worker bool writes_psiz;
1000*61046927SAndroid Build Coastguard Worker
1001*61046927SAndroid Build Coastguard Worker /* Maps the nir->data.location to its
1002*61046927SAndroid Build Coastguard Worker * nir->data.driver_location. In general we are using the
1003*61046927SAndroid Build Coastguard Worker * driver location as index (like vattr_sizes above), so this
1004*61046927SAndroid Build Coastguard Worker * map is useful when what we have is the location
1005*61046927SAndroid Build Coastguard Worker *
1006*61046927SAndroid Build Coastguard Worker * Returns -1 if the location is not used
1007*61046927SAndroid Build Coastguard Worker */
1008*61046927SAndroid Build Coastguard Worker int32_t driver_location_map[V3D_MAX_VS_INPUTS];
1009*61046927SAndroid Build Coastguard Worker };
1010*61046927SAndroid Build Coastguard Worker
1011*61046927SAndroid Build Coastguard Worker struct v3d_gs_prog_data {
1012*61046927SAndroid Build Coastguard Worker struct v3d_prog_data base;
1013*61046927SAndroid Build Coastguard Worker
1014*61046927SAndroid Build Coastguard Worker /* Whether the program reads gl_PrimitiveIDIn */
1015*61046927SAndroid Build Coastguard Worker bool uses_pid;
1016*61046927SAndroid Build Coastguard Worker
1017*61046927SAndroid Build Coastguard Worker /* Number of components read from each input varying. */
1018*61046927SAndroid Build Coastguard Worker uint8_t input_sizes[V3D_MAX_GS_INPUTS / 4];
1019*61046927SAndroid Build Coastguard Worker
1020*61046927SAndroid Build Coastguard Worker /* Number of inputs */
1021*61046927SAndroid Build Coastguard Worker uint8_t num_inputs;
1022*61046927SAndroid Build Coastguard Worker struct v3d_varying_slot input_slots[V3D_MAX_GS_INPUTS];
1023*61046927SAndroid Build Coastguard Worker
1024*61046927SAndroid Build Coastguard Worker /* Total number of components written, for the shader state record. */
1025*61046927SAndroid Build Coastguard Worker uint32_t vpm_output_size;
1026*61046927SAndroid Build Coastguard Worker
1027*61046927SAndroid Build Coastguard Worker /* Maximum SIMD dispatch width to not exceed VPM output size limits
1028*61046927SAndroid Build Coastguard Worker * in the geometry shader. Notice that the final dispatch width has to
1029*61046927SAndroid Build Coastguard Worker * be decided at draw time and could be lower based on the VPM pressure
1030*61046927SAndroid Build Coastguard Worker * added by other shader stages.
1031*61046927SAndroid Build Coastguard Worker */
1032*61046927SAndroid Build Coastguard Worker uint8_t simd_width;
1033*61046927SAndroid Build Coastguard Worker
1034*61046927SAndroid Build Coastguard Worker /* Output primitive type */
1035*61046927SAndroid Build Coastguard Worker uint8_t out_prim_type;
1036*61046927SAndroid Build Coastguard Worker
1037*61046927SAndroid Build Coastguard Worker /* Number of GS invocations */
1038*61046927SAndroid Build Coastguard Worker uint8_t num_invocations;
1039*61046927SAndroid Build Coastguard Worker
1040*61046927SAndroid Build Coastguard Worker bool writes_psiz;
1041*61046927SAndroid Build Coastguard Worker };
1042*61046927SAndroid Build Coastguard Worker
1043*61046927SAndroid Build Coastguard Worker struct v3d_fs_prog_data {
1044*61046927SAndroid Build Coastguard Worker struct v3d_prog_data base;
1045*61046927SAndroid Build Coastguard Worker
1046*61046927SAndroid Build Coastguard Worker /* Whether the program reads gl_PrimitiveID */
1047*61046927SAndroid Build Coastguard Worker bool uses_pid;
1048*61046927SAndroid Build Coastguard Worker
1049*61046927SAndroid Build Coastguard Worker struct v3d_varying_slot input_slots[V3D_MAX_FS_INPUTS];
1050*61046927SAndroid Build Coastguard Worker
1051*61046927SAndroid Build Coastguard Worker /* Array of flat shade flags.
1052*61046927SAndroid Build Coastguard Worker *
1053*61046927SAndroid Build Coastguard Worker * Each entry is only 24 bits (high 8 bits 0), to match the hardware
1054*61046927SAndroid Build Coastguard Worker * packet layout.
1055*61046927SAndroid Build Coastguard Worker */
1056*61046927SAndroid Build Coastguard Worker uint32_t flat_shade_flags[((V3D_MAX_FS_INPUTS - 1) / 24) + 1];
1057*61046927SAndroid Build Coastguard Worker
1058*61046927SAndroid Build Coastguard Worker uint32_t noperspective_flags[((V3D_MAX_FS_INPUTS - 1) / 24) + 1];
1059*61046927SAndroid Build Coastguard Worker
1060*61046927SAndroid Build Coastguard Worker uint32_t centroid_flags[((V3D_MAX_FS_INPUTS - 1) / 24) + 1];
1061*61046927SAndroid Build Coastguard Worker
1062*61046927SAndroid Build Coastguard Worker uint8_t num_inputs;
1063*61046927SAndroid Build Coastguard Worker bool writes_z;
1064*61046927SAndroid Build Coastguard Worker bool writes_z_from_fep;
1065*61046927SAndroid Build Coastguard Worker bool disable_ez;
1066*61046927SAndroid Build Coastguard Worker bool uses_center_w;
1067*61046927SAndroid Build Coastguard Worker bool uses_implicit_point_line_varyings;
1068*61046927SAndroid Build Coastguard Worker bool lock_scoreboard_on_first_thrsw;
1069*61046927SAndroid Build Coastguard Worker
1070*61046927SAndroid Build Coastguard Worker /* If the fragment shader does anything that requires to force
1071*61046927SAndroid Build Coastguard Worker * per-sample MSAA, such as reading gl_SampleID.
1072*61046927SAndroid Build Coastguard Worker */
1073*61046927SAndroid Build Coastguard Worker bool force_per_sample_msaa;
1074*61046927SAndroid Build Coastguard Worker };
1075*61046927SAndroid Build Coastguard Worker
1076*61046927SAndroid Build Coastguard Worker struct v3d_compute_prog_data {
1077*61046927SAndroid Build Coastguard Worker struct v3d_prog_data base;
1078*61046927SAndroid Build Coastguard Worker /* Size in bytes of the workgroup's shared space. */
1079*61046927SAndroid Build Coastguard Worker uint32_t shared_size;
1080*61046927SAndroid Build Coastguard Worker uint16_t local_size[3];
1081*61046927SAndroid Build Coastguard Worker /* If the shader uses subgroup functionality */
1082*61046927SAndroid Build Coastguard Worker bool has_subgroups;
1083*61046927SAndroid Build Coastguard Worker };
1084*61046927SAndroid Build Coastguard Worker
1085*61046927SAndroid Build Coastguard Worker struct vpm_config {
1086*61046927SAndroid Build Coastguard Worker uint32_t As;
1087*61046927SAndroid Build Coastguard Worker uint32_t Vc;
1088*61046927SAndroid Build Coastguard Worker uint32_t Gs;
1089*61046927SAndroid Build Coastguard Worker uint32_t Gd;
1090*61046927SAndroid Build Coastguard Worker uint32_t Gv;
1091*61046927SAndroid Build Coastguard Worker uint32_t Ve;
1092*61046927SAndroid Build Coastguard Worker uint32_t gs_width;
1093*61046927SAndroid Build Coastguard Worker };
1094*61046927SAndroid Build Coastguard Worker
1095*61046927SAndroid Build Coastguard Worker bool
1096*61046927SAndroid Build Coastguard Worker v3d_compute_vpm_config(struct v3d_device_info *devinfo,
1097*61046927SAndroid Build Coastguard Worker struct v3d_vs_prog_data *vs_bin,
1098*61046927SAndroid Build Coastguard Worker struct v3d_vs_prog_data *vs,
1099*61046927SAndroid Build Coastguard Worker struct v3d_gs_prog_data *gs_bin,
1100*61046927SAndroid Build Coastguard Worker struct v3d_gs_prog_data *gs,
1101*61046927SAndroid Build Coastguard Worker struct vpm_config *vpm_cfg_bin,
1102*61046927SAndroid Build Coastguard Worker struct vpm_config *vpm_cfg);
1103*61046927SAndroid Build Coastguard Worker void
1104*61046927SAndroid Build Coastguard Worker v3d_pack_unnormalized_coordinates(struct v3d_device_info *devinfo,
1105*61046927SAndroid Build Coastguard Worker uint32_t *p1_packed,
1106*61046927SAndroid Build Coastguard Worker bool unnormalized_coordinates);
1107*61046927SAndroid Build Coastguard Worker
1108*61046927SAndroid Build Coastguard Worker static inline bool
vir_has_uniform(struct qinst * inst)1109*61046927SAndroid Build Coastguard Worker vir_has_uniform(struct qinst *inst)
1110*61046927SAndroid Build Coastguard Worker {
1111*61046927SAndroid Build Coastguard Worker return inst->uniform != ~0;
1112*61046927SAndroid Build Coastguard Worker }
1113*61046927SAndroid Build Coastguard Worker
1114*61046927SAndroid Build Coastguard Worker const struct v3d_compiler *v3d_compiler_init(const struct v3d_device_info *devinfo,
1115*61046927SAndroid Build Coastguard Worker uint32_t max_inline_uniform_buffers);
1116*61046927SAndroid Build Coastguard Worker void v3d_compiler_free(const struct v3d_compiler *compiler);
1117*61046927SAndroid Build Coastguard Worker void v3d_optimize_nir(struct v3d_compile *c, struct nir_shader *s);
1118*61046927SAndroid Build Coastguard Worker
1119*61046927SAndroid Build Coastguard Worker uint64_t *v3d_compile(const struct v3d_compiler *compiler,
1120*61046927SAndroid Build Coastguard Worker struct v3d_key *key,
1121*61046927SAndroid Build Coastguard Worker struct v3d_prog_data **prog_data,
1122*61046927SAndroid Build Coastguard Worker nir_shader *s,
1123*61046927SAndroid Build Coastguard Worker void (*debug_output)(const char *msg,
1124*61046927SAndroid Build Coastguard Worker void *debug_output_data),
1125*61046927SAndroid Build Coastguard Worker void *debug_output_data,
1126*61046927SAndroid Build Coastguard Worker int program_id, int variant_id,
1127*61046927SAndroid Build Coastguard Worker uint32_t *final_assembly_size);
1128*61046927SAndroid Build Coastguard Worker
1129*61046927SAndroid Build Coastguard Worker uint32_t v3d_prog_data_size(gl_shader_stage stage);
1130*61046927SAndroid Build Coastguard Worker void v3d_nir_to_vir(struct v3d_compile *c);
1131*61046927SAndroid Build Coastguard Worker
1132*61046927SAndroid Build Coastguard Worker void vir_compile_destroy(struct v3d_compile *c);
1133*61046927SAndroid Build Coastguard Worker const char *vir_get_stage_name(struct v3d_compile *c);
1134*61046927SAndroid Build Coastguard Worker struct qblock *vir_new_block(struct v3d_compile *c);
1135*61046927SAndroid Build Coastguard Worker void vir_set_emit_block(struct v3d_compile *c, struct qblock *block);
1136*61046927SAndroid Build Coastguard Worker void vir_link_blocks(struct qblock *predecessor, struct qblock *successor);
1137*61046927SAndroid Build Coastguard Worker struct qblock *vir_entry_block(struct v3d_compile *c);
1138*61046927SAndroid Build Coastguard Worker struct qblock *vir_exit_block(struct v3d_compile *c);
1139*61046927SAndroid Build Coastguard Worker struct qinst *vir_add_inst(enum v3d_qpu_add_op op, struct qreg dst,
1140*61046927SAndroid Build Coastguard Worker struct qreg src0, struct qreg src1);
1141*61046927SAndroid Build Coastguard Worker struct qinst *vir_mul_inst(enum v3d_qpu_mul_op op, struct qreg dst,
1142*61046927SAndroid Build Coastguard Worker struct qreg src0, struct qreg src1);
1143*61046927SAndroid Build Coastguard Worker struct qinst *vir_branch_inst(struct v3d_compile *c,
1144*61046927SAndroid Build Coastguard Worker enum v3d_qpu_branch_cond cond);
1145*61046927SAndroid Build Coastguard Worker void vir_remove_instruction(struct v3d_compile *c, struct qinst *qinst);
1146*61046927SAndroid Build Coastguard Worker uint32_t vir_get_uniform_index(struct v3d_compile *c,
1147*61046927SAndroid Build Coastguard Worker enum quniform_contents contents,
1148*61046927SAndroid Build Coastguard Worker uint32_t data);
1149*61046927SAndroid Build Coastguard Worker struct qreg vir_uniform(struct v3d_compile *c,
1150*61046927SAndroid Build Coastguard Worker enum quniform_contents contents,
1151*61046927SAndroid Build Coastguard Worker uint32_t data);
1152*61046927SAndroid Build Coastguard Worker void vir_schedule_instructions(struct v3d_compile *c);
1153*61046927SAndroid Build Coastguard Worker void v3d_setup_spill_base(struct v3d_compile *c);
1154*61046927SAndroid Build Coastguard Worker struct v3d_qpu_instr v3d_qpu_nop(void);
1155*61046927SAndroid Build Coastguard Worker
1156*61046927SAndroid Build Coastguard Worker struct qreg vir_emit_def(struct v3d_compile *c, struct qinst *inst);
1157*61046927SAndroid Build Coastguard Worker struct qinst *vir_emit_nondef(struct v3d_compile *c, struct qinst *inst);
1158*61046927SAndroid Build Coastguard Worker void vir_set_cond(struct qinst *inst, enum v3d_qpu_cond cond);
1159*61046927SAndroid Build Coastguard Worker enum v3d_qpu_cond vir_get_cond(struct qinst *inst);
1160*61046927SAndroid Build Coastguard Worker void vir_set_pf(struct v3d_compile *c, struct qinst *inst, enum v3d_qpu_pf pf);
1161*61046927SAndroid Build Coastguard Worker void vir_set_uf(struct v3d_compile *c, struct qinst *inst, enum v3d_qpu_uf uf);
1162*61046927SAndroid Build Coastguard Worker void vir_set_unpack(struct qinst *inst, int src,
1163*61046927SAndroid Build Coastguard Worker enum v3d_qpu_input_unpack unpack);
1164*61046927SAndroid Build Coastguard Worker void vir_set_pack(struct qinst *inst, enum v3d_qpu_output_pack pack);
1165*61046927SAndroid Build Coastguard Worker
1166*61046927SAndroid Build Coastguard Worker struct qreg vir_get_temp(struct v3d_compile *c);
1167*61046927SAndroid Build Coastguard Worker void vir_calculate_live_intervals(struct v3d_compile *c);
1168*61046927SAndroid Build Coastguard Worker int vir_get_nsrc(struct qinst *inst);
1169*61046927SAndroid Build Coastguard Worker bool vir_has_side_effects(struct v3d_compile *c, struct qinst *inst);
1170*61046927SAndroid Build Coastguard Worker bool vir_get_add_op(struct qinst *inst, enum v3d_qpu_add_op *op);
1171*61046927SAndroid Build Coastguard Worker bool vir_get_mul_op(struct qinst *inst, enum v3d_qpu_mul_op *op);
1172*61046927SAndroid Build Coastguard Worker bool vir_is_raw_mov(struct qinst *inst);
1173*61046927SAndroid Build Coastguard Worker bool vir_is_tex(const struct v3d_device_info *devinfo, struct qinst *inst);
1174*61046927SAndroid Build Coastguard Worker bool vir_is_add(struct qinst *inst);
1175*61046927SAndroid Build Coastguard Worker bool vir_is_mul(struct qinst *inst);
1176*61046927SAndroid Build Coastguard Worker bool vir_writes_r4_implicitly(const struct v3d_device_info *devinfo, struct qinst *inst);
1177*61046927SAndroid Build Coastguard Worker struct qreg vir_follow_movs(struct v3d_compile *c, struct qreg reg);
1178*61046927SAndroid Build Coastguard Worker uint8_t vir_channels_written(struct qinst *inst);
1179*61046927SAndroid Build Coastguard Worker struct qreg ntq_get_src(struct v3d_compile *c, nir_src src, int i);
1180*61046927SAndroid Build Coastguard Worker void ntq_store_def(struct v3d_compile *c, nir_def *def, int chan,
1181*61046927SAndroid Build Coastguard Worker struct qreg result);
1182*61046927SAndroid Build Coastguard Worker bool ntq_tmu_fifo_overflow(struct v3d_compile *c, uint32_t components);
1183*61046927SAndroid Build Coastguard Worker void ntq_add_pending_tmu_flush(struct v3d_compile *c, nir_def *def,
1184*61046927SAndroid Build Coastguard Worker uint32_t component_mask);
1185*61046927SAndroid Build Coastguard Worker void ntq_flush_tmu(struct v3d_compile *c);
1186*61046927SAndroid Build Coastguard Worker void vir_emit_thrsw(struct v3d_compile *c);
1187*61046927SAndroid Build Coastguard Worker
1188*61046927SAndroid Build Coastguard Worker void vir_dump(struct v3d_compile *c);
1189*61046927SAndroid Build Coastguard Worker void vir_dump_inst(struct v3d_compile *c, struct qinst *inst);
1190*61046927SAndroid Build Coastguard Worker void vir_dump_uniform(enum quniform_contents contents, uint32_t data);
1191*61046927SAndroid Build Coastguard Worker
1192*61046927SAndroid Build Coastguard Worker void vir_validate(struct v3d_compile *c);
1193*61046927SAndroid Build Coastguard Worker
1194*61046927SAndroid Build Coastguard Worker void vir_optimize(struct v3d_compile *c);
1195*61046927SAndroid Build Coastguard Worker bool vir_opt_algebraic(struct v3d_compile *c);
1196*61046927SAndroid Build Coastguard Worker bool vir_opt_constant_folding(struct v3d_compile *c);
1197*61046927SAndroid Build Coastguard Worker bool vir_opt_copy_propagate(struct v3d_compile *c);
1198*61046927SAndroid Build Coastguard Worker bool vir_opt_dead_code(struct v3d_compile *c);
1199*61046927SAndroid Build Coastguard Worker bool vir_opt_peephole_sf(struct v3d_compile *c);
1200*61046927SAndroid Build Coastguard Worker bool vir_opt_redundant_flags(struct v3d_compile *c);
1201*61046927SAndroid Build Coastguard Worker bool vir_opt_small_immediates(struct v3d_compile *c);
1202*61046927SAndroid Build Coastguard Worker bool vir_opt_vpm(struct v3d_compile *c);
1203*61046927SAndroid Build Coastguard Worker bool vir_opt_constant_alu(struct v3d_compile *c);
1204*61046927SAndroid Build Coastguard Worker bool v3d_nir_lower_io(nir_shader *s, struct v3d_compile *c);
1205*61046927SAndroid Build Coastguard Worker bool v3d_nir_lower_line_smooth(nir_shader *shader);
1206*61046927SAndroid Build Coastguard Worker bool v3d_nir_lower_logic_ops(nir_shader *s, struct v3d_compile *c);
1207*61046927SAndroid Build Coastguard Worker bool v3d_nir_lower_scratch(nir_shader *s);
1208*61046927SAndroid Build Coastguard Worker bool v3d_nir_lower_txf_ms(nir_shader *s);
1209*61046927SAndroid Build Coastguard Worker bool v3d_nir_lower_image_load_store(nir_shader *s, struct v3d_compile *c);
1210*61046927SAndroid Build Coastguard Worker bool v3d_nir_lower_global_2x32(nir_shader *s);
1211*61046927SAndroid Build Coastguard Worker bool v3d_nir_lower_load_store_bitsize(nir_shader *s);
1212*61046927SAndroid Build Coastguard Worker bool v3d_nir_lower_algebraic(struct nir_shader *shader);
1213*61046927SAndroid Build Coastguard Worker
1214*61046927SAndroid Build Coastguard Worker void v3d_vir_emit_tex(struct v3d_compile *c, nir_tex_instr *instr);
1215*61046927SAndroid Build Coastguard Worker void v3d_vir_emit_image_load_store(struct v3d_compile *c,
1216*61046927SAndroid Build Coastguard Worker nir_intrinsic_instr *instr);
1217*61046927SAndroid Build Coastguard Worker
1218*61046927SAndroid Build Coastguard Worker void v3d_vir_to_qpu(struct v3d_compile *c, struct qpu_reg *temp_registers);
1219*61046927SAndroid Build Coastguard Worker uint32_t v3d_qpu_schedule_instructions(struct v3d_compile *c);
1220*61046927SAndroid Build Coastguard Worker void qpu_validate(struct v3d_compile *c);
1221*61046927SAndroid Build Coastguard Worker struct qpu_reg *v3d_register_allocate(struct v3d_compile *c);
1222*61046927SAndroid Build Coastguard Worker bool vir_init_reg_sets(struct v3d_compiler *compiler);
1223*61046927SAndroid Build Coastguard Worker
1224*61046927SAndroid Build Coastguard Worker int v3d_shaderdb_dump(struct v3d_compile *c, char **shaderdb_str);
1225*61046927SAndroid Build Coastguard Worker
1226*61046927SAndroid Build Coastguard Worker bool v3d_gl_format_is_return_32(enum pipe_format format);
1227*61046927SAndroid Build Coastguard Worker
1228*61046927SAndroid Build Coastguard Worker uint32_t
1229*61046927SAndroid Build Coastguard Worker v3d_get_op_for_atomic_add(nir_intrinsic_instr *instr, unsigned src);
1230*61046927SAndroid Build Coastguard Worker
1231*61046927SAndroid Build Coastguard Worker static inline bool
quniform_contents_is_texture_p0(enum quniform_contents contents)1232*61046927SAndroid Build Coastguard Worker quniform_contents_is_texture_p0(enum quniform_contents contents)
1233*61046927SAndroid Build Coastguard Worker {
1234*61046927SAndroid Build Coastguard Worker return (contents >= QUNIFORM_TEXTURE_CONFIG_P0_0 &&
1235*61046927SAndroid Build Coastguard Worker contents < (QUNIFORM_TEXTURE_CONFIG_P0_0 +
1236*61046927SAndroid Build Coastguard Worker V3D_MAX_TEXTURE_SAMPLERS));
1237*61046927SAndroid Build Coastguard Worker }
1238*61046927SAndroid Build Coastguard Worker
1239*61046927SAndroid Build Coastguard Worker static inline bool
vir_in_nonuniform_control_flow(struct v3d_compile * c)1240*61046927SAndroid Build Coastguard Worker vir_in_nonuniform_control_flow(struct v3d_compile *c)
1241*61046927SAndroid Build Coastguard Worker {
1242*61046927SAndroid Build Coastguard Worker return c->execute.file != QFILE_NULL;
1243*61046927SAndroid Build Coastguard Worker }
1244*61046927SAndroid Build Coastguard Worker
1245*61046927SAndroid Build Coastguard Worker static inline struct qreg
vir_uniform_ui(struct v3d_compile * c,uint32_t ui)1246*61046927SAndroid Build Coastguard Worker vir_uniform_ui(struct v3d_compile *c, uint32_t ui)
1247*61046927SAndroid Build Coastguard Worker {
1248*61046927SAndroid Build Coastguard Worker return vir_uniform(c, QUNIFORM_CONSTANT, ui);
1249*61046927SAndroid Build Coastguard Worker }
1250*61046927SAndroid Build Coastguard Worker
1251*61046927SAndroid Build Coastguard Worker static inline struct qreg
vir_uniform_f(struct v3d_compile * c,float f)1252*61046927SAndroid Build Coastguard Worker vir_uniform_f(struct v3d_compile *c, float f)
1253*61046927SAndroid Build Coastguard Worker {
1254*61046927SAndroid Build Coastguard Worker return vir_uniform(c, QUNIFORM_CONSTANT, fui(f));
1255*61046927SAndroid Build Coastguard Worker }
1256*61046927SAndroid Build Coastguard Worker
1257*61046927SAndroid Build Coastguard Worker #define VIR_ALU0(name, vir_inst, op) \
1258*61046927SAndroid Build Coastguard Worker static inline struct qreg \
1259*61046927SAndroid Build Coastguard Worker vir_##name(struct v3d_compile *c) \
1260*61046927SAndroid Build Coastguard Worker { \
1261*61046927SAndroid Build Coastguard Worker return vir_emit_def(c, vir_inst(op, c->undef, \
1262*61046927SAndroid Build Coastguard Worker c->undef, c->undef)); \
1263*61046927SAndroid Build Coastguard Worker } \
1264*61046927SAndroid Build Coastguard Worker static inline struct qinst * \
1265*61046927SAndroid Build Coastguard Worker vir_##name##_dest(struct v3d_compile *c, struct qreg dest) \
1266*61046927SAndroid Build Coastguard Worker { \
1267*61046927SAndroid Build Coastguard Worker return vir_emit_nondef(c, vir_inst(op, dest, \
1268*61046927SAndroid Build Coastguard Worker c->undef, c->undef)); \
1269*61046927SAndroid Build Coastguard Worker }
1270*61046927SAndroid Build Coastguard Worker
1271*61046927SAndroid Build Coastguard Worker #define VIR_ALU1(name, vir_inst, op) \
1272*61046927SAndroid Build Coastguard Worker static inline struct qreg \
1273*61046927SAndroid Build Coastguard Worker vir_##name(struct v3d_compile *c, struct qreg a) \
1274*61046927SAndroid Build Coastguard Worker { \
1275*61046927SAndroid Build Coastguard Worker return vir_emit_def(c, vir_inst(op, c->undef, \
1276*61046927SAndroid Build Coastguard Worker a, c->undef)); \
1277*61046927SAndroid Build Coastguard Worker } \
1278*61046927SAndroid Build Coastguard Worker static inline struct qinst * \
1279*61046927SAndroid Build Coastguard Worker vir_##name##_dest(struct v3d_compile *c, struct qreg dest, \
1280*61046927SAndroid Build Coastguard Worker struct qreg a) \
1281*61046927SAndroid Build Coastguard Worker { \
1282*61046927SAndroid Build Coastguard Worker return vir_emit_nondef(c, vir_inst(op, dest, a, \
1283*61046927SAndroid Build Coastguard Worker c->undef)); \
1284*61046927SAndroid Build Coastguard Worker }
1285*61046927SAndroid Build Coastguard Worker
1286*61046927SAndroid Build Coastguard Worker #define VIR_ALU2(name, vir_inst, op) \
1287*61046927SAndroid Build Coastguard Worker static inline struct qreg \
1288*61046927SAndroid Build Coastguard Worker vir_##name(struct v3d_compile *c, struct qreg a, struct qreg b) \
1289*61046927SAndroid Build Coastguard Worker { \
1290*61046927SAndroid Build Coastguard Worker return vir_emit_def(c, vir_inst(op, c->undef, a, b)); \
1291*61046927SAndroid Build Coastguard Worker } \
1292*61046927SAndroid Build Coastguard Worker static inline struct qinst * \
1293*61046927SAndroid Build Coastguard Worker vir_##name##_dest(struct v3d_compile *c, struct qreg dest, \
1294*61046927SAndroid Build Coastguard Worker struct qreg a, struct qreg b) \
1295*61046927SAndroid Build Coastguard Worker { \
1296*61046927SAndroid Build Coastguard Worker return vir_emit_nondef(c, vir_inst(op, dest, a, b)); \
1297*61046927SAndroid Build Coastguard Worker }
1298*61046927SAndroid Build Coastguard Worker
1299*61046927SAndroid Build Coastguard Worker #define VIR_NODST_0(name, vir_inst, op) \
1300*61046927SAndroid Build Coastguard Worker static inline struct qinst * \
1301*61046927SAndroid Build Coastguard Worker vir_##name(struct v3d_compile *c) \
1302*61046927SAndroid Build Coastguard Worker { \
1303*61046927SAndroid Build Coastguard Worker return vir_emit_nondef(c, vir_inst(op, c->undef, \
1304*61046927SAndroid Build Coastguard Worker c->undef, c->undef)); \
1305*61046927SAndroid Build Coastguard Worker }
1306*61046927SAndroid Build Coastguard Worker
1307*61046927SAndroid Build Coastguard Worker #define VIR_NODST_1(name, vir_inst, op) \
1308*61046927SAndroid Build Coastguard Worker static inline struct qinst * \
1309*61046927SAndroid Build Coastguard Worker vir_##name(struct v3d_compile *c, struct qreg a) \
1310*61046927SAndroid Build Coastguard Worker { \
1311*61046927SAndroid Build Coastguard Worker return vir_emit_nondef(c, vir_inst(op, c->undef, \
1312*61046927SAndroid Build Coastguard Worker a, c->undef)); \
1313*61046927SAndroid Build Coastguard Worker }
1314*61046927SAndroid Build Coastguard Worker
1315*61046927SAndroid Build Coastguard Worker #define VIR_NODST_2(name, vir_inst, op) \
1316*61046927SAndroid Build Coastguard Worker static inline struct qinst * \
1317*61046927SAndroid Build Coastguard Worker vir_##name(struct v3d_compile *c, struct qreg a, struct qreg b) \
1318*61046927SAndroid Build Coastguard Worker { \
1319*61046927SAndroid Build Coastguard Worker return vir_emit_nondef(c, vir_inst(op, c->undef, \
1320*61046927SAndroid Build Coastguard Worker a, b)); \
1321*61046927SAndroid Build Coastguard Worker }
1322*61046927SAndroid Build Coastguard Worker
1323*61046927SAndroid Build Coastguard Worker #define VIR_SFU(name) \
1324*61046927SAndroid Build Coastguard Worker static inline struct qreg \
1325*61046927SAndroid Build Coastguard Worker vir_##name(struct v3d_compile *c, struct qreg a) \
1326*61046927SAndroid Build Coastguard Worker { \
1327*61046927SAndroid Build Coastguard Worker return vir_emit_def(c, vir_add_inst(V3D_QPU_A_##name, \
1328*61046927SAndroid Build Coastguard Worker c->undef, \
1329*61046927SAndroid Build Coastguard Worker a, c->undef)); \
1330*61046927SAndroid Build Coastguard Worker } \
1331*61046927SAndroid Build Coastguard Worker static inline struct qinst * \
1332*61046927SAndroid Build Coastguard Worker vir_##name##_dest(struct v3d_compile *c, struct qreg dest, \
1333*61046927SAndroid Build Coastguard Worker struct qreg a) \
1334*61046927SAndroid Build Coastguard Worker { \
1335*61046927SAndroid Build Coastguard Worker return vir_emit_nondef(c, vir_add_inst(V3D_QPU_A_##name, \
1336*61046927SAndroid Build Coastguard Worker dest, \
1337*61046927SAndroid Build Coastguard Worker a, c->undef)); \
1338*61046927SAndroid Build Coastguard Worker }
1339*61046927SAndroid Build Coastguard Worker
1340*61046927SAndroid Build Coastguard Worker #define VIR_SFU2(name) \
1341*61046927SAndroid Build Coastguard Worker static inline struct qreg \
1342*61046927SAndroid Build Coastguard Worker vir_##name(struct v3d_compile *c, struct qreg a, struct qreg b) \
1343*61046927SAndroid Build Coastguard Worker { \
1344*61046927SAndroid Build Coastguard Worker return vir_emit_def(c, vir_add_inst(V3D_QPU_A_##name, \
1345*61046927SAndroid Build Coastguard Worker c->undef, \
1346*61046927SAndroid Build Coastguard Worker a, b)); \
1347*61046927SAndroid Build Coastguard Worker } \
1348*61046927SAndroid Build Coastguard Worker static inline struct qinst * \
1349*61046927SAndroid Build Coastguard Worker vir_##name##_dest(struct v3d_compile *c, struct qreg dest, \
1350*61046927SAndroid Build Coastguard Worker struct qreg a, struct qreg b) \
1351*61046927SAndroid Build Coastguard Worker { \
1352*61046927SAndroid Build Coastguard Worker return vir_emit_nondef(c, vir_add_inst(V3D_QPU_A_##name, \
1353*61046927SAndroid Build Coastguard Worker dest, \
1354*61046927SAndroid Build Coastguard Worker a, b)); \
1355*61046927SAndroid Build Coastguard Worker }
1356*61046927SAndroid Build Coastguard Worker
1357*61046927SAndroid Build Coastguard Worker #define VIR_A_ALU2(name) VIR_ALU2(name, vir_add_inst, V3D_QPU_A_##name)
1358*61046927SAndroid Build Coastguard Worker #define VIR_M_ALU2(name) VIR_ALU2(name, vir_mul_inst, V3D_QPU_M_##name)
1359*61046927SAndroid Build Coastguard Worker #define VIR_A_ALU1(name) VIR_ALU1(name, vir_add_inst, V3D_QPU_A_##name)
1360*61046927SAndroid Build Coastguard Worker #define VIR_M_ALU1(name) VIR_ALU1(name, vir_mul_inst, V3D_QPU_M_##name)
1361*61046927SAndroid Build Coastguard Worker #define VIR_A_ALU0(name) VIR_ALU0(name, vir_add_inst, V3D_QPU_A_##name)
1362*61046927SAndroid Build Coastguard Worker #define VIR_M_ALU0(name) VIR_ALU0(name, vir_mul_inst, V3D_QPU_M_##name)
1363*61046927SAndroid Build Coastguard Worker #define VIR_A_NODST_2(name) VIR_NODST_2(name, vir_add_inst, V3D_QPU_A_##name)
1364*61046927SAndroid Build Coastguard Worker #define VIR_M_NODST_2(name) VIR_NODST_2(name, vir_mul_inst, V3D_QPU_M_##name)
1365*61046927SAndroid Build Coastguard Worker #define VIR_A_NODST_1(name) VIR_NODST_1(name, vir_add_inst, V3D_QPU_A_##name)
1366*61046927SAndroid Build Coastguard Worker #define VIR_M_NODST_1(name) VIR_NODST_1(name, vir_mul_inst, V3D_QPU_M_##name)
1367*61046927SAndroid Build Coastguard Worker #define VIR_A_NODST_0(name) VIR_NODST_0(name, vir_add_inst, V3D_QPU_A_##name)
1368*61046927SAndroid Build Coastguard Worker
1369*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(FADD)
VIR_A_ALU2(VFPACK)1370*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(VFPACK)
1371*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(FSUB)
1372*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(FMIN)
1373*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(FMAX)
1374*61046927SAndroid Build Coastguard Worker
1375*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(ADD)
1376*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(SUB)
1377*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(SHL)
1378*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(SHR)
1379*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(ASR)
1380*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(ROR)
1381*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(MIN)
1382*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(MAX)
1383*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(UMIN)
1384*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(UMAX)
1385*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(AND)
1386*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(OR)
1387*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(XOR)
1388*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(VADD)
1389*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(VSUB)
1390*61046927SAndroid Build Coastguard Worker VIR_A_NODST_2(STVPMV)
1391*61046927SAndroid Build Coastguard Worker VIR_A_NODST_2(STVPMD)
1392*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(NOT)
1393*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(NEG)
1394*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FLAPUSH)
1395*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FLBPUSH)
1396*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FLPOP)
1397*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(FLAFIRST)
1398*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(FLNAFIRST)
1399*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(SETMSF)
1400*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(SETREVF)
1401*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(TIDX)
1402*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(EIDX)
1403*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(LDVPMV_IN)
1404*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(LDVPMV_OUT)
1405*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(LDVPMD_IN)
1406*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(LDVPMD_OUT)
1407*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(LDVPMG_IN)
1408*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(LDVPMG_OUT)
1409*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(TMUWT)
1410*61046927SAndroid Build Coastguard Worker
1411*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(IID)
1412*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(FXCD)
1413*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(XCD)
1414*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(FYCD)
1415*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(YCD)
1416*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(MSF)
1417*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(REVF)
1418*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(BARRIERID)
1419*61046927SAndroid Build Coastguard Worker VIR_A_ALU0(SAMPID)
1420*61046927SAndroid Build Coastguard Worker VIR_A_NODST_1(VPMSETUP)
1421*61046927SAndroid Build Coastguard Worker VIR_A_NODST_0(VPMWT)
1422*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(FCMP)
1423*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(VFMAX)
1424*61046927SAndroid Build Coastguard Worker
1425*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FROUND)
1426*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FTOIN)
1427*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FTRUNC)
1428*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FTOIZ)
1429*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FFLOOR)
1430*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FTOUZ)
1431*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FCEIL)
1432*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FTOC)
1433*61046927SAndroid Build Coastguard Worker
1434*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FDX)
1435*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(FDY)
1436*61046927SAndroid Build Coastguard Worker
1437*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(ITOF)
1438*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(CLZ)
1439*61046927SAndroid Build Coastguard Worker VIR_A_ALU1(UTOF)
1440*61046927SAndroid Build Coastguard Worker
1441*61046927SAndroid Build Coastguard Worker VIR_M_ALU2(UMUL24)
1442*61046927SAndroid Build Coastguard Worker VIR_M_ALU2(FMUL)
1443*61046927SAndroid Build Coastguard Worker VIR_M_ALU2(SMUL24)
1444*61046927SAndroid Build Coastguard Worker VIR_M_NODST_2(MULTOP)
1445*61046927SAndroid Build Coastguard Worker
1446*61046927SAndroid Build Coastguard Worker VIR_M_ALU1(MOV)
1447*61046927SAndroid Build Coastguard Worker VIR_M_ALU1(FMOV)
1448*61046927SAndroid Build Coastguard Worker
1449*61046927SAndroid Build Coastguard Worker VIR_SFU(RECIP)
1450*61046927SAndroid Build Coastguard Worker VIR_SFU(RSQRT)
1451*61046927SAndroid Build Coastguard Worker VIR_SFU(EXP)
1452*61046927SAndroid Build Coastguard Worker VIR_SFU(LOG)
1453*61046927SAndroid Build Coastguard Worker VIR_SFU(SIN)
1454*61046927SAndroid Build Coastguard Worker VIR_SFU(RSQRT2)
1455*61046927SAndroid Build Coastguard Worker
1456*61046927SAndroid Build Coastguard Worker VIR_SFU(BALLOT)
1457*61046927SAndroid Build Coastguard Worker VIR_SFU(BCASTF)
1458*61046927SAndroid Build Coastguard Worker VIR_SFU(ALLEQ)
1459*61046927SAndroid Build Coastguard Worker VIR_SFU(ALLFEQ)
1460*61046927SAndroid Build Coastguard Worker VIR_SFU2(ROTQ)
1461*61046927SAndroid Build Coastguard Worker VIR_SFU2(ROT)
1462*61046927SAndroid Build Coastguard Worker VIR_SFU2(SHUFFLE)
1463*61046927SAndroid Build Coastguard Worker
1464*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(VPACK)
1465*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(V8PACK)
1466*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(V10PACK)
1467*61046927SAndroid Build Coastguard Worker VIR_A_ALU2(V11FPACK)
1468*61046927SAndroid Build Coastguard Worker
1469*61046927SAndroid Build Coastguard Worker VIR_M_ALU1(FTOUNORM16)
1470*61046927SAndroid Build Coastguard Worker VIR_M_ALU1(FTOSNORM16)
1471*61046927SAndroid Build Coastguard Worker
1472*61046927SAndroid Build Coastguard Worker VIR_M_ALU1(VFTOUNORM8)
1473*61046927SAndroid Build Coastguard Worker VIR_M_ALU1(VFTOSNORM8)
1474*61046927SAndroid Build Coastguard Worker
1475*61046927SAndroid Build Coastguard Worker VIR_M_ALU1(VFTOUNORM10LO)
1476*61046927SAndroid Build Coastguard Worker VIR_M_ALU1(VFTOUNORM10HI)
1477*61046927SAndroid Build Coastguard Worker
1478*61046927SAndroid Build Coastguard Worker static inline struct qinst *
1479*61046927SAndroid Build Coastguard Worker vir_MOV_cond(struct v3d_compile *c, enum v3d_qpu_cond cond,
1480*61046927SAndroid Build Coastguard Worker struct qreg dest, struct qreg src)
1481*61046927SAndroid Build Coastguard Worker {
1482*61046927SAndroid Build Coastguard Worker struct qinst *mov = vir_MOV_dest(c, dest, src);
1483*61046927SAndroid Build Coastguard Worker vir_set_cond(mov, cond);
1484*61046927SAndroid Build Coastguard Worker return mov;
1485*61046927SAndroid Build Coastguard Worker }
1486*61046927SAndroid Build Coastguard Worker
1487*61046927SAndroid Build Coastguard Worker static inline struct qreg
vir_SEL(struct v3d_compile * c,enum v3d_qpu_cond cond,struct qreg src0,struct qreg src1)1488*61046927SAndroid Build Coastguard Worker vir_SEL(struct v3d_compile *c, enum v3d_qpu_cond cond,
1489*61046927SAndroid Build Coastguard Worker struct qreg src0, struct qreg src1)
1490*61046927SAndroid Build Coastguard Worker {
1491*61046927SAndroid Build Coastguard Worker struct qreg t = vir_get_temp(c);
1492*61046927SAndroid Build Coastguard Worker vir_MOV_dest(c, t, src1);
1493*61046927SAndroid Build Coastguard Worker vir_MOV_cond(c, cond, t, src0);
1494*61046927SAndroid Build Coastguard Worker return t;
1495*61046927SAndroid Build Coastguard Worker }
1496*61046927SAndroid Build Coastguard Worker
1497*61046927SAndroid Build Coastguard Worker static inline struct qinst *
vir_NOP(struct v3d_compile * c)1498*61046927SAndroid Build Coastguard Worker vir_NOP(struct v3d_compile *c)
1499*61046927SAndroid Build Coastguard Worker {
1500*61046927SAndroid Build Coastguard Worker return vir_emit_nondef(c, vir_add_inst(V3D_QPU_A_NOP,
1501*61046927SAndroid Build Coastguard Worker c->undef, c->undef, c->undef));
1502*61046927SAndroid Build Coastguard Worker }
1503*61046927SAndroid Build Coastguard Worker
1504*61046927SAndroid Build Coastguard Worker static inline struct qreg
vir_LDTMU(struct v3d_compile * c)1505*61046927SAndroid Build Coastguard Worker vir_LDTMU(struct v3d_compile *c)
1506*61046927SAndroid Build Coastguard Worker {
1507*61046927SAndroid Build Coastguard Worker struct qinst *ldtmu = vir_add_inst(V3D_QPU_A_NOP, c->undef,
1508*61046927SAndroid Build Coastguard Worker c->undef, c->undef);
1509*61046927SAndroid Build Coastguard Worker ldtmu->qpu.sig.ldtmu = true;
1510*61046927SAndroid Build Coastguard Worker
1511*61046927SAndroid Build Coastguard Worker return vir_emit_def(c, ldtmu);
1512*61046927SAndroid Build Coastguard Worker }
1513*61046927SAndroid Build Coastguard Worker
1514*61046927SAndroid Build Coastguard Worker static inline struct qreg
vir_UMUL(struct v3d_compile * c,struct qreg src0,struct qreg src1)1515*61046927SAndroid Build Coastguard Worker vir_UMUL(struct v3d_compile *c, struct qreg src0, struct qreg src1)
1516*61046927SAndroid Build Coastguard Worker {
1517*61046927SAndroid Build Coastguard Worker vir_MULTOP(c, src0, src1);
1518*61046927SAndroid Build Coastguard Worker return vir_UMUL24(c, src0, src1);
1519*61046927SAndroid Build Coastguard Worker }
1520*61046927SAndroid Build Coastguard Worker
1521*61046927SAndroid Build Coastguard Worker static inline struct qreg
vir_TLBU_COLOR_READ(struct v3d_compile * c,uint32_t config)1522*61046927SAndroid Build Coastguard Worker vir_TLBU_COLOR_READ(struct v3d_compile *c, uint32_t config)
1523*61046927SAndroid Build Coastguard Worker {
1524*61046927SAndroid Build Coastguard Worker assert((config & 0xffffff00) == 0xffffff00);
1525*61046927SAndroid Build Coastguard Worker
1526*61046927SAndroid Build Coastguard Worker struct qinst *ldtlb = vir_add_inst(V3D_QPU_A_NOP, c->undef,
1527*61046927SAndroid Build Coastguard Worker c->undef, c->undef);
1528*61046927SAndroid Build Coastguard Worker ldtlb->qpu.sig.ldtlbu = true;
1529*61046927SAndroid Build Coastguard Worker ldtlb->uniform = vir_get_uniform_index(c, QUNIFORM_CONSTANT, config);
1530*61046927SAndroid Build Coastguard Worker return vir_emit_def(c, ldtlb);
1531*61046927SAndroid Build Coastguard Worker }
1532*61046927SAndroid Build Coastguard Worker
1533*61046927SAndroid Build Coastguard Worker static inline struct qreg
vir_TLB_COLOR_READ(struct v3d_compile * c)1534*61046927SAndroid Build Coastguard Worker vir_TLB_COLOR_READ(struct v3d_compile *c)
1535*61046927SAndroid Build Coastguard Worker {
1536*61046927SAndroid Build Coastguard Worker struct qinst *ldtlb = vir_add_inst(V3D_QPU_A_NOP, c->undef,
1537*61046927SAndroid Build Coastguard Worker c->undef, c->undef);
1538*61046927SAndroid Build Coastguard Worker ldtlb->qpu.sig.ldtlb = true;
1539*61046927SAndroid Build Coastguard Worker return vir_emit_def(c, ldtlb);
1540*61046927SAndroid Build Coastguard Worker }
1541*61046927SAndroid Build Coastguard Worker
1542*61046927SAndroid Build Coastguard Worker static inline struct qinst *
vir_BRANCH(struct v3d_compile * c,enum v3d_qpu_branch_cond cond)1543*61046927SAndroid Build Coastguard Worker vir_BRANCH(struct v3d_compile *c, enum v3d_qpu_branch_cond cond)
1544*61046927SAndroid Build Coastguard Worker {
1545*61046927SAndroid Build Coastguard Worker /* The actual uniform_data value will be set at scheduling time */
1546*61046927SAndroid Build Coastguard Worker return vir_emit_nondef(c, vir_branch_inst(c, cond));
1547*61046927SAndroid Build Coastguard Worker }
1548*61046927SAndroid Build Coastguard Worker
1549*61046927SAndroid Build Coastguard Worker #define vir_for_each_block(block, c) \
1550*61046927SAndroid Build Coastguard Worker list_for_each_entry(struct qblock, block, &c->blocks, link)
1551*61046927SAndroid Build Coastguard Worker
1552*61046927SAndroid Build Coastguard Worker #define vir_for_each_block_rev(block, c) \
1553*61046927SAndroid Build Coastguard Worker list_for_each_entry_rev(struct qblock, block, &c->blocks, link)
1554*61046927SAndroid Build Coastguard Worker
1555*61046927SAndroid Build Coastguard Worker /* Loop over the non-NULL members of the successors array. */
1556*61046927SAndroid Build Coastguard Worker #define vir_for_each_successor(succ, block) \
1557*61046927SAndroid Build Coastguard Worker for (struct qblock *succ = block->successors[0]; \
1558*61046927SAndroid Build Coastguard Worker succ != NULL; \
1559*61046927SAndroid Build Coastguard Worker succ = (succ == block->successors[1] ? NULL : \
1560*61046927SAndroid Build Coastguard Worker block->successors[1]))
1561*61046927SAndroid Build Coastguard Worker
1562*61046927SAndroid Build Coastguard Worker #define vir_for_each_inst(inst, block) \
1563*61046927SAndroid Build Coastguard Worker list_for_each_entry(struct qinst, inst, &block->instructions, link)
1564*61046927SAndroid Build Coastguard Worker
1565*61046927SAndroid Build Coastguard Worker #define vir_for_each_inst_rev(inst, block) \
1566*61046927SAndroid Build Coastguard Worker list_for_each_entry_rev(struct qinst, inst, &block->instructions, link)
1567*61046927SAndroid Build Coastguard Worker
1568*61046927SAndroid Build Coastguard Worker #define vir_for_each_inst_safe(inst, block) \
1569*61046927SAndroid Build Coastguard Worker list_for_each_entry_safe(struct qinst, inst, &block->instructions, link)
1570*61046927SAndroid Build Coastguard Worker
1571*61046927SAndroid Build Coastguard Worker #define vir_for_each_inst_inorder(inst, c) \
1572*61046927SAndroid Build Coastguard Worker vir_for_each_block(_block, c) \
1573*61046927SAndroid Build Coastguard Worker vir_for_each_inst(inst, _block)
1574*61046927SAndroid Build Coastguard Worker
1575*61046927SAndroid Build Coastguard Worker #define vir_for_each_inst_inorder_safe(inst, c) \
1576*61046927SAndroid Build Coastguard Worker vir_for_each_block(_block, c) \
1577*61046927SAndroid Build Coastguard Worker vir_for_each_inst_safe(inst, _block)
1578*61046927SAndroid Build Coastguard Worker
1579*61046927SAndroid Build Coastguard Worker #endif /* V3D_COMPILER_H */
1580