Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4358 Serge 1
/*
2
 * Copyright (c) 2012 Rob Clark 
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 "a2xx.xml.h"
32
 
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
} instr_scalar_opc_t;
90
 
91
typedef enum {
92
	ADDv = 0,
93
	MULv = 1,
94
	MAXv = 2,
95
	MINv = 3,
96
	SETEv = 4,
97
	SETGTv = 5,
98
	SETGTEv = 6,
99
	SETNEv = 7,
100
	FRACv = 8,
101
	TRUNCv = 9,
102
	FLOORv = 10,
103
	MULADDv = 11,
104
	CNDEv = 12,
105
	CNDGTEv = 13,
106
	CNDGTv = 14,
107
	DOT4v = 15,
108
	DOT3v = 16,
109
	DOT2ADDv = 17,
110
	CUBEv = 18,
111
	MAX4v = 19,
112
	PRED_SETE_PUSHv = 20,
113
	PRED_SETNE_PUSHv = 21,
114
	PRED_SETGT_PUSHv = 22,
115
	PRED_SETGTE_PUSHv = 23,
116
	KILLEv = 24,
117
	KILLGTv = 25,
118
	KILLGTEv = 26,
119
	KILLNEv = 27,
120
	DSTv = 28,
121
	MOVAv = 29,
122
} instr_vector_opc_t;
123
 
124
typedef struct PACKED {
125
	/* dword0: */
126
	uint8_t             vector_dest              : 6;
127
	uint8_t             vector_dest_rel          : 1;
128
	uint8_t             low_precision_16b_fp     : 1;
129
	uint8_t             scalar_dest              : 6;
130
	uint8_t             scalar_dest_rel          : 1;
131
	uint8_t             export_data              : 1;
132
	uint8_t             vector_write_mask        : 4;
133
	uint8_t             scalar_write_mask        : 4;
134
	uint8_t             vector_clamp             : 1;
135
	uint8_t             scalar_clamp             : 1;
136
	instr_scalar_opc_t  scalar_opc               : 6;
137
	/* dword1: */
138
	uint8_t             src3_swiz                : 8;
139
	uint8_t             src2_swiz                : 8;
140
	uint8_t             src1_swiz                : 8;
141
	uint8_t             src3_reg_negate          : 1;
142
	uint8_t             src2_reg_negate          : 1;
143
	uint8_t             src1_reg_negate          : 1;
144
	uint8_t             pred_select              : 2;
145
	uint8_t             relative_addr            : 1;
146
	uint8_t             const_1_rel_abs          : 1;
147
	uint8_t             const_0_rel_abs          : 1;
148
	/* dword2: */
149
	uint8_t             src3_reg                 : 6;
150
	uint8_t             src3_reg_select          : 1;
151
	uint8_t             src3_reg_abs             : 1;
152
	uint8_t             src2_reg                 : 6;
153
	uint8_t             src2_reg_select          : 1;
154
	uint8_t             src2_reg_abs             : 1;
155
	uint8_t             src1_reg                 : 6;
156
	uint8_t             src1_reg_select          : 1;
157
	uint8_t             src1_reg_abs             : 1;
158
	instr_vector_opc_t  vector_opc               : 5;
159
	uint8_t             src3_sel                 : 1;
160
	uint8_t             src2_sel                 : 1;
161
	uint8_t             src1_sel                 : 1;
162
} instr_alu_t;
163
 
164
 
165
 
166
/*
167
 * CF instructions:
168
 */
169
 
170
typedef enum {
171
	NOP = 0,
172
	EXEC = 1,
173
	EXEC_END = 2,
174
	COND_EXEC = 3,
175
	COND_EXEC_END = 4,
176
	COND_PRED_EXEC = 5,
177
	COND_PRED_EXEC_END = 6,
178
	LOOP_START = 7,
179
	LOOP_END = 8,
180
	COND_CALL = 9,
181
	RETURN = 10,
182
	COND_JMP = 11,
183
	ALLOC = 12,
184
	COND_EXEC_PRED_CLEAN = 13,
185
	COND_EXEC_PRED_CLEAN_END = 14,
186
	MARK_VS_FETCH_DONE = 15,
187
} instr_cf_opc_t;
188
 
189
typedef enum {
190
	RELATIVE_ADDR = 0,
191
	ABSOLUTE_ADDR = 1,
192
} instr_addr_mode_t;
193
 
