• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2012 Rob Clark <robdclark@gmail.com>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  */
23 
24 #ifndef INSTR_A2XX_H_
25 #define INSTR_A2XX_H_
26 
27 #define PACKED __attribute__((__packed__))
28 
29 #include "util/u_math.h"
30 #include "adreno_common.xml.h"
31 #include "adreno_pm4.xml.h"
32 #include "a2xx.xml.h"
33 
34 /*
35  * ALU instructions:
36  */
37 
38 typedef enum {
39    ADDs = 0,
40    ADD_PREVs = 1,
41    MULs = 2,
42    MUL_PREVs = 3,
43    MUL_PREV2s = 4,
44    MAXs = 5,
45    MINs = 6,
46    SETEs = 7,
47    SETGTs = 8,
48    SETGTEs = 9,
49    SETNEs = 10,
50    FRACs = 11,
51    TRUNCs = 12,
52    FLOORs = 13,
53    EXP_IEEE = 14,
54    LOG_CLAMP = 15,
55    LOG_IEEE = 16,
56    RECIP_CLAMP = 17,
57    RECIP_FF = 18,
58    RECIP_IEEE = 19,
59    RECIPSQ_CLAMP = 20,
60    RECIPSQ_FF = 21,
61    RECIPSQ_IEEE = 22,
62    MOVAs = 23,
63    MOVA_FLOORs = 24,
64    SUBs = 25,
65    SUB_PREVs = 26,
66    PRED_SETEs = 27,
67    PRED_SETNEs = 28,
68    PRED_SETGTs = 29,
69    PRED_SETGTEs = 30,
70    PRED_SET_INVs = 31,
71    PRED_SET_POPs = 32,
72    PRED_SET_CLRs = 33,
73    PRED_SET_RESTOREs = 34,
74    KILLEs = 35,
75    KILLGTs = 36,
76    KILLGTEs = 37,
77    KILLNEs = 38,
78    KILLONEs = 39,
79    SQRT_IEEE = 40,
80    MUL_CONST_0 = 42,
81    MUL_CONST_1 = 43,
82    ADD_CONST_0 = 44,
83    ADD_CONST_1 = 45,
84    SUB_CONST_0 = 46,
85    SUB_CONST_1 = 47,
86    SIN = 48,
87    COS = 49,
88    RETAIN_PREV = 50,
89    SCALAR_NONE = 63,
90 } instr_scalar_opc_t;
91 
92 typedef enum {
93    ADDv = 0,
94    MULv = 1,
95    MAXv = 2,
96    MINv = 3,
97    SETEv = 4,
98    SETGTv = 5,
99    SETGTEv = 6,
100    SETNEv = 7,
101    FRACv = 8,
102    TRUNCv = 9,
103    FLOORv = 10,
104    MULADDv = 11,
105    CNDEv = 12,
106    CNDGTEv = 13,
107    CNDGTv = 14,
108    DOT4v = 15,
109    DOT3v = 16,
110    DOT2ADDv = 17,
111    CUBEv = 18,
112    MAX4v = 19,
113    PRED_SETE_PUSHv = 20,
114    PRED_SETNE_PUSHv = 21,
115    PRED_SETGT_PUSHv = 22,
116    PRED_SETGTE_PUSHv = 23,
117    KILLEv = 24,
118    KILLGTv = 25,
119    KILLGTEv = 26,
120    KILLNEv = 27,
121    DSTv = 28,
122    MOVAv = 29,
123    VECTOR_NONE = 31,
124 } instr_vector_opc_t;
125 
126 typedef struct PACKED {
127    /* dword0: */
128    uint8_t vector_dest : 6;
129    uint8_t vector_dest_rel : 1;
130    uint8_t low_precision_16b_fp : 1;
131    uint8_t scalar_dest : 6;
132    uint8_t scalar_dest_rel : 1;
133    uint8_t export_data : 1;
134    uint8_t vector_write_mask : 4;
135    uint8_t scalar_write_mask : 4;
136    uint8_t vector_clamp : 1;
137    uint8_t scalar_clamp : 1;
138    instr_scalar_opc_t scalar_opc : 6;
139    /* dword1: */
140    uint8_t src3_swiz : 8;
141    uint8_t src2_swiz : 8;
142    uint8_t src1_swiz : 8;
143    uint8_t src3_reg_negate : 1;
144    uint8_t src2_reg_negate : 1;
145    uint8_t src1_reg_negate : 1;
146    uint8_t pred_select : 2;
147    uint8_t relative_addr : 1;
148    uint8_t const_1_rel_abs : 1;
149    uint8_t const_0_rel_abs : 1;
150    /* dword2: */
151    union {
152       struct {
153          uint8_t src3_reg : 6;
154          uint8_t src3_reg_select : 1;
155          uint8_t src3_reg_abs : 1;
156          uint8_t src2_reg : 6;
157          uint8_t src2_reg_select : 1;
158          uint8_t src2_reg_abs : 1;
159          uint8_t src1_reg : 6;
160          uint8_t src1_reg_select : 1;
161          uint8_t src1_reg_abs : 1;
162       };
163       /* constants have full 8-bit index */
164       struct {
165          uint8_t src3_reg_byte : 8;
166          uint8_t src2_reg_byte : 8;
167          uint8_t src1_reg_byte : 8;
168       };
169    };
170    instr_vector_opc_t vector_opc : 5;
171    uint8_t src3_sel : 1;
172    uint8_t src2_sel : 1;
173    uint8_t src1_sel : 1;
174 } instr_alu_t;
175 
176 /*
177  * CF instructions:
178  */
179 
180 typedef enum {
181    NOP = 0,
182    EXEC = 1,
183    EXEC_END = 2,
184    COND_EXEC = 3,
185    COND_EXEC_END = 4,
186    COND_PRED_EXEC = 5,
187    COND_PRED_EXEC_END = 6,
188    LOOP_START = 7,
189    LOOP_END = 8,
190    COND_CALL = 9,
191    RETURN = 10,
192    COND_JMP = 11,
193    ALLOC = 12,
194    COND_EXEC_PRED_CLEAN = 13,
195    COND_EXEC_PRED_CLEAN_END = 14,
196    MARK_VS_FETCH_DONE = 15,
197 } instr_cf_opc_t;
198 
199 typedef enum {
200    RELATIVE_ADDR = 0,
201    ABSOLUTE_ADDR = 1,
202 } instr_addr_mode_t;
203 
204 typedef enum {
205    SQ_NO_ALLOC = 0,
206    SQ_POSITION = 1,
207    SQ_PARAMETER_PIXEL = 2,
208    SQ_MEMORY = 3,
209 } instr_alloc_type_t;
210 
211 typedef struct PACKED {
212    uint16_t address : 9;
213    uint8_t reserved0 : 3;
214    uint8_t count : 3;
215    uint8_t yeild : 1;
216    uint16_t serialize : 12;
217    uint32_t vc : 6; /* vertex cache? */
218    uint32_t bool_addr : 8;
219    uint8_t condition : 1;
220    instr_addr_mode_t address_mode : 1;
221    instr_cf_opc_t opc : 4;
222 } instr_cf_exec_t;
223 
224 typedef struct PACKED {
225    uint16_t address : 10;
226    uint8_t reserved0 : 6;
227    uint8_t loop_id : 5;
228    uint32_t reserved1 : 22;
229    instr_addr_mode_t address_mode : 1;
230    instr_cf_opc_t opc : 4;
231 } instr_cf_loop_t;
232 
233 typedef struct PACKED {
234    uint16_t address : 10;
235    uint8_t reserved0 : 3;
236    uint8_t force_call : 1;
237    uint8_t predicated_jmp : 1;
238    uint32_t reserved1 : 18;
239    uint8_t direction : 1;
240    uint32_t bool_addr : 8;
241    uint8_t condition : 1;
242    instr_addr_mode_t address_mode : 1;
243    instr_cf_opc_t opc : 4;
244 } instr_cf_jmp_call_t;
245 
246 typedef struct PACKED {
247    uint8_t size : 4;
248    uint64_t reserved0 : 36;
249    uint8_t no_serial : 1;
250    instr_alloc_type_t buffer_select : 2;
251    uint8_t alloc_mode : 1;
252    instr_cf_opc_t opc : 4;
253 } instr_cf_alloc_t;
254 
255 typedef union PACKED {
256    instr_cf_exec_t exec;
257    instr_cf_loop_t loop;
258    instr_cf_jmp_call_t jmp_call;
259    instr_cf_alloc_t alloc;
260    struct PACKED {
261       uint64_t dummy : 44;
262       instr_cf_opc_t opc : 4;
263    };
264 } instr_cf_t;
265 
266 /*
267  * FETCH instructions:
268  */
269 
270 typedef enum {
271    VTX_FETCH = 0,
272    TEX_FETCH = 1,
273    TEX_GET_BORDER_COLOR_FRAC = 16,
274    TEX_GET_COMP_TEX_LOD = 17,
275    TEX_GET_GRADIENTS = 18,
276    TEX_GET_WEIGHTS = 19,
277    TEX_SET_TEX_LOD = 24,
278    TEX_SET_GRADIENTS_H = 25,
279    TEX_SET_GRADIENTS_V = 26,
280    TEX_RESERVED_4 = 27,
281 } instr_fetch_opc_t;
282 
283 typedef enum {
284    TEX_FILTER_POINT = 0,
285    TEX_FILTER_LINEAR = 1,
286    TEX_FILTER_BASEMAP = 2, /* only applicable for mip-filter */
287    TEX_FILTER_USE_FETCH_CONST = 3,
288 } instr_tex_filter_t;
289 
290 typedef enum {
291    ANISO_FILTER_DISABLED = 0,
292    ANISO_FILTER_MAX_1_1 = 1,
293    ANISO_FILTER_MAX_2_1 = 2,
294    ANISO_FILTER_MAX_4_1 = 3,
295    ANISO_FILTER_MAX_8_1 = 4,
296    ANISO_FILTER_MAX_16_1 = 5,
297    ANISO_FILTER_USE_FETCH_CONST = 7,
298 } instr_aniso_filter_t;
299 
300 typedef enum {
301    ARBITRARY_FILTER_2X4_SYM = 0,
302    ARBITRARY_FILTER_2X4_ASYM = 1,
303    ARBITRARY_FILTER_4X2_SYM = 2,
304    ARBITRARY_FILTER_4X2_ASYM = 3,
305    ARBITRARY_FILTER_4X4_SYM = 4,
306    ARBITRARY_FILTER_4X4_ASYM = 5,
307    ARBITRARY_FILTER_USE_FETCH_CONST = 7,
308 } instr_arbitrary_filter_t;
309 
310 typedef enum {
311    SAMPLE_CENTROID = 0,
312    SAMPLE_CENTER = 1,
313 } instr_sample_loc_t;
314 
315 typedef enum a2xx_sq_surfaceformat instr_surf_fmt_t;
316 
317 typedef struct PACKED {
318    /* dword0: */
319    instr_fetch_opc_t opc : 5;
320    uint32_t src_reg : 6;
321    uint8_t src_reg_am : 1;
322    uint32_t dst_reg : 6;
323    uint8_t dst_reg_am : 1;
324    uint8_t fetch_valid_only : 1;
325    uint32_t const_idx : 5;
326    uint8_t tx_coord_denorm : 1;
327    uint8_t src_swiz : 6;
328    /* dword1: */
329    uint16_t dst_swiz : 12;
330    instr_tex_filter_t mag_filter : 2;
331    instr_tex_filter_t min_filter : 2;
332    instr_tex_filter_t mip_filter : 2;
333    instr_aniso_filter_t aniso_filter : 3;
334    instr_arbitrary_filter_t arbitrary_filter : 3;
335    instr_tex_filter_t vol_mag_filter : 2;
336    instr_tex_filter_t vol_min_filter : 2;
337    uint8_t use_comp_lod : 1;
338    uint8_t use_reg_lod : 2; /* 0 for cube, 1 for 2d */
339    uint8_t pred_select : 1;
340    /* dword2: */
341    uint8_t use_reg_gradients : 1;
342    instr_sample_loc_t sample_location : 1;
343    uint32_t lod_bias : 7;
344    uint8_t unused : 7;
345    uint8_t offset_x : 5;
346    uint32_t offset_y : 5;
347    uint8_t offset_z : 5;
348    uint8_t pred_condition : 1;
349 } instr_fetch_tex_t;
350 
351 typedef struct PACKED {
352    /* dword0: */
353    instr_fetch_opc_t opc : 5;
354    uint32_t src_reg : 6;
355    uint8_t src_reg_am : 1;
356    uint32_t dst_reg : 6;
357    uint8_t dst_reg_am : 1;
358    uint8_t must_be_one : 1;
359    uint32_t const_index : 5;
360    uint8_t const_index_sel : 2;
361    uint8_t reserved0 : 3;
362    uint8_t src_swiz : 2;
363    /* dword1: */
364    uint16_t dst_swiz : 12;
365    uint8_t format_comp_all : 1; /* '1' for signed, '0' for unsigned? */
366    uint8_t num_format_all : 1;  /* '0' for normalized, '1' for unnormalized */
367    uint8_t signed_rf_mode_all : 1;
368    uint8_t reserved1 : 1;
369    instr_surf_fmt_t format : 6;
370    uint8_t reserved2 : 2;
371    uint8_t exp_adjust_all : 6;
372    uint8_t reserved3 : 1;
373    uint8_t pred_select : 1;
374    /* dword2: */
375    uint8_t stride : 8;
376    uint32_t offset : 22;
377    uint8_t reserved4 : 1;
378    uint8_t pred_condition : 1;
379 } instr_fetch_vtx_t;
380 
381 typedef union PACKED {
382    instr_fetch_tex_t tex;
383    instr_fetch_vtx_t vtx;
384    struct PACKED {
385       /* dword0: */
386       instr_fetch_opc_t opc : 5;
387       uint32_t dummy0 : 27;
388       /* dword1: */
389       uint32_t dummy1 : 31;
390       uint8_t pred_select : 1;
391       /* dword2: */
392       uint32_t dummy2 : 31;
393       uint8_t pred_condition : 1;
394    };
395 } instr_fetch_t;
396 
397 typedef union PACKED {
398    instr_alu_t alu;
399    instr_fetch_t fetch;
400 } instr_t;
401 
402 #endif /* INSTR_H_ */
403