2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
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
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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include "util/u_format.h"
27 #include "util/u_memory.h"
28 #include "pipe/p_shader_tokens.h"
29 #include "r600_pipe.h"
31 #include "r600_opcodes.h"
33 #include "r600_formats.h"
36 #define NUM_OF_CYCLES 3
37 #define NUM_OF_COMPONENTS 4
39 static inline unsigned int r600_bytecode_get_num_operands(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
44 switch (bc
->chip_class
) {
48 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
:
50 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
:
51 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
:
52 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
:
53 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
:
54 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT
:
55 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLE
:
56 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
:
57 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGE
:
58 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLNE
:
59 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
:
60 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_INT
:
61 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_INT
:
62 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
:
63 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
:
64 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
:
65 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
:
66 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT
:
67 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT
:
68 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT
:
69 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT
:
70 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
:
71 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT
:
72 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
:
73 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT
:
74 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
:
75 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
:
76 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_UINT
:
77 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
:
78 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT
:
79 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
:
80 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE
:
81 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT
:
82 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE
:
83 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
:
84 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
:
85 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
:
86 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4_IEEE
:
87 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
:
88 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
:
89 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT
:
90 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
:
91 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT
:
94 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
:
95 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA
:
96 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR
:
97 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_GPR_INT
:
98 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
:
99 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
:
100 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
:
101 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
:
102 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
:
103 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
:
104 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
:
105 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
:
106 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
:
107 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_UINT
:
108 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
:
109 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
:
110 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
:
111 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
:
112 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
:
113 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
:
114 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
:
115 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
:
116 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE
:
117 case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT
:
120 "Need instruction operand number for 0x%x.\n", alu
->inst
);
126 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
:
128 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
:
129 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
:
130 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
:
131 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
:
132 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT
:
133 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLE
:
134 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
:
135 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGE
:
136 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLNE
:
137 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
:
138 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_INT
:
139 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_INT
:
140 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
:
141 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
:
142 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
:
143 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
:
144 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT
:
145 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT
:
146 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT
:
147 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT
:
148 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
:
149 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT
:
150 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
:
151 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT
:
152 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
:
153 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
:
154 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_UINT
:
155 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
:
156 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT
:
157 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
:
158 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE
:
159 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT
:
160 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE
:
161 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
:
162 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
:
163 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
:
164 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4_IEEE
:
165 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
:
166 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_XY
:
167 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW
:
168 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
:
169 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT
:
170 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
:
171 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT
:
174 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
:
175 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
:
176 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
:
177 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
:
178 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
:
179 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
:
180 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
:
181 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
:
182 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
:
183 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
:
184 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
:
185 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
:
186 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
:
187 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR
:
188 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
:
189 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
:
190 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
:
191 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
:
192 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
:
193 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE
:
194 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT
:
195 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_LOAD_P0
:
196 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_INT
:
197 case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_UINT
:
200 "Need instruction operand number for 0x%x.\n", alu
->inst
);
208 int r700_bytecode_alu_build(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
, unsigned id
);
210 static struct r600_bytecode_cf
*r600_bytecode_cf(void)
212 struct r600_bytecode_cf
*cf
= CALLOC_STRUCT(r600_bytecode_cf
);
216 LIST_INITHEAD(&cf
->list
);
217 LIST_INITHEAD(&cf
->alu
);
218 LIST_INITHEAD(&cf
->vtx
);
219 LIST_INITHEAD(&cf
->tex
);
223 static struct r600_bytecode_alu
*r600_bytecode_alu(void)
225 struct r600_bytecode_alu
*alu
= CALLOC_STRUCT(r600_bytecode_alu
);
229 LIST_INITHEAD(&alu
->list
);
233 static struct r600_bytecode_vtx
*r600_bytecode_vtx(void)
235 struct r600_bytecode_vtx
*vtx
= CALLOC_STRUCT(r600_bytecode_vtx
);
239 LIST_INITHEAD(&vtx
->list
);
243 static struct r600_bytecode_tex
*r600_bytecode_tex(void)
245 struct r600_bytecode_tex
*tex
= CALLOC_STRUCT(r600_bytecode_tex
);
249 LIST_INITHEAD(&tex
->list
);
253 void r600_bytecode_init(struct r600_bytecode
*bc
, enum chip_class chip_class
, enum radeon_family family
)
255 if ((chip_class
== R600
) && (family
!= CHIP_RV670
))
256 bc
->ar_handling
= AR_HANDLE_RV6XX
;
258 bc
->ar_handling
= AR_HANDLE_NORMAL
;
260 if ((chip_class
== R600
) && (family
!= CHIP_RV670
&& family
!= CHIP_RS780
&&
261 family
!= CHIP_RS880
))
262 bc
->r6xx_nop_after_rel_dst
= 1;
264 bc
->r6xx_nop_after_rel_dst
= 0;
265 LIST_INITHEAD(&bc
->cf
);
266 bc
->chip_class
= chip_class
;
269 static int r600_bytecode_add_cf(struct r600_bytecode
*bc
)
271 struct r600_bytecode_cf
*cf
= r600_bytecode_cf();
275 LIST_ADDTAIL(&cf
->list
, &bc
->cf
);
277 cf
->id
= bc
->cf_last
->id
+ 2;
278 if (bc
->cf_last
->eg_alu_extended
) {
279 /* take into account extended alu size */
287 bc
->force_add_cf
= 0;
292 int r600_bytecode_add_output(struct r600_bytecode
*bc
, const struct r600_bytecode_output
*output
)
296 if (bc
->cf_last
&& (bc
->cf_last
->inst
== output
->inst
||
297 (bc
->cf_last
->inst
== BC_INST(bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
) &&
298 output
->inst
== BC_INST(bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
))) &&
299 output
->type
== bc
->cf_last
->output
.type
&&
300 output
->elem_size
== bc
->cf_last
->output
.elem_size
&&
301 output
->swizzle_x
== bc
->cf_last
->output
.swizzle_x
&&
302 output
->swizzle_y
== bc
->cf_last
->output
.swizzle_y
&&
303 output
->swizzle_z
== bc
->cf_last
->output
.swizzle_z
&&
304 output
->swizzle_w
== bc
->cf_last
->output
.swizzle_w
&&
305 (output
->burst_count
+ bc
->cf_last
->output
.burst_count
) <= 16) {
307 if ((output
->gpr
+ output
->burst_count
) == bc
->cf_last
->output
.gpr
&&
308 (output
->array_base
+ output
->burst_count
) == bc
->cf_last
->output
.array_base
) {
310 bc
->cf_last
->output
.end_of_program
|= output
->end_of_program
;
311 bc
->cf_last
->output
.inst
= output
->inst
;
312 bc
->cf_last
->output
.gpr
= output
->gpr
;
313 bc
->cf_last
->output
.array_base
= output
->array_base
;
314 bc
->cf_last
->output
.burst_count
+= output
->burst_count
;
317 } else if (output
->gpr
== (bc
->cf_last
->output
.gpr
+ bc
->cf_last
->output
.burst_count
) &&
318 output
->array_base
== (bc
->cf_last
->output
.array_base
+ bc
->cf_last
->output
.burst_count
)) {
320 bc
->cf_last
->output
.end_of_program
|= output
->end_of_program
;
321 bc
->cf_last
->output
.inst
= output
->inst
;
322 bc
->cf_last
->output
.burst_count
+= output
->burst_count
;
327 r
= r600_bytecode_add_cf(bc
);
330 bc
->cf_last
->inst
= output
->inst
;
331 memcpy(&bc
->cf_last
->output
, output
, sizeof(struct r600_bytecode_output
));
335 /* alu instructions that can ony exits once per group */
336 static int is_alu_once_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
338 switch (bc
->chip_class
) {
341 return !alu
->is_op3
&& (
342 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLE
||
343 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
||
344 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGE
||
345 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLNE
||
346 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT_UINT
||
347 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGE_UINT
||
348 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLE_INT
||
349 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT_INT
||
350 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGE_INT
||
351 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLNE_INT
||
352 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT_UINT
||
353 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE_UINT
||
354 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE
||
355 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT
||
356 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE
||
357 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
||
358 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SET_INV
||
359 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SET_POP
||
360 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SET_CLR
||
361 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SET_RESTORE
||
362 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_PUSH
||
363 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT_PUSH
||
364 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE_PUSH
||
365 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_PUSH
||
366 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_INT
||
367 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT_INT
||
368 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE_INT
||
369 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
||
370 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_PUSH_INT
||
371 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT_PUSH_INT
||
372 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE_PUSH_INT
||
373 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_PUSH_INT
||
374 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETLT_PUSH_INT
||
375 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETLE_PUSH_INT
);
379 return !alu
->is_op3
&& (
380 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLE
||
381 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
||
382 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGE
||
383 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLNE
||
384 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT_UINT
||
385 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGE_UINT
||
386 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLE_INT
||
387 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT_INT
||
388 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGE_INT
||
389 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLNE_INT
||
390 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT_UINT
||
391 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE_UINT
||
392 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE
||
393 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT
||
394 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE
||
395 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
||
396 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SET_INV
||
397 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SET_POP
||
398 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SET_CLR
||
399 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SET_RESTORE
||
400 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_PUSH
||
401 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT_PUSH
||
402 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE_PUSH
||
403 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_PUSH
||
404 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_INT
||
405 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT_INT
||
406 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE_INT
||
407 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
||
408 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_PUSH_INT
||
409 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGT_PUSH_INT
||
410 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETGE_PUSH_INT
||
411 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_PUSH_INT
||
412 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETLT_PUSH_INT
||
413 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETLE_PUSH_INT
);
417 static int is_alu_reduction_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
419 switch (bc
->chip_class
) {
422 return !alu
->is_op3
&& (
423 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
||
424 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
||
425 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4_IEEE
||
426 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX4
);
430 return !alu
->is_op3
&& (
431 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
||
432 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
||
433 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4_IEEE
||
434 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX4
);
438 static int is_alu_cube_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
440 switch (bc
->chip_class
) {
443 return !alu
->is_op3
&&
444 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
;
448 return !alu
->is_op3
&&
449 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
;
453 static int is_alu_mova_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
455 switch (bc
->chip_class
) {
458 return !alu
->is_op3
&& (
459 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA
||
460 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR
||
461 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
||
462 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_GPR_INT
);
466 return !alu
->is_op3
&& (
467 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
);
471 /* alu instructions that can only execute on the vector unit */
472 static int is_alu_vec_unit_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
474 switch (bc
->chip_class
) {
477 return is_alu_reduction_inst(bc
, alu
) ||
478 (is_alu_mova_inst(bc
, alu
) &&
479 (alu
->inst
!= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_GPR_INT
));
483 return is_alu_reduction_inst(bc
, alu
) ||
484 is_alu_mova_inst(bc
, alu
) ||
485 (alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
||
486 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR
||
487 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_LOAD_P0
||
488 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_XY
||
489 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW
);
493 /* alu instructions that can only execute on the trans unit */
494 static int is_alu_trans_unit_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
496 switch (bc
->chip_class
) {
500 return alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT
||
501 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_GPR_INT
||
502 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
||
503 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
||
504 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
||
505 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT
||
506 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
||
507 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_INT
||
508 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
||
509 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_INT
||
510 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
||
511 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_INT
||
512 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_UINT
||
513 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
||
514 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
||
515 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
||
516 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
||
517 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
||
518 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
||
519 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_FF
||
520 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
||
521 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
||
522 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_FF
||
523 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
||
524 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
||
525 alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SQRT_IEEE
;
527 return alu
->inst
== V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
||
528 alu
->inst
== V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT_D2
||
529 alu
->inst
== V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT_M2
||
530 alu
->inst
== V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT_M4
;
535 /* Note that FLT_TO_INT_* instructions are vector-only instructions
536 * on Evergreen, despite what the documentation says. FLT_TO_INT
537 * can do both vector and scalar. */
538 return alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
||
539 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_INT
||
540 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
||
541 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_INT
||
542 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
||
543 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_INT
||
544 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_UINT
||
545 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
||
546 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
||
547 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
||
548 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
||
549 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
||
550 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
||
551 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
||
552 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_FF
||
553 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
||
554 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
||
555 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_FF
||
556 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
||
557 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
||
558 alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SQRT_IEEE
;
560 return alu
->inst
== EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
;
564 /* alu instructions that can execute on any unit */
565 static int is_alu_any_unit_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
567 return !is_alu_vec_unit_inst(bc
, alu
) &&
568 !is_alu_trans_unit_inst(bc
, alu
);
571 static int is_nop_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
573 switch (bc
->chip_class
) {
576 return (!alu
->is_op3
&& alu
->inst
== V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
580 return (!alu
->is_op3
&& alu
->inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
584 static int assign_alu_units(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu_first
,
585 struct r600_bytecode_alu
*assignment
[5])
587 struct r600_bytecode_alu
*alu
;
588 unsigned i
, chan
, trans
;
589 int max_slots
= bc
->chip_class
== CAYMAN
? 4 : 5;
591 for (i
= 0; i
< max_slots
; i
++)
592 assignment
[i
] = NULL
;
594 for (alu
= alu_first
; alu
; alu
= LIST_ENTRY(struct r600_bytecode_alu
, alu
->list
.next
, list
)) {
595 chan
= alu
->dst
.chan
;
598 else if (is_alu_trans_unit_inst(bc
, alu
))
600 else if (is_alu_vec_unit_inst(bc
, alu
))
602 else if (assignment
[chan
])
603 trans
= 1; /* Assume ALU_INST_PREFER_VECTOR. */
609 assert(0); /* ALU.Trans has already been allocated. */
614 if (assignment
[chan
]) {
615 assert(0); /* ALU.chan has already been allocated. */
618 assignment
[chan
] = alu
;
627 struct alu_bank_swizzle
{
628 int hw_gpr
[NUM_OF_CYCLES
][NUM_OF_COMPONENTS
];
629 int hw_cfile_addr
[4];
630 int hw_cfile_elem
[4];
633 static const unsigned cycle_for_bank_swizzle_vec
[][3] = {
634 [SQ_ALU_VEC_012
] = { 0, 1, 2 },
635 [SQ_ALU_VEC_021
] = { 0, 2, 1 },
636 [SQ_ALU_VEC_120
] = { 1, 2, 0 },
637 [SQ_ALU_VEC_102
] = { 1, 0, 2 },
638 [SQ_ALU_VEC_201
] = { 2, 0, 1 },
639 [SQ_ALU_VEC_210
] = { 2, 1, 0 }
642 static const unsigned cycle_for_bank_swizzle_scl
[][3] = {
643 [SQ_ALU_SCL_210
] = { 2, 1, 0 },
644 [SQ_ALU_SCL_122
] = { 1, 2, 2 },
645 [SQ_ALU_SCL_212
] = { 2, 1, 2 },
646 [SQ_ALU_SCL_221
] = { 2, 2, 1 }
649 static void init_bank_swizzle(struct alu_bank_swizzle
*bs
)
651 int i
, cycle
, component
;
653 for (cycle
= 0; cycle
< NUM_OF_CYCLES
; cycle
++)
654 for (component
= 0; component
< NUM_OF_COMPONENTS
; component
++)
655 bs
->hw_gpr
[cycle
][component
] = -1;
656 for (i
= 0; i
< 4; i
++)
657 bs
->hw_cfile_addr
[i
] = -1;
658 for (i
= 0; i
< 4; i
++)
659 bs
->hw_cfile_elem
[i
] = -1;
662 static int reserve_gpr(struct alu_bank_swizzle
*bs
, unsigned sel
, unsigned chan
, unsigned cycle
)
664 if (bs
->hw_gpr
[cycle
][chan
] == -1)
665 bs
->hw_gpr
[cycle
][chan
] = sel
;
666 else if (bs
->hw_gpr
[cycle
][chan
] != (int)sel
) {
667 /* Another scalar operation has already used the GPR read port for the channel. */
673 static int reserve_cfile(struct r600_bytecode
*bc
, struct alu_bank_swizzle
*bs
, unsigned sel
, unsigned chan
)
675 int res
, num_res
= 4;
676 if (bc
->chip_class
>= R700
) {
680 for (res
= 0; res
< num_res
; ++res
) {
681 if (bs
->hw_cfile_addr
[res
] == -1) {
682 bs
->hw_cfile_addr
[res
] = sel
;
683 bs
->hw_cfile_elem
[res
] = chan
;
685 } else if (bs
->hw_cfile_addr
[res
] == sel
&&
686 bs
->hw_cfile_elem
[res
] == chan
)
687 return 0; /* Read for this scalar element already reserved, nothing to do here. */
689 /* All cfile read ports are used, cannot reference vector element. */
693 static int is_gpr(unsigned sel
)
695 return (sel
>= 0 && sel
<= 127);
698 /* CB constants start at 512, and get translated to a kcache index when ALU
699 * clauses are constructed. Note that we handle kcache constants the same way
700 * as (the now gone) cfile constants, is that really required? */
701 static int is_cfile(unsigned sel
)
703 return (sel
> 255 && sel
< 512) ||
704 (sel
> 511 && sel
< 4607) || /* Kcache before translation. */
705 (sel
> 127 && sel
< 192); /* Kcache after translation. */
708 static int is_const(int sel
)
710 return is_cfile(sel
) ||
711 (sel
>= V_SQ_ALU_SRC_0
&&
712 sel
<= V_SQ_ALU_SRC_LITERAL
);
715 static int check_vector(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
,
716 struct alu_bank_swizzle
*bs
, int bank_swizzle
)
718 int r
, src
, num_src
, sel
, elem
, cycle
;
720 num_src
= r600_bytecode_get_num_operands(bc
, alu
);
721 for (src
= 0; src
< num_src
; src
++) {
722 sel
= alu
->src
[src
].sel
;
723 elem
= alu
->src
[src
].chan
;
725 cycle
= cycle_for_bank_swizzle_vec
[bank_swizzle
][src
];
726 if (src
== 1 && sel
== alu
->src
[0].sel
&& elem
== alu
->src
[0].chan
)
727 /* Nothing to do; special-case optimization,
728 * second source uses first source’s reservation. */
731 r
= reserve_gpr(bs
, sel
, elem
, cycle
);
735 } else if (is_cfile(sel
)) {
736 r
= reserve_cfile(bc
, bs
, sel
, elem
);
740 /* No restrictions on PV, PS, literal or special constants. */
745 static int check_scalar(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
,
746 struct alu_bank_swizzle
*bs
, int bank_swizzle
)
748 int r
, src
, num_src
, const_count
, sel
, elem
, cycle
;
750 num_src
= r600_bytecode_get_num_operands(bc
, alu
);
751 for (const_count
= 0, src
= 0; src
< num_src
; ++src
) {
752 sel
= alu
->src
[src
].sel
;
753 elem
= alu
->src
[src
].chan
;
754 if (is_const(sel
)) { /* Any constant, including literal and inline constants. */
755 if (const_count
>= 2)
756 /* More than two references to a constant in
757 * transcendental operation. */
763 r
= reserve_cfile(bc
, bs
, sel
, elem
);
768 for (src
= 0; src
< num_src
; ++src
) {
769 sel
= alu
->src
[src
].sel
;
770 elem
= alu
->src
[src
].chan
;
772 cycle
= cycle_for_bank_swizzle_scl
[bank_swizzle
][src
];
773 if (cycle
< const_count
)
774 /* Cycle for GPR load conflicts with
775 * constant load in transcendental operation. */
777 r
= reserve_gpr(bs
, sel
, elem
, cycle
);
781 /* PV PS restrictions */
782 if (const_count
&& (sel
== 254 || sel
== 255)) {
783 cycle
= cycle_for_bank_swizzle_scl
[bank_swizzle
][src
];
784 if (cycle
< const_count
)
791 static int check_and_set_bank_swizzle(struct r600_bytecode
*bc
,
792 struct r600_bytecode_alu
*slots
[5])
794 struct alu_bank_swizzle bs
;
796 int i
, r
= 0, forced
= 1;
797 boolean scalar_only
= bc
->chip_class
== CAYMAN
? false : true;
798 int max_slots
= bc
->chip_class
== CAYMAN
? 4 : 5;
800 for (i
= 0; i
< max_slots
; i
++) {
802 if (slots
[i
]->bank_swizzle_force
) {
803 slots
[i
]->bank_swizzle
= slots
[i
]->bank_swizzle_force
;
809 if (i
< 4 && slots
[i
])
815 /* Just check every possible combination of bank swizzle.
816 * Not very efficent, but works on the first try in most of the cases. */
817 for (i
= 0; i
< 4; i
++)
818 if (!slots
[i
] || !slots
[i
]->bank_swizzle_force
)
819 bank_swizzle
[i
] = SQ_ALU_VEC_012
;
821 bank_swizzle
[i
] = slots
[i
]->bank_swizzle
;
823 bank_swizzle
[4] = SQ_ALU_SCL_210
;
824 while(bank_swizzle
[4] <= SQ_ALU_SCL_221
) {
826 if (max_slots
== 4) {
827 for (i
= 0; i
< max_slots
; i
++) {
828 if (bank_swizzle
[i
] == SQ_ALU_VEC_210
)
832 init_bank_swizzle(&bs
);
833 if (scalar_only
== false) {
834 for (i
= 0; i
< 4; i
++) {
836 r
= check_vector(bc
, slots
[i
], &bs
, bank_swizzle
[i
]);
844 if (!r
&& slots
[4] && max_slots
== 5) {
845 r
= check_scalar(bc
, slots
[4], &bs
, bank_swizzle
[4]);
848 for (i
= 0; i
< max_slots
; i
++) {
850 slots
[i
]->bank_swizzle
= bank_swizzle
[i
];
858 for (i
= 0; i
< max_slots
; i
++) {
859 if (!slots
[i
] || !slots
[i
]->bank_swizzle_force
) {
861 if (bank_swizzle
[i
] <= SQ_ALU_VEC_210
)
864 bank_swizzle
[i
] = SQ_ALU_VEC_012
;
870 /* Couldn't find a working swizzle. */
874 static int replace_gpr_with_pv_ps(struct r600_bytecode
*bc
,
875 struct r600_bytecode_alu
*slots
[5], struct r600_bytecode_alu
*alu_prev
)
877 struct r600_bytecode_alu
*prev
[5];
879 int i
, j
, r
, src
, num_src
;
880 int max_slots
= bc
->chip_class
== CAYMAN
? 4 : 5;
882 r
= assign_alu_units(bc
, alu_prev
, prev
);
886 for (i
= 0; i
< max_slots
; ++i
) {
887 if (prev
[i
] && (prev
[i
]->dst
.write
|| prev
[i
]->is_op3
) && !prev
[i
]->dst
.rel
) {
888 gpr
[i
] = prev
[i
]->dst
.sel
;
889 /* cube writes more than PV.X */
890 if (!is_alu_cube_inst(bc
, prev
[i
]) && is_alu_reduction_inst(bc
, prev
[i
]))
893 chan
[i
] = prev
[i
]->dst
.chan
;
898 for (i
= 0; i
< max_slots
; ++i
) {
899 struct r600_bytecode_alu
*alu
= slots
[i
];
903 num_src
= r600_bytecode_get_num_operands(bc
, alu
);
904 for (src
= 0; src
< num_src
; ++src
) {
905 if (!is_gpr(alu
->src
[src
].sel
) || alu
->src
[src
].rel
)
908 if (bc
->chip_class
< CAYMAN
) {
909 if (alu
->src
[src
].sel
== gpr
[4] &&
910 alu
->src
[src
].chan
== chan
[4]) {
911 alu
->src
[src
].sel
= V_SQ_ALU_SRC_PS
;
912 alu
->src
[src
].chan
= 0;
917 for (j
= 0; j
< 4; ++j
) {
918 if (alu
->src
[src
].sel
== gpr
[j
] &&
919 alu
->src
[src
].chan
== j
) {
920 alu
->src
[src
].sel
= V_SQ_ALU_SRC_PV
;
921 alu
->src
[src
].chan
= chan
[j
];
931 void r600_bytecode_special_constants(u32 value
, unsigned *sel
, unsigned *neg
)
935 *sel
= V_SQ_ALU_SRC_0
;
938 *sel
= V_SQ_ALU_SRC_1_INT
;
941 *sel
= V_SQ_ALU_SRC_M_1_INT
;
943 case 0x3F800000: /* 1.0f */
944 *sel
= V_SQ_ALU_SRC_1
;
946 case 0x3F000000: /* 0.5f */
947 *sel
= V_SQ_ALU_SRC_0_5
;
949 case 0xBF800000: /* -1.0f */
950 *sel
= V_SQ_ALU_SRC_1
;
953 case 0xBF000000: /* -0.5f */
954 *sel
= V_SQ_ALU_SRC_0_5
;
958 *sel
= V_SQ_ALU_SRC_LITERAL
;
963 /* compute how many literal are needed */
964 static int r600_bytecode_alu_nliterals(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
,
965 uint32_t literal
[4], unsigned *nliteral
)
967 unsigned num_src
= r600_bytecode_get_num_operands(bc
, alu
);
970 for (i
= 0; i
< num_src
; ++i
) {
971 if (alu
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
972 uint32_t value
= alu
->src
[i
].value
;
974 for (j
= 0; j
< *nliteral
; ++j
) {
975 if (literal
[j
] == value
) {
983 literal
[(*nliteral
)++] = value
;
990 static void r600_bytecode_alu_adjust_literals(struct r600_bytecode
*bc
,
991 struct r600_bytecode_alu
*alu
,
992 uint32_t literal
[4], unsigned nliteral
)
994 unsigned num_src
= r600_bytecode_get_num_operands(bc
, alu
);
997 for (i
= 0; i
< num_src
; ++i
) {
998 if (alu
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
999 uint32_t value
= alu
->src
[i
].value
;
1000 for (j
= 0; j
< nliteral
; ++j
) {
1001 if (literal
[j
] == value
) {
1002 alu
->src
[i
].chan
= j
;
1010 static int merge_inst_groups(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*slots
[5],
1011 struct r600_bytecode_alu
*alu_prev
)
1013 struct r600_bytecode_alu
*prev
[5];
1014 struct r600_bytecode_alu
*result
[5] = { NULL
};
1016 uint32_t literal
[4], prev_literal
[4];
1017 unsigned nliteral
= 0, prev_nliteral
= 0;
1019 int i
, j
, r
, src
, num_src
;
1020 int num_once_inst
= 0;
1021 int have_mova
= 0, have_rel
= 0;
1022 int max_slots
= bc
->chip_class
== CAYMAN
? 4 : 5;
1024 r
= assign_alu_units(bc
, alu_prev
, prev
);
1028 for (i
= 0; i
< max_slots
; ++i
) {
1029 struct r600_bytecode_alu
*alu
;
1031 /* check number of literals */
1033 if (r600_bytecode_alu_nliterals(bc
, prev
[i
], literal
, &nliteral
))
1035 if (r600_bytecode_alu_nliterals(bc
, prev
[i
], prev_literal
, &prev_nliteral
))
1037 if (is_alu_mova_inst(bc
, prev
[i
])) {
1042 num_once_inst
+= is_alu_once_inst(bc
, prev
[i
]);
1044 if (slots
[i
] && r600_bytecode_alu_nliterals(bc
, slots
[i
], literal
, &nliteral
))
1047 /* Let's check used slots. */
1048 if (prev
[i
] && !slots
[i
]) {
1049 result
[i
] = prev
[i
];
1051 } else if (prev
[i
] && slots
[i
]) {
1052 if (max_slots
== 5 && result
[4] == NULL
&& prev
[4] == NULL
&& slots
[4] == NULL
) {
1053 /* Trans unit is still free try to use it. */
1054 if (is_alu_any_unit_inst(bc
, slots
[i
])) {
1055 result
[i
] = prev
[i
];
1056 result
[4] = slots
[i
];
1057 } else if (is_alu_any_unit_inst(bc
, prev
[i
])) {
1058 if (slots
[i
]->dst
.sel
== prev
[i
]->dst
.sel
&&
1059 (slots
[i
]->dst
.write
== 1 || slots
[i
]->is_op3
) &&
1060 (prev
[i
]->dst
.write
== 1 || prev
[i
]->is_op3
))
1063 result
[i
] = slots
[i
];
1064 result
[4] = prev
[i
];
1069 } else if(!slots
[i
]) {
1072 if (max_slots
== 5 && slots
[i
] && prev
[4] &&
1073 slots
[i
]->dst
.sel
== prev
[4]->dst
.sel
&&
1074 slots
[i
]->dst
.chan
== prev
[4]->dst
.chan
&&
1075 (slots
[i
]->dst
.write
== 1 || slots
[i
]->is_op3
) &&
1076 (prev
[4]->dst
.write
== 1 || prev
[4]->is_op3
))
1079 result
[i
] = slots
[i
];
1083 num_once_inst
+= is_alu_once_inst(bc
, alu
);
1085 /* don't reschedule NOPs */
1086 if (is_nop_inst(bc
, alu
))
1089 /* Let's check dst gpr. */
1096 /* Let's check source gprs */
1097 num_src
= r600_bytecode_get_num_operands(bc
, alu
);
1098 for (src
= 0; src
< num_src
; ++src
) {
1099 if (alu
->src
[src
].rel
) {
1105 /* Constants don't matter. */
1106 if (!is_gpr(alu
->src
[src
].sel
))
1109 for (j
= 0; j
< max_slots
; ++j
) {
1110 if (!prev
[j
] || !(prev
[j
]->dst
.write
|| prev
[j
]->is_op3
))
1113 /* If it's relative then we can't determin which gpr is really used. */
1114 if (prev
[j
]->dst
.chan
== alu
->src
[src
].chan
&&
1115 (prev
[j
]->dst
.sel
== alu
->src
[src
].sel
||
1116 prev
[j
]->dst
.rel
|| alu
->src
[src
].rel
))
1122 /* more than one PRED_ or KILL_ ? */
1123 if (num_once_inst
> 1)
1126 /* check if the result can still be swizzlet */
1127 r
= check_and_set_bank_swizzle(bc
, result
);
1131 /* looks like everything worked out right, apply the changes */
1133 /* undo adding previus literals */
1134 bc
->cf_last
->ndw
-= align(prev_nliteral
, 2);
1136 /* sort instructions */
1137 for (i
= 0; i
< max_slots
; ++i
) {
1138 slots
[i
] = result
[i
];
1140 LIST_DEL(&result
[i
]->list
);
1141 result
[i
]->last
= 0;
1142 LIST_ADDTAIL(&result
[i
]->list
, &bc
->cf_last
->alu
);
1146 /* determine new last instruction */
1147 LIST_ENTRY(struct r600_bytecode_alu
, bc
->cf_last
->alu
.prev
, list
)->last
= 1;
1149 /* determine new first instruction */
1150 for (i
= 0; i
< max_slots
; ++i
) {
1152 bc
->cf_last
->curr_bs_head
= result
[i
];
1157 bc
->cf_last
->prev_bs_head
= bc
->cf_last
->prev2_bs_head
;
1158 bc
->cf_last
->prev2_bs_head
= NULL
;
1163 /* we'll keep kcache sets sorted by bank & addr */
1164 static int r600_bytecode_alloc_kcache_line(struct r600_bytecode
*bc
,
1165 struct r600_bytecode_kcache
*kcache
,
1166 unsigned bank
, unsigned line
)
1168 int i
, kcache_banks
= bc
->chip_class
>= EVERGREEN
? 4 : 2;
1170 for (i
= 0; i
< kcache_banks
; i
++) {
1171 if (kcache
[i
].mode
) {
1174 if (kcache
[i
].bank
< bank
)
1177 if ((kcache
[i
].bank
== bank
&& kcache
[i
].addr
> line
+1) ||
1178 kcache
[i
].bank
> bank
) {
1179 /* try to insert new line */
1180 if (kcache
[kcache_banks
-1].mode
) {
1181 /* all sets are in use */
1185 memmove(&kcache
[i
+1],&kcache
[i
], (kcache_banks
-i
-1)*sizeof(struct r600_bytecode_kcache
));
1186 kcache
[i
].mode
= V_SQ_CF_KCACHE_LOCK_1
;
1187 kcache
[i
].bank
= bank
;
1188 kcache
[i
].addr
= line
;
1192 d
= line
- kcache
[i
].addr
;
1196 if (kcache
[i
].mode
== V_SQ_CF_KCACHE_LOCK_2
) {
1197 /* we are prepending the line to the current set,
1198 * discarding the existing second line,
1199 * so we'll have to insert line+2 after it */
1202 } else if (kcache
[i
].mode
== V_SQ_CF_KCACHE_LOCK_1
) {
1203 kcache
[i
].mode
= V_SQ_CF_KCACHE_LOCK_2
;
1206 /* V_SQ_CF_KCACHE_LOCK_LOOP_INDEX is not supported */
1209 } else if (d
== 1) {
1210 kcache
[i
].mode
= V_SQ_CF_KCACHE_LOCK_2
;
1214 } else { /* free kcache set - use it */
1215 kcache
[i
].mode
= V_SQ_CF_KCACHE_LOCK_1
;
1216 kcache
[i
].bank
= bank
;
1217 kcache
[i
].addr
= line
;
1224 static int r600_bytecode_alloc_inst_kcache_lines(struct r600_bytecode
*bc
,
1225 struct r600_bytecode_kcache
*kcache
,
1226 struct r600_bytecode_alu
*alu
)
1230 for (i
= 0; i
< 3; i
++) {
1231 unsigned bank
, line
, sel
= alu
->src
[i
].sel
;
1236 bank
= alu
->src
[i
].kc_bank
;
1237 line
= (sel
-512)>>4;
1239 if ((r
= r600_bytecode_alloc_kcache_line(bc
, kcache
, bank
, line
)))
1245 static int r600_bytecode_assign_kcache_banks(struct r600_bytecode
*bc
,
1246 struct r600_bytecode_alu
*alu
,
1247 struct r600_bytecode_kcache
* kcache
)
1251 /* Alter the src operands to refer to the kcache. */
1252 for (i
= 0; i
< 3; ++i
) {
1253 static const unsigned int base
[] = {128, 160, 256, 288};
1254 unsigned int line
, sel
= alu
->src
[i
].sel
, found
= 0;
1262 for (j
= 0; j
< 4 && !found
; ++j
) {
1263 switch (kcache
[j
].mode
) {
1264 case V_SQ_CF_KCACHE_NOP
:
1265 case V_SQ_CF_KCACHE_LOCK_LOOP_INDEX
:
1266 R600_ERR("unexpected kcache line mode\n");
1269 if (kcache
[j
].bank
== alu
->src
[i
].kc_bank
&&
1270 kcache
[j
].addr
<= line
&&
1271 line
< kcache
[j
].addr
+ kcache
[j
].mode
) {
1272 alu
->src
[i
].sel
= sel
- (kcache
[j
].addr
<<4);
1273 alu
->src
[i
].sel
+= base
[j
];
1282 static int r600_bytecode_alloc_kcache_lines(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
, int type
)
1284 struct r600_bytecode_kcache kcache_sets
[4];
1285 struct r600_bytecode_kcache
*kcache
= kcache_sets
;
1288 memcpy(kcache
, bc
->cf_last
->kcache
, 4 * sizeof(struct r600_bytecode_kcache
));
1290 if ((r
= r600_bytecode_alloc_inst_kcache_lines(bc
, kcache
, alu
))) {
1291 /* can't alloc, need to start new clause */
1292 if ((r
= r600_bytecode_add_cf(bc
))) {
1295 bc
->cf_last
->inst
= type
;
1297 /* retry with the new clause */
1298 kcache
= bc
->cf_last
->kcache
;
1299 if ((r
= r600_bytecode_alloc_inst_kcache_lines(bc
, kcache
, alu
))) {
1300 /* can't alloc again- should never happen */
1304 /* update kcache sets */
1305 memcpy(bc
->cf_last
->kcache
, kcache
, 4 * sizeof(struct r600_bytecode_kcache
));
1308 /* if we actually used more than 2 kcache sets - use ALU_EXTENDED on eg+ */
1309 if (kcache
[2].mode
!= V_SQ_CF_KCACHE_NOP
) {
1310 if (bc
->chip_class
< EVERGREEN
)
1312 bc
->cf_last
->eg_alu_extended
= 1;
1318 static int insert_nop_r6xx(struct r600_bytecode
*bc
)
1320 struct r600_bytecode_alu alu
;
1323 for (i
= 0; i
< 4; i
++) {
1324 memset(&alu
, 0, sizeof(alu
));
1325 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
;
1326 alu
.src
[0].chan
= i
;
1328 alu
.last
= (i
== 3);
1329 r
= r600_bytecode_add_alu(bc
, &alu
);
1336 /* load AR register from gpr (bc->ar_reg) with MOVA_INT */
1337 static int load_ar_r6xx(struct r600_bytecode
*bc
)
1339 struct r600_bytecode_alu alu
;
1345 /* hack to avoid making MOVA the last instruction in the clause */
1346 if ((bc
->cf_last
->ndw
>>1) >= 110)
1347 bc
->force_add_cf
= 1;
1349 memset(&alu
, 0, sizeof(alu
));
1350 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_GPR_INT
;
1351 alu
.src
[0].sel
= bc
->ar_reg
;
1353 alu
.index_mode
= INDEX_MODE_LOOP
;
1354 r
= r600_bytecode_add_alu(bc
, &alu
);
1358 /* no requirement to set uses waterfall on MOVA_GPR_INT */
1363 /* load AR register from gpr (bc->ar_reg) with MOVA_INT */
1364 static int load_ar(struct r600_bytecode
*bc
)
1366 struct r600_bytecode_alu alu
;
1369 if (bc
->ar_handling
)
1370 return load_ar_r6xx(bc
);
1375 /* hack to avoid making MOVA the last instruction in the clause */
1376 if ((bc
->cf_last
->ndw
>>1) >= 110)
1377 bc
->force_add_cf
= 1;
1379 memset(&alu
, 0, sizeof(alu
));
1380 alu
.inst
= BC_INST(bc
, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
);
1381 alu
.src
[0].sel
= bc
->ar_reg
;
1383 r
= r600_bytecode_add_alu(bc
, &alu
);
1387 bc
->cf_last
->r6xx_uses_waterfall
= 1;
1392 int r600_bytecode_add_alu_type(struct r600_bytecode
*bc
, const struct r600_bytecode_alu
*alu
, int type
)
1394 struct r600_bytecode_alu
*nalu
= r600_bytecode_alu();
1395 struct r600_bytecode_alu
*lalu
;
1400 memcpy(nalu
, alu
, sizeof(struct r600_bytecode_alu
));
1402 if (bc
->cf_last
!= NULL
&& bc
->cf_last
->inst
!= type
) {
1403 /* check if we could add it anyway */
1404 if (bc
->cf_last
->inst
== BC_INST(bc
, V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
) &&
1405 type
== BC_INST(bc
, V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
)) {
1406 LIST_FOR_EACH_ENTRY(lalu
, &bc
->cf_last
->alu
, list
) {
1407 if (lalu
->predicate
) {
1408 bc
->force_add_cf
= 1;
1413 bc
->force_add_cf
= 1;
1416 /* cf can contains only alu or only vtx or only tex */
1417 if (bc
->cf_last
== NULL
|| bc
->force_add_cf
) {
1418 r
= r600_bytecode_add_cf(bc
);
1424 bc
->cf_last
->inst
= type
;
1426 /* Check AR usage and load it if required */
1427 for (i
= 0; i
< 3; i
++)
1428 if (nalu
->src
[i
].rel
&& !bc
->ar_loaded
)
1431 if (nalu
->dst
.rel
&& !bc
->ar_loaded
)
1434 /* Setup the kcache for this ALU instruction. This will start a new
1435 * ALU clause if needed. */
1436 if ((r
= r600_bytecode_alloc_kcache_lines(bc
, nalu
, type
))) {
1441 if (!bc
->cf_last
->curr_bs_head
) {
1442 bc
->cf_last
->curr_bs_head
= nalu
;
1444 /* number of gpr == the last gpr used in any alu */
1445 for (i
= 0; i
< 3; i
++) {
1446 if (nalu
->src
[i
].sel
>= bc
->ngpr
&& nalu
->src
[i
].sel
< 128) {
1447 bc
->ngpr
= nalu
->src
[i
].sel
+ 1;
1449 if (nalu
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
)
1450 r600_bytecode_special_constants(nalu
->src
[i
].value
,
1451 &nalu
->src
[i
].sel
, &nalu
->src
[i
].neg
);
1453 if (nalu
->dst
.sel
>= bc
->ngpr
) {
1454 bc
->ngpr
= nalu
->dst
.sel
+ 1;
1456 LIST_ADDTAIL(&nalu
->list
, &bc
->cf_last
->alu
);
1457 /* each alu use 2 dwords */
1458 bc
->cf_last
->ndw
+= 2;
1461 /* process cur ALU instructions for bank swizzle */
1463 uint32_t literal
[4];
1465 struct r600_bytecode_alu
*slots
[5];
1466 int max_slots
= bc
->chip_class
== CAYMAN
? 4 : 5;
1467 r
= assign_alu_units(bc
, bc
->cf_last
->curr_bs_head
, slots
);
1471 if (bc
->cf_last
->prev_bs_head
) {
1472 r
= merge_inst_groups(bc
, slots
, bc
->cf_last
->prev_bs_head
);
1477 if (bc
->cf_last
->prev_bs_head
) {
1478 r
= replace_gpr_with_pv_ps(bc
, slots
, bc
->cf_last
->prev_bs_head
);
1483 r
= check_and_set_bank_swizzle(bc
, slots
);
1487 for (i
= 0, nliteral
= 0; i
< max_slots
; i
++) {
1489 r
= r600_bytecode_alu_nliterals(bc
, slots
[i
], literal
, &nliteral
);
1494 bc
->cf_last
->ndw
+= align(nliteral
, 2);
1496 /* at most 128 slots, one add alu can add 5 slots + 4 constants(2 slots)
1498 if ((bc
->cf_last
->ndw
>> 1) >= 120) {
1499 bc
->force_add_cf
= 1;
1502 bc
->cf_last
->prev2_bs_head
= bc
->cf_last
->prev_bs_head
;
1503 bc
->cf_last
->prev_bs_head
= bc
->cf_last
->curr_bs_head
;
1504 bc
->cf_last
->curr_bs_head
= NULL
;
1507 if (nalu
->dst
.rel
&& bc
->r6xx_nop_after_rel_dst
)
1508 insert_nop_r6xx(bc
);
1513 int r600_bytecode_add_alu(struct r600_bytecode
*bc
, const struct r600_bytecode_alu
*alu
)
1515 return r600_bytecode_add_alu_type(bc
, alu
, BC_INST(bc
, V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
1518 static unsigned r600_bytecode_num_tex_and_vtx_instructions(const struct r600_bytecode
*bc
)
1520 switch (bc
->chip_class
) {
1530 R600_ERR("Unknown chip class %d.\n", bc
->chip_class
);
1535 static inline boolean
last_inst_was_not_vtx_fetch(struct r600_bytecode
*bc
)
1537 switch (bc
->chip_class
) {
1540 return bc
->cf_last
->inst
!= V_SQ_CF_WORD1_SQ_CF_INST_VTX
&&
1541 bc
->cf_last
->inst
!= V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC
;
1543 return bc
->cf_last
->inst
!= EG_V_SQ_CF_WORD1_SQ_CF_INST_VTX
;
1545 return bc
->cf_last
->inst
!= CM_V_SQ_CF_WORD1_SQ_CF_INST_TC
;
1547 R600_ERR("Unknown chip class %d.\n", bc
->chip_class
);
1552 int r600_bytecode_add_vtx(struct r600_bytecode
*bc
, const struct r600_bytecode_vtx
*vtx
)
1554 struct r600_bytecode_vtx
*nvtx
= r600_bytecode_vtx();
1559 memcpy(nvtx
, vtx
, sizeof(struct r600_bytecode_vtx
));
1561 /* cf can contains only alu or only vtx or only tex */
1562 if (bc
->cf_last
== NULL
||
1563 last_inst_was_not_vtx_fetch(bc
) ||
1565 r
= r600_bytecode_add_cf(bc
);
1570 switch (bc
->chip_class
) {
1573 bc
->cf_last
->inst
= V_SQ_CF_WORD1_SQ_CF_INST_VTX
;
1576 bc
->cf_last
->inst
= EG_V_SQ_CF_WORD1_SQ_CF_INST_VTX
;
1579 bc
->cf_last
->inst
= CM_V_SQ_CF_WORD1_SQ_CF_INST_TC
;
1582 R600_ERR("Unknown chip class %d.\n", bc
->chip_class
);
1586 LIST_ADDTAIL(&nvtx
->list
, &bc
->cf_last
->vtx
);
1587 /* each fetch use 4 dwords */
1588 bc
->cf_last
->ndw
+= 4;
1590 if ((bc
->cf_last
->ndw
/ 4) >= r600_bytecode_num_tex_and_vtx_instructions(bc
))
1591 bc
->force_add_cf
= 1;
1595 int r600_bytecode_add_tex(struct r600_bytecode
*bc
, const struct r600_bytecode_tex
*tex
)
1597 struct r600_bytecode_tex
*ntex
= r600_bytecode_tex();
1602 memcpy(ntex
, tex
, sizeof(struct r600_bytecode_tex
));
1604 /* we can't fetch data und use it as texture lookup address in the same TEX clause */
1605 if (bc
->cf_last
!= NULL
&&
1606 bc
->cf_last
->inst
== BC_INST(bc
, V_SQ_CF_WORD1_SQ_CF_INST_TEX
)) {
1607 struct r600_bytecode_tex
*ttex
;
1608 LIST_FOR_EACH_ENTRY(ttex
, &bc
->cf_last
->tex
, list
) {
1609 if (ttex
->dst_gpr
== ntex
->src_gpr
) {
1610 bc
->force_add_cf
= 1;
1614 /* slight hack to make gradients always go into same cf */
1615 if (ntex
->inst
== SQ_TEX_INST_SET_GRADIENTS_H
)
1616 bc
->force_add_cf
= 1;
1619 /* cf can contains only alu or only vtx or only tex */
1620 if (bc
->cf_last
== NULL
||
1621 bc
->cf_last
->inst
!= BC_INST(bc
, V_SQ_CF_WORD1_SQ_CF_INST_TEX
) ||
1623 r
= r600_bytecode_add_cf(bc
);
1628 bc
->cf_last
->inst
= BC_INST(bc
, V_SQ_CF_WORD1_SQ_CF_INST_TEX
);
1630 if (ntex
->src_gpr
>= bc
->ngpr
) {
1631 bc
->ngpr
= ntex
->src_gpr
+ 1;
1633 if (ntex
->dst_gpr
>= bc
->ngpr
) {
1634 bc
->ngpr
= ntex
->dst_gpr
+ 1;
1636 LIST_ADDTAIL(&ntex
->list
, &bc
->cf_last
->tex
);
1637 /* each texture fetch use 4 dwords */
1638 bc
->cf_last
->ndw
+= 4;
1640 if ((bc
->cf_last
->ndw
/ 4) >= r600_bytecode_num_tex_and_vtx_instructions(bc
))
1641 bc
->force_add_cf
= 1;
1645 int r600_bytecode_add_cfinst(struct r600_bytecode
*bc
, int inst
)
1648 r
= r600_bytecode_add_cf(bc
);
1652 bc
->cf_last
->cond
= V_SQ_CF_COND_ACTIVE
;
1653 bc
->cf_last
->inst
= inst
;
1657 int cm_bytecode_add_cf_end(struct r600_bytecode
*bc
)
1659 return r600_bytecode_add_cfinst(bc
, CM_V_SQ_CF_WORD1_SQ_CF_INST_END
);
1662 /* common to all 3 families */
1663 static int r600_bytecode_vtx_build(struct r600_bytecode
*bc
, struct r600_bytecode_vtx
*vtx
, unsigned id
)
1665 bc
->bytecode
[id
] = S_SQ_VTX_WORD0_BUFFER_ID(vtx
->buffer_id
) |
1666 S_SQ_VTX_WORD0_FETCH_TYPE(vtx
->fetch_type
) |
1667 S_SQ_VTX_WORD0_SRC_GPR(vtx
->src_gpr
) |
1668 S_SQ_VTX_WORD0_SRC_SEL_X(vtx
->src_sel_x
);
1669 if (bc
->chip_class
< CAYMAN
)
1670 bc
->bytecode
[id
] |= S_SQ_VTX_WORD0_MEGA_FETCH_COUNT(vtx
->mega_fetch_count
);
1672 bc
->bytecode
[id
++] = S_SQ_VTX_WORD1_DST_SEL_X(vtx
->dst_sel_x
) |
1673 S_SQ_VTX_WORD1_DST_SEL_Y(vtx
->dst_sel_y
) |
1674 S_SQ_VTX_WORD1_DST_SEL_Z(vtx
->dst_sel_z
) |
1675 S_SQ_VTX_WORD1_DST_SEL_W(vtx
->dst_sel_w
) |
1676 S_SQ_VTX_WORD1_USE_CONST_FIELDS(vtx
->use_const_fields
) |
1677 S_SQ_VTX_WORD1_DATA_FORMAT(vtx
->data_format
) |
1678 S_SQ_VTX_WORD1_NUM_FORMAT_ALL(vtx
->num_format_all
) |
1679 S_SQ_VTX_WORD1_FORMAT_COMP_ALL(vtx
->format_comp_all
) |
1680 S_SQ_VTX_WORD1_SRF_MODE_ALL(vtx
->srf_mode_all
) |
1681 S_SQ_VTX_WORD1_GPR_DST_GPR(vtx
->dst_gpr
);
1682 bc
->bytecode
[id
] = S_SQ_VTX_WORD2_OFFSET(vtx
->offset
)|
1683 S_SQ_VTX_WORD2_ENDIAN_SWAP(vtx
->endian
);
1684 if (bc
->chip_class
< CAYMAN
)
1685 bc
->bytecode
[id
] |= S_SQ_VTX_WORD2_MEGA_FETCH(1);
1687 bc
->bytecode
[id
++] = 0;
1691 /* common to all 3 families */
1692 static int r600_bytecode_tex_build(struct r600_bytecode
*bc
, struct r600_bytecode_tex
*tex
, unsigned id
)
1694 bc
->bytecode
[id
++] = S_SQ_TEX_WORD0_TEX_INST(tex
->inst
) |
1695 S_SQ_TEX_WORD0_RESOURCE_ID(tex
->resource_id
) |
1696 S_SQ_TEX_WORD0_SRC_GPR(tex
->src_gpr
) |
1697 S_SQ_TEX_WORD0_SRC_REL(tex
->src_rel
);
1698 bc
->bytecode
[id
++] = S_SQ_TEX_WORD1_DST_GPR(tex
->dst_gpr
) |
1699 S_SQ_TEX_WORD1_DST_REL(tex
->dst_rel
) |
1700 S_SQ_TEX_WORD1_DST_SEL_X(tex
->dst_sel_x
) |
1701 S_SQ_TEX_WORD1_DST_SEL_Y(tex
->dst_sel_y
) |
1702 S_SQ_TEX_WORD1_DST_SEL_Z(tex
->dst_sel_z
) |
1703 S_SQ_TEX_WORD1_DST_SEL_W(tex
->dst_sel_w
) |
1704 S_SQ_TEX_WORD1_LOD_BIAS(tex
->lod_bias
) |
1705 S_SQ_TEX_WORD1_COORD_TYPE_X(tex
->coord_type_x
) |
1706 S_SQ_TEX_WORD1_COORD_TYPE_Y(tex
->coord_type_y
) |
1707 S_SQ_TEX_WORD1_COORD_TYPE_Z(tex
->coord_type_z
) |
1708 S_SQ_TEX_WORD1_COORD_TYPE_W(tex
->coord_type_w
);
1709 bc
->bytecode
[id
++] = S_SQ_TEX_WORD2_OFFSET_X(tex
->offset_x
) |
1710 S_SQ_TEX_WORD2_OFFSET_Y(tex
->offset_y
) |
1711 S_SQ_TEX_WORD2_OFFSET_Z(tex
->offset_z
) |
1712 S_SQ_TEX_WORD2_SAMPLER_ID(tex
->sampler_id
) |
1713 S_SQ_TEX_WORD2_SRC_SEL_X(tex
->src_sel_x
) |
1714 S_SQ_TEX_WORD2_SRC_SEL_Y(tex
->src_sel_y
) |
1715 S_SQ_TEX_WORD2_SRC_SEL_Z(tex
->src_sel_z
) |
1716 S_SQ_TEX_WORD2_SRC_SEL_W(tex
->src_sel_w
);
1717 bc
->bytecode
[id
++] = 0;
1721 /* r600 only, r700/eg bits in r700_asm.c */
1722 static int r600_bytecode_alu_build(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
, unsigned id
)
1724 /* don't replace gpr by pv or ps for destination register */
1725 bc
->bytecode
[id
++] = S_SQ_ALU_WORD0_SRC0_SEL(alu
->src
[0].sel
) |
1726 S_SQ_ALU_WORD0_SRC0_REL(alu
->src
[0].rel
) |
1727 S_SQ_ALU_WORD0_SRC0_CHAN(alu
->src
[0].chan
) |
1728 S_SQ_ALU_WORD0_SRC0_NEG(alu
->src
[0].neg
) |
1729 S_SQ_ALU_WORD0_SRC1_SEL(alu
->src
[1].sel
) |
1730 S_SQ_ALU_WORD0_SRC1_REL(alu
->src
[1].rel
) |
1731 S_SQ_ALU_WORD0_SRC1_CHAN(alu
->src
[1].chan
) |
1732 S_SQ_ALU_WORD0_SRC1_NEG(alu
->src
[1].neg
) |
1733 S_SQ_ALU_WORD0_INDEX_MODE(alu
->index_mode
) |
1734 S_SQ_ALU_WORD0_LAST(alu
->last
);
1737 bc
->bytecode
[id
++] = S_SQ_ALU_WORD1_DST_GPR(alu
->dst
.sel
) |
1738 S_SQ_ALU_WORD1_DST_CHAN(alu
->dst
.chan
) |
1739 S_SQ_ALU_WORD1_DST_REL(alu
->dst
.rel
) |
1740 S_SQ_ALU_WORD1_CLAMP(alu
->dst
.clamp
) |
1741 S_SQ_ALU_WORD1_OP3_SRC2_SEL(alu
->src
[2].sel
) |
1742 S_SQ_ALU_WORD1_OP3_SRC2_REL(alu
->src
[2].rel
) |
1743 S_SQ_ALU_WORD1_OP3_SRC2_CHAN(alu
->src
[2].chan
) |
1744 S_SQ_ALU_WORD1_OP3_SRC2_NEG(alu
->src
[2].neg
) |
1745 S_SQ_ALU_WORD1_OP3_ALU_INST(alu
->inst
) |
1746 S_SQ_ALU_WORD1_BANK_SWIZZLE(alu
->bank_swizzle
);
1748 bc
->bytecode
[id
++] = S_SQ_ALU_WORD1_DST_GPR(alu
->dst
.sel
) |
1749 S_SQ_ALU_WORD1_DST_CHAN(alu
->dst
.chan
) |
1750 S_SQ_ALU_WORD1_DST_REL(alu
->dst
.rel
) |
1751 S_SQ_ALU_WORD1_CLAMP(alu
->dst
.clamp
) |
1752 S_SQ_ALU_WORD1_OP2_SRC0_ABS(alu
->src
[0].abs
) |
1753 S_SQ_ALU_WORD1_OP2_SRC1_ABS(alu
->src
[1].abs
) |
1754 S_SQ_ALU_WORD1_OP2_WRITE_MASK(alu
->dst
.write
) |
1755 S_SQ_ALU_WORD1_OP2_OMOD(alu
->omod
) |
1756 S_SQ_ALU_WORD1_OP2_ALU_INST(alu
->inst
) |
1757 S_SQ_ALU_WORD1_BANK_SWIZZLE(alu
->bank_swizzle
) |
1758 S_SQ_ALU_WORD1_OP2_UPDATE_EXECUTE_MASK(alu
->predicate
) |
1759 S_SQ_ALU_WORD1_OP2_UPDATE_PRED(alu
->predicate
);
1764 static void r600_bytecode_cf_vtx_build(uint32_t *bytecode
, const struct r600_bytecode_cf
*cf
)
1766 *bytecode
++ = S_SQ_CF_WORD0_ADDR(cf
->addr
>> 1);
1767 *bytecode
++ = cf
->inst
|
1768 S_SQ_CF_WORD1_BARRIER(1) |
1769 S_SQ_CF_WORD1_COUNT((cf
->ndw
/ 4) - 1);
1772 /* common for r600/r700 - eg in eg_asm.c */
1773 static int r600_bytecode_cf_build(struct r600_bytecode
*bc
, struct r600_bytecode_cf
*cf
)
1775 unsigned id
= cf
->id
;
1778 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
:
1779 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
:
1780 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
:
1781 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
:
1782 bc
->bytecode
[id
++] = S_SQ_CF_ALU_WORD0_ADDR(cf
->addr
>> 1) |
1783 S_SQ_CF_ALU_WORD0_KCACHE_MODE0(cf
->kcache
[0].mode
) |
1784 S_SQ_CF_ALU_WORD0_KCACHE_BANK0(cf
->kcache
[0].bank
) |
1785 S_SQ_CF_ALU_WORD0_KCACHE_BANK1(cf
->kcache
[1].bank
);
1787 bc
->bytecode
[id
++] = cf
->inst
|
1788 S_SQ_CF_ALU_WORD1_KCACHE_MODE1(cf
->kcache
[1].mode
) |
1789 S_SQ_CF_ALU_WORD1_KCACHE_ADDR0(cf
->kcache
[0].addr
) |
1790 S_SQ_CF_ALU_WORD1_KCACHE_ADDR1(cf
->kcache
[1].addr
) |
1791 S_SQ_CF_ALU_WORD1_BARRIER(1) |
1792 S_SQ_CF_ALU_WORD1_USES_WATERFALL(bc
->chip_class
== R600
? cf
->r6xx_uses_waterfall
: 0) |
1793 S_SQ_CF_ALU_WORD1_COUNT((cf
->ndw
/ 2) - 1);
1795 case V_SQ_CF_WORD1_SQ_CF_INST_TEX
:
1796 case V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
1797 case V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC
:
1798 if (bc
->chip_class
== R700
)
1799 r700_bytecode_cf_vtx_build(&bc
->bytecode
[id
], cf
);
1801 r600_bytecode_cf_vtx_build(&bc
->bytecode
[id
], cf
);
1803 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
:
1804 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
:
1805 bc
->bytecode
[id
++] = S_SQ_CF_ALLOC_EXPORT_WORD0_RW_GPR(cf
->output
.gpr
) |
1806 S_SQ_CF_ALLOC_EXPORT_WORD0_ELEM_SIZE(cf
->output
.elem_size
) |
1807 S_SQ_CF_ALLOC_EXPORT_WORD0_ARRAY_BASE(cf
->output
.array_base
) |
1808 S_SQ_CF_ALLOC_EXPORT_WORD0_TYPE(cf
->output
.type
);
1809 bc
->bytecode
[id
++] = S_SQ_CF_ALLOC_EXPORT_WORD1_BURST_COUNT(cf
->output
.burst_count
- 1) |
1810 S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_X(cf
->output
.swizzle_x
) |
1811 S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Y(cf
->output
.swizzle_y
) |
1812 S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Z(cf
->output
.swizzle_z
) |
1813 S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_W(cf
->output
.swizzle_w
) |
1814 S_SQ_CF_ALLOC_EXPORT_WORD1_BARRIER(cf
->output
.barrier
) |
1816 S_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM(cf
->output
.end_of_program
);
1818 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0
:
1819 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1
:
1820 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2
:
1821 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3
:
1822 bc
->bytecode
[id
++] = S_SQ_CF_ALLOC_EXPORT_WORD0_RW_GPR(cf
->output
.gpr
) |
1823 S_SQ_CF_ALLOC_EXPORT_WORD0_ELEM_SIZE(cf
->output
.elem_size
) |
1824 S_SQ_CF_ALLOC_EXPORT_WORD0_ARRAY_BASE(cf
->output
.array_base
) |
1825 S_SQ_CF_ALLOC_EXPORT_WORD0_TYPE(cf
->output
.type
);
1826 bc
->bytecode
[id
++] = S_SQ_CF_ALLOC_EXPORT_WORD1_BURST_COUNT(cf
->output
.burst_count
- 1) |
1827 S_SQ_CF_ALLOC_EXPORT_WORD1_BARRIER(cf
->output
.barrier
) |
1829 S_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM(cf
->output
.end_of_program
) |
1830 S_SQ_CF_ALLOC_EXPORT_WORD1_BUF_ARRAY_SIZE(cf
->output
.array_size
) |
1831 S_SQ_CF_ALLOC_EXPORT_WORD1_BUF_COMP_MASK(cf
->output
.comp_mask
);
1833 case V_SQ_CF_WORD1_SQ_CF_INST_JUMP
:
1834 case V_SQ_CF_WORD1_SQ_CF_INST_ELSE
:
1835 case V_SQ_CF_WORD1_SQ_CF_INST_POP
:
1836 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
:
1837 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
:
1838 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
:
1839 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
:
1840 case V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
:
1841 case V_SQ_CF_WORD1_SQ_CF_INST_RETURN
:
1842 bc
->bytecode
[id
++] = S_SQ_CF_WORD0_ADDR(cf
->cf_addr
>> 1);
1843 bc
->bytecode
[id
++] = cf
->inst
|
1844 S_SQ_CF_WORD1_BARRIER(1) |
1845 S_SQ_CF_WORD1_COND(cf
->cond
) |
1846 S_SQ_CF_WORD1_POP_COUNT(cf
->pop_count
);
1850 R600_ERR("unsupported CF instruction (0x%X)\n", cf
->inst
);
1856 int r600_bytecode_build(struct r600_bytecode
*bc
)
1858 struct r600_bytecode_cf
*cf
;
1859 struct r600_bytecode_alu
*alu
;
1860 struct r600_bytecode_vtx
*vtx
;
1861 struct r600_bytecode_tex
*tex
;
1862 uint32_t literal
[4];
1867 if (bc
->callstack
[0].max
> 0)
1868 bc
->nstack
= ((bc
->callstack
[0].max
+ 3) >> 2) + 2;
1869 if (bc
->type
== TGSI_PROCESSOR_VERTEX
&& !bc
->nstack
) {
1873 /* first path compute addr of each CF block */
1874 /* addr start after all the CF instructions */
1875 addr
= bc
->cf_last
->id
+ 2;
1876 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
1877 if (bc
->chip_class
>= EVERGREEN
) {
1879 case EG_V_SQ_CF_WORD1_SQ_CF_INST_TEX
:
1880 case EG_V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
1881 /* fetch node need to be 16 bytes aligned*/
1883 addr
&= 0xFFFFFFFCUL
;
1885 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
:
1886 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
:
1887 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
:
1888 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
:
1889 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
:
1890 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
:
1891 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF0
:
1892 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF1
:
1893 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF2
:
1894 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF3
:
1895 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF0
:
1896 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF1
:
1897 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF2
:
1898 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF3
:
1899 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF0
:
1900 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF1
:
1901 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF2
:
1902 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF3
:
1903 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF0
:
1904 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF1
:
1905 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF2
:
1906 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF3
:
1907 case EG_V_SQ_CF_WORD1_SQ_CF_INST_JUMP
:
1908 case EG_V_SQ_CF_WORD1_SQ_CF_INST_ELSE
:
1909 case EG_V_SQ_CF_WORD1_SQ_CF_INST_POP
:
1910 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
:
1911 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
:
1912 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
:
1913 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
:
1914 case EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
:
1915 case EG_V_SQ_CF_WORD1_SQ_CF_INST_RETURN
:
1916 case CM_V_SQ_CF_WORD1_SQ_CF_INST_END
:
1919 R600_ERR("unsupported CF instruction (0x%X)\n", cf
->inst
);
1924 case V_SQ_CF_WORD1_SQ_CF_INST_TEX
:
1925 case V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
1926 case V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC
:
1927 /* fetch node need to be 16 bytes aligned*/
1929 addr
&= 0xFFFFFFFCUL
;
1931 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
:
1932 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
:
1933 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
:
1934 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
:
1935 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
:
1936 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
:
1937 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0
:
1938 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1
:
1939 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2
:
1940 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3
:
1941 case V_SQ_CF_WORD1_SQ_CF_INST_JUMP
:
1942 case V_SQ_CF_WORD1_SQ_CF_INST_ELSE
:
1943 case V_SQ_CF_WORD1_SQ_CF_INST_POP
:
1944 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
:
1945 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
:
1946 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
:
1947 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
:
1948 case V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
:
1949 case V_SQ_CF_WORD1_SQ_CF_INST_RETURN
:
1952 R600_ERR("unsupported CF instruction (0x%X)\n", cf
->inst
);
1958 bc
->ndw
= cf
->addr
+ cf
->ndw
;
1961 bc
->bytecode
= calloc(1, bc
->ndw
* 4);
1962 if (bc
->bytecode
== NULL
)
1964 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
1966 if (bc
->chip_class
>= EVERGREEN
) {
1967 r
= eg_bytecode_cf_build(bc
, cf
);
1972 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
:
1973 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
:
1974 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
:
1975 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
:
1977 memset(literal
, 0, sizeof(literal
));
1978 LIST_FOR_EACH_ENTRY(alu
, &cf
->alu
, list
) {
1979 r
= r600_bytecode_alu_nliterals(bc
, alu
, literal
, &nliteral
);
1982 r600_bytecode_alu_adjust_literals(bc
, alu
, literal
, nliteral
);
1983 r600_bytecode_assign_kcache_banks(bc
, alu
, cf
->kcache
);
1985 switch(bc
->chip_class
) {
1986 case EVERGREEN
: /* eg alu is same encoding as r700 */
1988 r
= r700_bytecode_alu_build(bc
, alu
, addr
);
1991 R600_ERR("unknown chip class %d.\n", bc
->chip_class
);
1998 for (i
= 0; i
< align(nliteral
, 2); ++i
) {
1999 bc
->bytecode
[addr
++] = literal
[i
];
2002 memset(literal
, 0, sizeof(literal
));
2006 case EG_V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
2007 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
2008 r
= r600_bytecode_vtx_build(bc
, vtx
, addr
);
2014 case EG_V_SQ_CF_WORD1_SQ_CF_INST_TEX
:
2015 if (bc
->chip_class
== CAYMAN
) {
2016 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
2017 r
= r600_bytecode_vtx_build(bc
, vtx
, addr
);
2023 LIST_FOR_EACH_ENTRY(tex
, &cf
->tex
, list
) {
2024 r
= r600_bytecode_tex_build(bc
, tex
, addr
);
2030 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
:
2031 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
:
2032 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF0
:
2033 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF1
:
2034 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF2
:
2035 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF3
:
2036 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF0
:
2037 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF1
:
2038 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF2
:
2039 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF3
:
2040 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF0
:
2041 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF1
:
2042 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF2
:
2043 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF3
:
2044 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF0
:
2045 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF1
:
2046 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF2
:
2047 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF3
:
2048 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
:
2049 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
:
2050 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
:
2051 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
:
2052 case EG_V_SQ_CF_WORD1_SQ_CF_INST_JUMP
:
2053 case EG_V_SQ_CF_WORD1_SQ_CF_INST_ELSE
:
2054 case EG_V_SQ_CF_WORD1_SQ_CF_INST_POP
:
2055 case EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
:
2056 case EG_V_SQ_CF_WORD1_SQ_CF_INST_RETURN
:
2057 case CM_V_SQ_CF_WORD1_SQ_CF_INST_END
:
2060 R600_ERR("unsupported CF instruction (0x%X)\n", cf
->inst
);
2064 r
= r600_bytecode_cf_build(bc
, cf
);
2069 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
:
2070 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
:
2071 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
:
2072 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
:
2074 memset(literal
, 0, sizeof(literal
));
2075 LIST_FOR_EACH_ENTRY(alu
, &cf
->alu
, list
) {
2076 r
= r600_bytecode_alu_nliterals(bc
, alu
, literal
, &nliteral
);
2079 r600_bytecode_alu_adjust_literals(bc
, alu
, literal
, nliteral
);
2080 r600_bytecode_assign_kcache_banks(bc
, alu
, cf
->kcache
);
2082 switch(bc
->chip_class
) {
2084 r
= r600_bytecode_alu_build(bc
, alu
, addr
);
2087 r
= r700_bytecode_alu_build(bc
, alu
, addr
);
2090 R600_ERR("unknown chip class %d.\n", bc
->chip_class
);
2097 for (i
= 0; i
< align(nliteral
, 2); ++i
) {
2098 bc
->bytecode
[addr
++] = literal
[i
];
2101 memset(literal
, 0, sizeof(literal
));
2105 case V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
2106 case V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC
:
2107 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
2108 r
= r600_bytecode_vtx_build(bc
, vtx
, addr
);
2114 case V_SQ_CF_WORD1_SQ_CF_INST_TEX
:
2115 LIST_FOR_EACH_ENTRY(tex
, &cf
->tex
, list
) {
2116 r
= r600_bytecode_tex_build(bc
, tex
, addr
);
2122 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
:
2123 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
:
2124 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0
:
2125 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1
:
2126 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2
:
2127 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3
:
2128 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
:
2129 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
:
2130 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
:
2131 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
:
2132 case V_SQ_CF_WORD1_SQ_CF_INST_JUMP
:
2133 case V_SQ_CF_WORD1_SQ_CF_INST_ELSE
:
2134 case V_SQ_CF_WORD1_SQ_CF_INST_POP
:
2135 case V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
:
2136 case V_SQ_CF_WORD1_SQ_CF_INST_RETURN
:
2139 R600_ERR("unsupported CF instruction (0x%X)\n", cf
->inst
);
2147 void r600_bytecode_clear(struct r600_bytecode
*bc
)
2149 struct r600_bytecode_cf
*cf
= NULL
, *next_cf
;
2152 bc
->bytecode
= NULL
;
2154 LIST_FOR_EACH_ENTRY_SAFE(cf
, next_cf
, &bc
->cf
, list
) {
2155 struct r600_bytecode_alu
*alu
= NULL
, *next_alu
;
2156 struct r600_bytecode_tex
*tex
= NULL
, *next_tex
;
2157 struct r600_bytecode_tex
*vtx
= NULL
, *next_vtx
;
2159 LIST_FOR_EACH_ENTRY_SAFE(alu
, next_alu
, &cf
->alu
, list
) {
2163 LIST_INITHEAD(&cf
->alu
);
2165 LIST_FOR_EACH_ENTRY_SAFE(tex
, next_tex
, &cf
->tex
, list
) {
2169 LIST_INITHEAD(&cf
->tex
);
2171 LIST_FOR_EACH_ENTRY_SAFE(vtx
, next_vtx
, &cf
->vtx
, list
) {
2175 LIST_INITHEAD(&cf
->vtx
);
2180 LIST_INITHEAD(&cf
->list
);
2183 void r600_bytecode_dump(struct r600_bytecode
*bc
)
2185 struct r600_bytecode_cf
*cf
= NULL
;
2186 struct r600_bytecode_alu
*alu
= NULL
;
2187 struct r600_bytecode_vtx
*vtx
= NULL
;
2188 struct r600_bytecode_tex
*tex
= NULL
;
2191 uint32_t literal
[4];
2195 switch (bc
->chip_class
) {
2210 fprintf(stderr
, "bytecode %d dw -- %d gprs ---------------------\n", bc
->ndw
, bc
->ngpr
);
2211 fprintf(stderr
, " %c\n", chip
);
2213 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
2216 if (bc
->chip_class
>= EVERGREEN
) {
2218 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
:
2219 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
:
2220 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
:
2221 case EG_V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
:
2222 if (cf
->eg_alu_extended
) {
2223 fprintf(stderr
, "%04d %08X ALU_EXT0 ", id
, bc
->bytecode
[id
]);
2224 fprintf(stderr
, "KCACHE_BANK2:%X ", cf
->kcache
[2].bank
);
2225 fprintf(stderr
, "KCACHE_BANK3:%X ", cf
->kcache
[3].bank
);
2226 fprintf(stderr
, "KCACHE_MODE2:%X\n", cf
->kcache
[2].mode
);
2228 fprintf(stderr
, "%04d %08X ALU_EXT1 ", id
, bc
->bytecode
[id
]);
2229 fprintf(stderr
, "KCACHE_MODE3:%X ", cf
->kcache
[3].mode
);
2230 fprintf(stderr
, "KCACHE_ADDR2:%X ", cf
->kcache
[2].addr
);
2231 fprintf(stderr
, "KCACHE_ADDR3:%X\n", cf
->kcache
[3].addr
);
2235 fprintf(stderr
, "%04d %08X ALU ", id
, bc
->bytecode
[id
]);
2236 fprintf(stderr
, "ADDR:%d ", cf
->addr
);
2237 fprintf(stderr
, "KCACHE_MODE0:%X ", cf
->kcache
[0].mode
);
2238 fprintf(stderr
, "KCACHE_BANK0:%X ", cf
->kcache
[0].bank
);
2239 fprintf(stderr
, "KCACHE_BANK1:%X\n", cf
->kcache
[1].bank
);
2241 fprintf(stderr
, "%04d %08X ALU ", id
, bc
->bytecode
[id
]);
2242 fprintf(stderr
, "INST:0x%x ", EG_G_SQ_CF_ALU_WORD1_CF_INST(cf
->inst
));
2243 fprintf(stderr
, "KCACHE_MODE1:%X ", cf
->kcache
[1].mode
);
2244 fprintf(stderr
, "KCACHE_ADDR0:%X ", cf
->kcache
[0].addr
);
2245 fprintf(stderr
, "KCACHE_ADDR1:%X ", cf
->kcache
[1].addr
);
2246 fprintf(stderr
, "COUNT:%d\n", cf
->ndw
/ 2);
2248 case EG_V_SQ_CF_WORD1_SQ_CF_INST_TEX
:
2249 case EG_V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
2250 fprintf(stderr
, "%04d %08X TEX/VTX ", id
, bc
->bytecode
[id
]);
2251 fprintf(stderr
, "ADDR:%d\n", cf
->addr
);
2253 fprintf(stderr
, "%04d %08X TEX/VTX ", id
, bc
->bytecode
[id
]);
2254 fprintf(stderr
, "INST:0x%x ", EG_G_SQ_CF_WORD1_CF_INST(cf
->inst
));
2255 fprintf(stderr
, "COUNT:%d\n", cf
->ndw
/ 4);
2257 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
:
2258 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
:
2259 fprintf(stderr
, "%04d %08X EXPORT ", id
, bc
->bytecode
[id
]);
2260 fprintf(stderr
, "GPR:%X ", cf
->output
.gpr
);
2261 fprintf(stderr
, "ELEM_SIZE:%X ", cf
->output
.elem_size
);
2262 fprintf(stderr
, "ARRAY_BASE:%X ", cf
->output
.array_base
);
2263 fprintf(stderr
, "TYPE:%X\n", cf
->output
.type
);
2265 fprintf(stderr
, "%04d %08X EXPORT ", id
, bc
->bytecode
[id
]);
2266 fprintf(stderr
, "SWIZ_X:%X ", cf
->output
.swizzle_x
);
2267 fprintf(stderr
, "SWIZ_Y:%X ", cf
->output
.swizzle_y
);
2268 fprintf(stderr
, "SWIZ_Z:%X ", cf
->output
.swizzle_z
);
2269 fprintf(stderr
, "SWIZ_W:%X ", cf
->output
.swizzle_w
);
2270 fprintf(stderr
, "BARRIER:%X ", cf
->output
.barrier
);
2271 fprintf(stderr
, "INST:0x%x ", EG_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(cf
->output
.inst
));
2272 fprintf(stderr
, "BURST_COUNT:%d ", cf
->output
.burst_count
);
2273 fprintf(stderr
, "EOP:%X\n", cf
->output
.end_of_program
);
2275 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF0
:
2276 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF1
:
2277 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF2
:
2278 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF3
:
2279 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF0
:
2280 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF1
:
2281 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF2
:
2282 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1_BUF3
:
2283 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF0
:
2284 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF1
:
2285 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF2
:
2286 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2_BUF3
:
2287 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF0
:
2288 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF1
:
2289 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF2
:
2290 case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3_BUF3
:
2291 fprintf(stderr
, "%04d %08X EXPORT MEM_STREAM%i_BUF%i ", id
, bc
->bytecode
[id
],
2292 (EG_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(cf
->inst
) -
2293 EG_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF0
)) / 4,
2294 (EG_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(cf
->inst
) -
2295 EG_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF0
)) % 4);
2296 fprintf(stderr
, "GPR:%X ", cf
->output
.gpr
);
2297 fprintf(stderr
, "ELEM_SIZE:%i ", cf
->output
.elem_size
);
2298 fprintf(stderr
, "ARRAY_BASE:%i ", cf
->output
.array_base
);
2299 fprintf(stderr
, "TYPE:%X\n", cf
->output
.type
);
2301 fprintf(stderr
, "%04d %08X EXPORT MEM_STREAM%i_BUF%i ", id
, bc
->bytecode
[id
],
2302 (EG_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(cf
->inst
) -
2303 EG_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF0
)) / 4,
2304 (EG_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(cf
->inst
) -
2305 EG_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF0
)) % 4);
2306 fprintf(stderr
, "ARRAY_SIZE:%i ", cf
->output
.array_size
);
2307 fprintf(stderr
, "COMP_MASK:%X ", cf
->output
.comp_mask
);
2308 fprintf(stderr
, "BARRIER:%X ", cf
->output
.barrier
);
2309 fprintf(stderr
, "INST:%d ", cf
->output
.inst
);
2310 fprintf(stderr
, "BURST_COUNT:%d ", cf
->output
.burst_count
);
2311 fprintf(stderr
, "EOP:%X\n", cf
->output
.end_of_program
);
2313 case EG_V_SQ_CF_WORD1_SQ_CF_INST_JUMP
:
2314 case EG_V_SQ_CF_WORD1_SQ_CF_INST_ELSE
:
2315 case EG_V_SQ_CF_WORD1_SQ_CF_INST_POP
:
2316 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
:
2317 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
:
2318 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
:
2319 case EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
:
2320 case EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
:
2321 case EG_V_SQ_CF_WORD1_SQ_CF_INST_RETURN
:
2322 case CM_V_SQ_CF_WORD1_SQ_CF_INST_END
:
2323 fprintf(stderr
, "%04d %08X CF ", id
, bc
->bytecode
[id
]);
2324 fprintf(stderr
, "ADDR:%d\n", cf
->cf_addr
);
2326 fprintf(stderr
, "%04d %08X CF ", id
, bc
->bytecode
[id
]);
2327 fprintf(stderr
, "INST:0x%x ", EG_G_SQ_CF_WORD1_CF_INST(cf
->inst
));
2328 fprintf(stderr
, "COND:%X ", cf
->cond
);
2329 fprintf(stderr
, "POP_COUNT:%X\n", cf
->pop_count
);
2332 R600_ERR("Unknown instruction %0x\n", cf
->inst
);
2336 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
:
2337 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
:
2338 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
:
2339 case V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
:
2340 fprintf(stderr
, "%04d %08X ALU ", id
, bc
->bytecode
[id
]);
2341 fprintf(stderr
, "ADDR:%d ", cf
->addr
);
2342 fprintf(stderr
, "KCACHE_MODE0:%X ", cf
->kcache
[0].mode
);
2343 fprintf(stderr
, "KCACHE_BANK0:%X ", cf
->kcache
[0].bank
);
2344 fprintf(stderr
, "KCACHE_BANK1:%X\n", cf
->kcache
[1].bank
);
2346 fprintf(stderr
, "%04d %08X ALU ", id
, bc
->bytecode
[id
]);
2347 fprintf(stderr
, "INST:0x%x ", R600_G_SQ_CF_ALU_WORD1_CF_INST(cf
->inst
));
2348 fprintf(stderr
, "KCACHE_MODE1:%X ", cf
->kcache
[1].mode
);
2349 fprintf(stderr
, "KCACHE_ADDR0:%X ", cf
->kcache
[0].addr
);
2350 fprintf(stderr
, "KCACHE_ADDR1:%X ", cf
->kcache
[1].addr
);
2351 fprintf(stderr
, "COUNT:%d\n", cf
->ndw
/ 2);
2353 case V_SQ_CF_WORD1_SQ_CF_INST_TEX
:
2354 case V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
2355 case V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC
:
2356 fprintf(stderr
, "%04d %08X TEX/VTX ", id
, bc
->bytecode
[id
]);
2357 fprintf(stderr
, "ADDR:%d\n", cf
->addr
);
2359 fprintf(stderr
, "%04d %08X TEX/VTX ", id
, bc
->bytecode
[id
]);
2360 fprintf(stderr
, "INST:0x%x ", R600_G_SQ_CF_WORD1_CF_INST(cf
->inst
));
2361 fprintf(stderr
, "COUNT:%d\n", cf
->ndw
/ 4);
2363 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
:
2364 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
:
2365 fprintf(stderr
, "%04d %08X EXPORT ", id
, bc
->bytecode
[id
]);
2366 fprintf(stderr
, "GPR:%X ", cf
->output
.gpr
);
2367 fprintf(stderr
, "ELEM_SIZE:%X ", cf
->output
.elem_size
);
2368 fprintf(stderr
, "ARRAY_BASE:%X ", cf
->output
.array_base
);
2369 fprintf(stderr
, "TYPE:%X\n", cf
->output
.type
);
2371 fprintf(stderr
, "%04d %08X EXPORT ", id
, bc
->bytecode
[id
]);
2372 fprintf(stderr
, "SWIZ_X:%X ", cf
->output
.swizzle_x
);
2373 fprintf(stderr
, "SWIZ_Y:%X ", cf
->output
.swizzle_y
);
2374 fprintf(stderr
, "SWIZ_Z:%X ", cf
->output
.swizzle_z
);
2375 fprintf(stderr
, "SWIZ_W:%X ", cf
->output
.swizzle_w
);
2376 fprintf(stderr
, "BARRIER:%X ", cf
->output
.barrier
);
2377 fprintf(stderr
, "INST:0x%x ", R600_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(cf
->output
.inst
));
2378 fprintf(stderr
, "BURST_COUNT:%d ", cf
->output
.burst_count
);
2379 fprintf(stderr
, "EOP:%X\n", cf
->output
.end_of_program
);
2381 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0
:
2382 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1
:
2383 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2
:
2384 case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3
:
2385 fprintf(stderr
, "%04d %08X EXPORT MEM_STREAM%i ", id
, bc
->bytecode
[id
],
2386 R600_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(cf
->inst
) -
2387 R600_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0
));
2388 fprintf(stderr
, "GPR:%X ", cf
->output
.gpr
);
2389 fprintf(stderr
, "ELEM_SIZE:%i ", cf
->output
.elem_size
);
2390 fprintf(stderr
, "ARRAY_BASE:%i ", cf
->output
.array_base
);
2391 fprintf(stderr
, "TYPE:%X\n", cf
->output
.type
);
2393 fprintf(stderr
, "%04d %08X EXPORT MEM_STREAM%i ", id
, bc
->bytecode
[id
],
2394 R600_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(cf
->inst
) -
2395 R600_G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0
));
2396 fprintf(stderr
, "ARRAY_SIZE:%i ", cf
->output
.array_size
);
2397 fprintf(stderr
, "COMP_MASK:%X ", cf
->output
.comp_mask
);
2398 fprintf(stderr
, "BARRIER:%X ", cf
->output
.barrier
);
2399 fprintf(stderr
, "INST:%d ", cf
->output
.inst
);
2400 fprintf(stderr
, "BURST_COUNT:%d ", cf
->output
.burst_count
);
2401 fprintf(stderr
, "EOP:%X\n", cf
->output
.end_of_program
);
2403 case V_SQ_CF_WORD1_SQ_CF_INST_JUMP
:
2404 case V_SQ_CF_WORD1_SQ_CF_INST_ELSE
:
2405 case V_SQ_CF_WORD1_SQ_CF_INST_POP
:
2406 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
:
2407 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
:
2408 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
:
2409 case V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
:
2410 case V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
:
2411 case V_SQ_CF_WORD1_SQ_CF_INST_RETURN
:
2412 fprintf(stderr
, "%04d %08X CF ", id
, bc
->bytecode
[id
]);
2413 fprintf(stderr
, "ADDR:%d\n", cf
->cf_addr
);
2415 fprintf(stderr
, "%04d %08X CF ", id
, bc
->bytecode
[id
]);
2416 fprintf(stderr
, "INST:0x%x ", R600_G_SQ_CF_WORD1_CF_INST(cf
->inst
));
2417 fprintf(stderr
, "COND:%X ", cf
->cond
);
2418 fprintf(stderr
, "POP_COUNT:%X\n", cf
->pop_count
);
2421 R600_ERR("Unknown instruction %0x\n", cf
->inst
);
2427 LIST_FOR_EACH_ENTRY(alu
, &cf
->alu
, list
) {
2428 r600_bytecode_alu_nliterals(bc
, alu
, literal
, &nliteral
);
2430 fprintf(stderr
, "%04d %08X ", id
, bc
->bytecode
[id
]);
2431 fprintf(stderr
, "SRC0(SEL:%d ", alu
->src
[0].sel
);
2432 fprintf(stderr
, "REL:%d ", alu
->src
[0].rel
);
2433 fprintf(stderr
, "CHAN:%d ", alu
->src
[0].chan
);
2434 fprintf(stderr
, "NEG:%d) ", alu
->src
[0].neg
);
2435 fprintf(stderr
, "SRC1(SEL:%d ", alu
->src
[1].sel
);
2436 fprintf(stderr
, "REL:%d ", alu
->src
[1].rel
);
2437 fprintf(stderr
, "CHAN:%d ", alu
->src
[1].chan
);
2438 fprintf(stderr
, "NEG:%d ", alu
->src
[1].neg
);
2439 fprintf(stderr
, "IM:%d) ", alu
->index_mode
);
2440 fprintf(stderr
, "LAST:%d)\n", alu
->last
);
2442 fprintf(stderr
, "%04d %08X %c ", id
, bc
->bytecode
[id
], alu
->last
? '*' : ' ');
2443 fprintf(stderr
, "INST:0x%x ", alu
->inst
);
2444 fprintf(stderr
, "DST(SEL:%d ", alu
->dst
.sel
);
2445 fprintf(stderr
, "CHAN:%d ", alu
->dst
.chan
);
2446 fprintf(stderr
, "REL:%d ", alu
->dst
.rel
);
2447 fprintf(stderr
, "CLAMP:%d) ", alu
->dst
.clamp
);
2448 fprintf(stderr
, "BANK_SWIZZLE:%d ", alu
->bank_swizzle
);
2450 fprintf(stderr
, "SRC2(SEL:%d ", alu
->src
[2].sel
);
2451 fprintf(stderr
, "REL:%d ", alu
->src
[2].rel
);
2452 fprintf(stderr
, "CHAN:%d ", alu
->src
[2].chan
);
2453 fprintf(stderr
, "NEG:%d)\n", alu
->src
[2].neg
);
2455 fprintf(stderr
, "SRC0_ABS:%d ", alu
->src
[0].abs
);
2456 fprintf(stderr
, "SRC1_ABS:%d ", alu
->src
[1].abs
);
2457 fprintf(stderr
, "WRITE_MASK:%d ", alu
->dst
.write
);
2458 fprintf(stderr
, "OMOD:%d ", alu
->omod
);
2459 fprintf(stderr
, "EXECUTE_MASK:%d ", alu
->predicate
);
2460 fprintf(stderr
, "UPDATE_PRED:%d\n", alu
->predicate
);
2465 for (i
= 0; i
< nliteral
; i
++, id
++) {
2466 float *f
= (float*)(bc
->bytecode
+ id
);
2467 fprintf(stderr
, "%04d %08X\t%f\n", id
, bc
->bytecode
[id
], *f
);
2474 LIST_FOR_EACH_ENTRY(tex
, &cf
->tex
, list
) {
2475 fprintf(stderr
, "%04d %08X ", id
, bc
->bytecode
[id
]);
2476 fprintf(stderr
, "INST:0x%x ", tex
->inst
);
2477 fprintf(stderr
, "RESOURCE_ID:%d ", tex
->resource_id
);
2478 fprintf(stderr
, "SRC(GPR:%d ", tex
->src_gpr
);
2479 fprintf(stderr
, "REL:%d)\n", tex
->src_rel
);
2481 fprintf(stderr
, "%04d %08X ", id
, bc
->bytecode
[id
]);
2482 fprintf(stderr
, "DST(GPR:%d ", tex
->dst_gpr
);
2483 fprintf(stderr
, "REL:%d ", tex
->dst_rel
);
2484 fprintf(stderr
, "SEL_X:%d ", tex
->dst_sel_x
);
2485 fprintf(stderr
, "SEL_Y:%d ", tex
->dst_sel_y
);
2486 fprintf(stderr
, "SEL_Z:%d ", tex
->dst_sel_z
);
2487 fprintf(stderr
, "SEL_W:%d) ", tex
->dst_sel_w
);
2488 fprintf(stderr
, "LOD_BIAS:%d ", tex
->lod_bias
);
2489 fprintf(stderr
, "COORD_TYPE_X:%d ", tex
->coord_type_x
);
2490 fprintf(stderr
, "COORD_TYPE_Y:%d ", tex
->coord_type_y
);
2491 fprintf(stderr
, "COORD_TYPE_Z:%d ", tex
->coord_type_z
);
2492 fprintf(stderr
, "COORD_TYPE_W:%d\n", tex
->coord_type_w
);
2494 fprintf(stderr
, "%04d %08X ", id
, bc
->bytecode
[id
]);
2495 fprintf(stderr
, "OFFSET_X:%d ", tex
->offset_x
);
2496 fprintf(stderr
, "OFFSET_Y:%d ", tex
->offset_y
);
2497 fprintf(stderr
, "OFFSET_Z:%d ", tex
->offset_z
);
2498 fprintf(stderr
, "SAMPLER_ID:%d ", tex
->sampler_id
);
2499 fprintf(stderr
, "SRC(SEL_X:%d ", tex
->src_sel_x
);
2500 fprintf(stderr
, "SEL_Y:%d ", tex
->src_sel_y
);
2501 fprintf(stderr
, "SEL_Z:%d ", tex
->src_sel_z
);
2502 fprintf(stderr
, "SEL_W:%d)\n", tex
->src_sel_w
);
2504 fprintf(stderr
, "%04d %08X \n", id
, bc
->bytecode
[id
]);
2508 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
2509 fprintf(stderr
, "%04d %08X ", id
, bc
->bytecode
[id
]);
2510 fprintf(stderr
, "INST:%d ", vtx
->inst
);
2511 fprintf(stderr
, "FETCH_TYPE:%d ", vtx
->fetch_type
);
2512 fprintf(stderr
, "BUFFER_ID:%d\n", vtx
->buffer_id
);
2514 /* This assumes that no semantic fetches exist */
2515 fprintf(stderr
, "%04d %08X ", id
, bc
->bytecode
[id
]);
2516 fprintf(stderr
, "SRC(GPR:%d ", vtx
->src_gpr
);
2517 fprintf(stderr
, "SEL_X:%d) ", vtx
->src_sel_x
);
2518 if (bc
->chip_class
< CAYMAN
)
2519 fprintf(stderr
, "MEGA_FETCH_COUNT:%d ", vtx
->mega_fetch_count
);
2521 fprintf(stderr
, "SEL_Y:%d) ", 0);
2522 fprintf(stderr
, "DST(GPR:%d ", vtx
->dst_gpr
);
2523 fprintf(stderr
, "SEL_X:%d ", vtx
->dst_sel_x
);
2524 fprintf(stderr
, "SEL_Y:%d ", vtx
->dst_sel_y
);
2525 fprintf(stderr
, "SEL_Z:%d ", vtx
->dst_sel_z
);
2526 fprintf(stderr
, "SEL_W:%d) ", vtx
->dst_sel_w
);
2527 fprintf(stderr
, "USE_CONST_FIELDS:%d ", vtx
->use_const_fields
);
2528 fprintf(stderr
, "FORMAT(DATA:%d ", vtx
->data_format
);
2529 fprintf(stderr
, "NUM:%d ", vtx
->num_format_all
);
2530 fprintf(stderr
, "COMP:%d ", vtx
->format_comp_all
);
2531 fprintf(stderr
, "MODE:%d)\n", vtx
->srf_mode_all
);
2533 fprintf(stderr
, "%04d %08X ", id
, bc
->bytecode
[id
]);
2534 fprintf(stderr
, "ENDIAN:%d ", vtx
->endian
);
2535 fprintf(stderr
, "OFFSET:%d\n", vtx
->offset
);
2538 fprintf(stderr
, "%04d %08X \n", id
, bc
->bytecode
[id
]);
2543 fprintf(stderr
, "--------------------------------------\n");
2546 static void r600_vertex_data_type(enum pipe_format pformat
,
2548 unsigned *num_format
, unsigned *format_comp
, unsigned *endian
)
2550 const struct util_format_description
*desc
;
2556 *endian
= ENDIAN_NONE
;
2558 desc
= util_format_description(pformat
);
2559 if (desc
->layout
!= UTIL_FORMAT_LAYOUT_PLAIN
) {
2563 /* Find the first non-VOID channel. */
2564 for (i
= 0; i
< 4; i
++) {
2565 if (desc
->channel
[i
].type
!= UTIL_FORMAT_TYPE_VOID
) {
2570 *endian
= r600_endian_swap(desc
->channel
[i
].size
);
2572 switch (desc
->channel
[i
].type
) {
2573 /* Half-floats, floats, ints */
2574 case UTIL_FORMAT_TYPE_FLOAT
:
2575 switch (desc
->channel
[i
].size
) {
2577 switch (desc
->nr_channels
) {
2579 *format
= FMT_16_FLOAT
;
2582 *format
= FMT_16_16_FLOAT
;
2586 *format
= FMT_16_16_16_16_FLOAT
;
2591 switch (desc
->nr_channels
) {
2593 *format
= FMT_32_FLOAT
;
2596 *format
= FMT_32_32_FLOAT
;
2599 *format
= FMT_32_32_32_FLOAT
;
2602 *format
= FMT_32_32_32_32_FLOAT
;
2611 case UTIL_FORMAT_TYPE_UNSIGNED
:
2613 case UTIL_FORMAT_TYPE_SIGNED
:
2614 switch (desc
->channel
[i
].size
) {
2616 switch (desc
->nr_channels
) {
2625 *format
= FMT_8_8_8_8
;
2630 if (desc
->nr_channels
!= 4)
2633 *format
= FMT_2_10_10_10
;
2636 switch (desc
->nr_channels
) {
2641 *format
= FMT_16_16
;
2645 *format
= FMT_16_16_16_16
;
2650 switch (desc
->nr_channels
) {
2655 *format
= FMT_32_32
;
2658 *format
= FMT_32_32_32
;
2661 *format
= FMT_32_32_32_32
;
2673 if (desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_SIGNED
) {
2678 if (desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_UNSIGNED
||
2679 desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_SIGNED
) {
2680 if (!desc
->channel
[i
].normalized
) {
2681 if (desc
->channel
[i
].pure_integer
)
2689 R600_ERR("unsupported vertex format %s\n", util_format_name(pformat
));
2692 int r600_vertex_elements_build_fetch_shader(struct r600_pipe_context
*rctx
, struct r600_vertex_element
*ve
)
2694 static int dump_shaders
= -1;
2696 struct r600_bytecode bc
;
2697 struct r600_bytecode_vtx vtx
;
2698 struct pipe_vertex_element
*elements
= ve
->elements
;
2699 const struct util_format_description
*desc
;
2700 unsigned fetch_resource_start
= rctx
->chip_class
>= EVERGREEN
? 0 : 160;
2701 unsigned format
, num_format
, format_comp
, endian
;
2705 /* Vertex element offsets need special handling. If the offset is
2706 * bigger than what we can put in the fetch instruction we need to
2707 * alter the vertex resource offset. In order to simplify code we
2708 * will bind one resource per element in such cases. It's a worst
2710 for (i
= 0; i
< ve
->count
; i
++) {
2711 ve
->vbuffer_offset
[i
] = C_SQ_VTX_WORD2_OFFSET
& elements
[i
].src_offset
;
2712 if (ve
->vbuffer_offset
[i
]) {
2713 ve
->vbuffer_need_offset
= 1;
2717 memset(&bc
, 0, sizeof(bc
));
2718 r600_bytecode_init(&bc
, rctx
->chip_class
, rctx
->family
);
2720 for (i
= 0; i
< ve
->count
; i
++) {
2721 if (elements
[i
].instance_divisor
> 1) {
2722 struct r600_bytecode_alu alu
;
2724 memset(&alu
, 0, sizeof(alu
));
2725 alu
.inst
= BC_INST(&bc
, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
2727 alu
.src
[0].chan
= 3;
2729 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
2730 alu
.src
[1].value
= (1ll << 32) / elements
[i
].instance_divisor
+ 1;
2732 alu
.dst
.sel
= i
+ 1;
2737 if ((r
= r600_bytecode_add_alu(&bc
, &alu
))) {
2738 r600_bytecode_clear(&bc
);
2744 for (i
= 0; i
< ve
->count
; i
++) {
2745 unsigned vbuffer_index
;
2746 r600_vertex_data_type(ve
->elements
[i
].src_format
,
2747 &format
, &num_format
, &format_comp
, &endian
);
2748 desc
= util_format_description(ve
->elements
[i
].src_format
);
2750 r600_bytecode_clear(&bc
);
2751 R600_ERR("unknown format %d\n", ve
->elements
[i
].src_format
);
2755 /* see above for vbuffer_need_offset explanation */
2756 vbuffer_index
= elements
[i
].vertex_buffer_index
;
2757 memset(&vtx
, 0, sizeof(vtx
));
2758 vtx
.buffer_id
= (ve
->vbuffer_need_offset
? i
: vbuffer_index
) + fetch_resource_start
;
2759 vtx
.fetch_type
= elements
[i
].instance_divisor
? 1 : 0;
2760 vtx
.src_gpr
= elements
[i
].instance_divisor
> 1 ? i
+ 1 : 0;
2761 vtx
.src_sel_x
= elements
[i
].instance_divisor
? 3 : 0;
2762 vtx
.mega_fetch_count
= 0x1F;
2763 vtx
.dst_gpr
= i
+ 1;
2764 vtx
.dst_sel_x
= desc
->swizzle
[0];
2765 vtx
.dst_sel_y
= desc
->swizzle
[1];
2766 vtx
.dst_sel_z
= desc
->swizzle
[2];
2767 vtx
.dst_sel_w
= desc
->swizzle
[3];
2768 vtx
.data_format
= format
;
2769 vtx
.num_format_all
= num_format
;
2770 vtx
.format_comp_all
= format_comp
;
2771 vtx
.srf_mode_all
= 1;
2772 vtx
.offset
= elements
[i
].src_offset
;
2773 vtx
.endian
= endian
;
2775 if ((r
= r600_bytecode_add_vtx(&bc
, &vtx
))) {
2776 r600_bytecode_clear(&bc
);
2781 r600_bytecode_add_cfinst(&bc
, BC_INST(&bc
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
));
2783 if ((r
= r600_bytecode_build(&bc
))) {
2784 r600_bytecode_clear(&bc
);
2788 if (dump_shaders
== -1)
2789 dump_shaders
= debug_get_bool_option("R600_DUMP_SHADERS", FALSE
);
2792 fprintf(stderr
, "--------------------------------------------------------------\n");
2793 r600_bytecode_dump(&bc
);
2794 fprintf(stderr
, "______________________________________________________________\n");
2797 ve
->fs_size
= bc
.ndw
*4;
2799 ve
->fetch_shader
= (struct r600_resource
*)
2800 pipe_buffer_create(rctx
->context
.screen
,
2802 PIPE_USAGE_IMMUTABLE
, ve
->fs_size
);
2803 if (ve
->fetch_shader
== NULL
) {
2804 r600_bytecode_clear(&bc
);
2808 bytecode
= rctx
->ws
->buffer_map(ve
->fetch_shader
->buf
, rctx
->ctx
.cs
, PIPE_TRANSFER_WRITE
);
2809 if (bytecode
== NULL
) {
2810 r600_bytecode_clear(&bc
);
2811 pipe_resource_reference((struct pipe_resource
**)&ve
->fetch_shader
, NULL
);
2815 if (R600_BIG_ENDIAN
) {
2816 for (i
= 0; i
< ve
->fs_size
/ 4; ++i
) {
2817 bytecode
[i
] = bswap_32(bc
.bytecode
[i
]);
2820 memcpy(bytecode
, bc
.bytecode
, ve
->fs_size
);
2823 rctx
->ws
->buffer_unmap(ve
->fetch_shader
->buf
);
2824 r600_bytecode_clear(&bc
);
2826 if (rctx
->chip_class
>= EVERGREEN
)
2827 evergreen_fetch_shader(&rctx
->context
, ve
);
2829 r600_fetch_shader(&rctx
->context
, ve
);