194
typedef enum {
195
	SQ_NO_ALLOC = 0,
196
	SQ_POSITION = 1,
197
	SQ_PARAMETER_PIXEL = 2,
198
	SQ_MEMORY = 3,
199
} instr_alloc_type_t;
200
 
201
typedef struct PACKED {
202
	uint16_t            address                  : 9;
203
	uint8_t             reserved0                : 3;
204
	uint8_t             count                    : 3;
205
	uint8_t             yeild                    : 1;
206
	uint16_t            serialize                : 12;
207
	uint8_t             vc                       : 6;   /* vertex cache? */
208
	uint8_t             bool_addr                : 8;
209
	uint8_t             condition                : 1;
210
	instr_addr_mode_t   address_mode             : 1;
211
	instr_cf_opc_t      opc                      : 4;
212
} instr_cf_exec_t;
213
 
214
typedef struct PACKED {
215
	uint16_t            address                  : 10;
216
	uint8_t             reserved0                : 6;
217
	uint8_t             loop_id                  : 5;
218
	uint32_t            reserved1                : 22;
219
	instr_addr_mode_t   address_mode             : 1;
220
	instr_cf_opc_t      opc                      : 4;
221
} instr_cf_loop_t;
222
 
223
typedef struct PACKED {
224
	uint16_t            address                  : 10;
225
	uint8_t             reserved0                : 3;
226
	uint8_t             force_call               : 1;
227
	uint8_t             predicated_jmp           : 1;
228
	uint32_t            reserved1                : 18;
229
	uint8_t             direction                : 1;
230
	uint8_t             bool_addr                : 8;
231
	uint8_t             condition                : 1;
232
	instr_addr_mode_t   address_mode             : 1;
233
	instr_cf_opc_t      opc                      : 4;
234
} instr_cf_jmp_call_t;
235
 
236
typedef struct PACKED {
237
	uint8_t             size                     : 4;
238
	uint64_t            reserved0                : 36;
239
	uint8_t             no_serial                : 1;
240
	instr_alloc_type_t  buffer_select            : 2;
241
	uint8_t             alloc_mode               : 1;
242
	instr_cf_opc_t      opc                      : 4;
243
} instr_cf_alloc_t;
244
 
245
typedef union PACKED {
246
	instr_cf_exec_t     exec;
247
	instr_cf_loop_t     loop;
248
	instr_cf_jmp_call_t jmp_call;
249
	instr_cf_alloc_t    alloc;
250
	struct PACKED {
251
		uint64_t        dummy                    : 44;
252
		instr_cf_opc_t  opc                      : 4;
253
	};
254
} instr_cf_t;
255
 
256
 
257
 
258
/*
259
 * FETCH instructions:
260
 */
261
 
262
typedef enum {
263
	VTX_FETCH = 0,
264
	TEX_FETCH = 1,
265
	TEX_GET_BORDER_COLOR_FRAC = 16,
266
	TEX_GET_COMP_TEX_LOD = 17,
267
	TEX_GET_GRADIENTS = 18,
268
	TEX_GET_WEIGHTS = 19,
269
	TEX_SET_TEX_LOD = 24,
270
	TEX_SET_GRADIENTS_H = 25,
271
	TEX_SET_GRADIENTS_V = 26,
272
	TEX_RESERVED_4 = 27,
273
} instr_fetch_opc_t;
274
 
275
typedef enum {
276
	TEX_FILTER_POINT = 0,
277
	TEX_FILTER_LINEAR = 1,
278
	TEX_FILTER_BASEMAP = 2,            /* only applicable for mip-filter */
279
	TEX_FILTER_USE_FETCH_CONST = 3,
280
} instr_tex_filter_t;
281
 
282
typedef enum {
283
	ANISO_FILTER_DISABLED = 0,
284
	ANISO_FILTER_MAX_1_1 = 1,
285
	ANISO_FILTER_MAX_2_1 = 2,
286
	ANISO_FILTER_MAX_4_1 = 3,
287
	ANISO_FILTER_MAX_8_1 = 4,
288
	ANISO_FILTER_MAX_16_1 = 5,
289
	ANISO_FILTER_USE_FETCH_CONST = 7,
290
} instr_aniso_filter_t;
291
 
292
typedef enum {
293
	ARBITRARY_FILTER_2X4_SYM = 0,
294
	ARBITRARY_FILTER_2X4_ASYM = 1,
295
	ARBITRARY_FILTER_4X2_SYM = 2,
296
	ARBITRARY_FILTER_4X2_ASYM = 3,
297
	ARBITRARY_FILTER_4X4_SYM = 4,
298
	ARBITRARY_FILTER_4X4_ASYM = 5,
299
	ARBITRARY_FILTER_USE_FETCH_CONST = 7,
300
} instr_arbitrary_filter_t;
301
 
302
typedef enum {
303
	SAMPLE_CENTROID = 0,
304
	SAMPLE_CENTER = 1,
305
} instr_sample_loc_t;
306
 
307
typedef enum a2xx_sq_surfaceformat instr_surf_fmt_t;
308
 
309
typedef struct PACKED {
310
	/* dword0: */
311
	instr_fetch_opc_t   opc                      : 5;
312
	uint8_t             src_reg                  : 6;
313
	uint8_t             src_reg_am               : 1;
314
	uint8_t             dst_reg                  : 6;
315
	uint8_t             dst_reg_am               : 1;
316
	uint8_t             fetch_valid_only         : 1;
317
	uint8_t             const_idx                : 5;
318
	uint8_t             tx_coord_denorm          : 1;
319
	uint8_t             src_swiz                 : 6;
320
	/* dword1: */
321
	uint16_t            dst_swiz                 : 12;
322
	instr_tex_filter_t  mag_filter               : 2;
323
	instr_tex_filter_t  min_filter               : 2;
324
	instr_tex_filter_t  mip_filter               : 2;
325
	instr_aniso_filter_t aniso_filter            : 3;
326
	instr_arbitrary_filter_t arbitrary_filter    : 3;
327
	instr_tex_filter_t  vol_mag_filter           : 2;
328
	instr_tex_filter_t  vol_min_filter           : 2;
329
	uint8_t             use_comp_lod             : 1;
330
	uint8_t             use_reg_lod              : 2;  /* 0 for cube, 1 for 2d */
331
	uint8_t             pred_select              : 1;
332
	/* dword2: */
333
	uint8_t             use_reg_gradients        : 1;
334
	instr_sample_loc_t  sample_location          : 1;
335
	uint8_t             lod_bias                 : 7;
336
	uint8_t             unused                   : 7;
337
	uint8_t             offset_x                 : 5;
338
	uint8_t             offset_y                 : 5;
339
	uint8_t             offset_z                 : 5;
340
	uint8_t             pred_condition           : 1;
341
} instr_fetch_tex_t;
342
 
343
typedef struct PACKED {
344
	/* dword0: */
345
	instr_fetch_opc_t   opc                      : 5;
346
	uint8_t             src_reg                  : 6;
347
	uint8_t             src_reg_am               : 1;
348
	uint8_t             dst_reg                  : 6;
349
	uint8_t             dst_reg_am               : 1;
350
	uint8_t             must_be_one              : 1;
351
	uint8_t             const_index              : 5;
352
	uint8_t             const_index_sel          : 2;
353
	uint8_t             reserved0                : 3;
354
	uint8_t             src_swiz                 : 2;
355
	/* dword1: */
356
	uint16_t            dst_swiz                 : 12;
357
	uint8_t             format_comp_all          : 1;   /* '1' for signed, '0' for unsigned? */
358
	uint8_t             num_format_all           : 1;   /* '0' for normalized, '1' for unnormalized */
359
	uint8_t             signed_rf_mode_all       : 1;
360
	uint8_t             reserved1                : 1;
361
	instr_surf_fmt_t    format                   : 6;
362
	uint8_t             reserved2                : 1;
363
	uint8_t             exp_adjust_all           : 7;
364
	uint8_t             reserved3                : 1;
365
	uint8_t             pred_select              : 1;
366
	/* dword2: */
367
	uint8_t             stride                   : 8;
368
	/* possibly offset and reserved4 are swapped on a200? */
369
	uint8_t             offset                   : 8;
370
	uint8_t             reserved4                : 8;
371
	uint8_t             reserved5                : 7;
372
	uint8_t             pred_condition           : 1;
373
} instr_fetch_vtx_t;
374
 
375
typedef union PACKED {
376
	instr_fetch_tex_t   tex;
377
	instr_fetch_vtx_t   vtx;
378
	struct PACKED {
379
		/* dword0: */
380
		instr_fetch_opc_t opc                    : 5;
381
		uint32_t        dummy0                   : 27;
382
		/* dword1: */
383
		uint32_t        dummy1                   : 32;
384
		/* dword2: */
385
		uint32_t        dummy2                   : 32;
386
	};
387
} instr_fetch_t;
388
 
389
#endif /* INSTR_H_ */