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.
24 #include "r600_opcodes.h"
25 #include "r600_formats.h"
26 #include "r600_shader.h"
30 #include "util/u_dump.h"
31 #include "util/u_memory.h"
32 #include "util/u_math.h"
33 #include "pipe/p_shader_tokens.h"
35 #include "sb/sb_public.h"
37 #define NUM_OF_CYCLES 3
38 #define NUM_OF_COMPONENTS 4
40 static inline unsigned int r600_bytecode_get_num_operands(
41 struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
43 return r600_isa_alu(alu
->op
)->src_count
;
46 int r700_bytecode_alu_build(struct r600_bytecode
*bc
,
47 struct r600_bytecode_alu
*alu
, unsigned id
);
49 static struct r600_bytecode_cf
*r600_bytecode_cf(void)
51 struct r600_bytecode_cf
*cf
= CALLOC_STRUCT(r600_bytecode_cf
);
55 LIST_INITHEAD(&cf
->list
);
56 LIST_INITHEAD(&cf
->alu
);
57 LIST_INITHEAD(&cf
->vtx
);
58 LIST_INITHEAD(&cf
->tex
);
62 static struct r600_bytecode_alu
*r600_bytecode_alu(void)
64 struct r600_bytecode_alu
*alu
= CALLOC_STRUCT(r600_bytecode_alu
);
68 LIST_INITHEAD(&alu
->list
);
72 static struct r600_bytecode_vtx
*r600_bytecode_vtx(void)
74 struct r600_bytecode_vtx
*vtx
= CALLOC_STRUCT(r600_bytecode_vtx
);
78 LIST_INITHEAD(&vtx
->list
);
82 static struct r600_bytecode_tex
*r600_bytecode_tex(void)
84 struct r600_bytecode_tex
*tex
= CALLOC_STRUCT(r600_bytecode_tex
);
88 LIST_INITHEAD(&tex
->list
);
92 static unsigned stack_entry_size(enum radeon_family chip
) {
94 * 64: R600/RV670/RV770/Cypress/R740/Barts/Turks/Caicos/
95 * Aruba/Sumo/Sumo2/redwood/juniper
96 * 32: R630/R730/R710/Palm/Cedar
100 * Wavefront Size 16 32 48 64
101 * Columns per Row (R6xx/R7xx/R8xx only) 8 8 4 4
102 * Columns per Row (R9xx+) 8 4 4 4 */
105 /* FIXME: are some chips missing here? */
106 /* wavefront size 16 */
111 /* wavefront size 32 */
120 /* wavefront size 64 */
126 void r600_bytecode_init(struct r600_bytecode
*bc
,
127 enum chip_class chip_class
,
128 enum radeon_family family
,
129 bool has_compressed_msaa_texturing
)
131 static unsigned next_shader_id
= 0;
133 bc
->debug_id
= ++next_shader_id
;
135 if ((chip_class
== R600
) &&
136 (family
!= CHIP_RV670
&& family
!= CHIP_RS780
&& family
!= CHIP_RS880
)) {
137 bc
->ar_handling
= AR_HANDLE_RV6XX
;
138 bc
->r6xx_nop_after_rel_dst
= 1;
140 bc
->ar_handling
= AR_HANDLE_NORMAL
;
141 bc
->r6xx_nop_after_rel_dst
= 0;
144 LIST_INITHEAD(&bc
->cf
);
145 bc
->chip_class
= chip_class
;
147 bc
->has_compressed_msaa_texturing
= has_compressed_msaa_texturing
;
148 bc
->stack
.entry_size
= stack_entry_size(family
);
151 int r600_bytecode_add_cf(struct r600_bytecode
*bc
)
153 struct r600_bytecode_cf
*cf
= r600_bytecode_cf();
157 LIST_ADDTAIL(&cf
->list
, &bc
->cf
);
159 cf
->id
= bc
->cf_last
->id
+ 2;
160 if (bc
->cf_last
->eg_alu_extended
) {
161 /* take into account extended alu size */
169 bc
->force_add_cf
= 0;
174 int r600_bytecode_add_output(struct r600_bytecode
*bc
,
175 const struct r600_bytecode_output
*output
)
179 if (output
->gpr
>= bc
->ngpr
)
180 bc
->ngpr
= output
->gpr
+ 1;
182 if (bc
->cf_last
&& (bc
->cf_last
->op
== output
->op
||
183 (bc
->cf_last
->op
== CF_OP_EXPORT
&&
184 output
->op
== CF_OP_EXPORT_DONE
)) &&
185 output
->type
== bc
->cf_last
->output
.type
&&
186 output
->elem_size
== bc
->cf_last
->output
.elem_size
&&
187 output
->swizzle_x
== bc
->cf_last
->output
.swizzle_x
&&
188 output
->swizzle_y
== bc
->cf_last
->output
.swizzle_y
&&
189 output
->swizzle_z
== bc
->cf_last
->output
.swizzle_z
&&
190 output
->swizzle_w
== bc
->cf_last
->output
.swizzle_w
&&
191 output
->comp_mask
== bc
->cf_last
->output
.comp_mask
&&
192 (output
->burst_count
+ bc
->cf_last
->output
.burst_count
) <= 16) {
194 if ((output
->gpr
+ output
->burst_count
) == bc
->cf_last
->output
.gpr
&&
195 (output
->array_base
+ output
->burst_count
) == bc
->cf_last
->output
.array_base
) {
197 bc
->cf_last
->op
= bc
->cf_last
->output
.op
= output
->op
;
198 bc
->cf_last
->output
.gpr
= output
->gpr
;
199 bc
->cf_last
->output
.array_base
= output
->array_base
;
200 bc
->cf_last
->output
.burst_count
+= output
->burst_count
;
203 } else if (output
->gpr
== (bc
->cf_last
->output
.gpr
+ bc
->cf_last
->output
.burst_count
) &&
204 output
->array_base
== (bc
->cf_last
->output
.array_base
+ bc
->cf_last
->output
.burst_count
)) {
206 bc
->cf_last
->op
= bc
->cf_last
->output
.op
= output
->op
;
207 bc
->cf_last
->output
.burst_count
+= output
->burst_count
;
212 r
= r600_bytecode_add_cf(bc
);
215 bc
->cf_last
->op
= output
->op
;
216 memcpy(&bc
->cf_last
->output
, output
, sizeof(struct r600_bytecode_output
));
217 bc
->cf_last
->barrier
= 1;
221 /* alu instructions that can ony exits once per group */
222 static int is_alu_once_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
224 return r600_isa_alu(alu
->op
)->flags
& (AF_KILL
| AF_PRED
);
227 static int is_alu_reduction_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
229 return (r600_isa_alu(alu
->op
)->flags
& AF_REPL
) &&
230 (r600_isa_alu_slots(bc
->isa
->hw_class
, alu
->op
) == AF_4V
);
233 static int is_alu_mova_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
235 return r600_isa_alu(alu
->op
)->flags
& AF_MOVA
;
238 static int alu_uses_rel(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
240 unsigned num_src
= r600_bytecode_get_num_operands(bc
, alu
);
247 for (src
= 0; src
< num_src
; ++src
) {
248 if (alu
->src
[src
].rel
) {
255 static int is_alu_64bit_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
257 const struct alu_op_info
*op
= r600_isa_alu(alu
->op
);
258 return (op
->flags
& AF_64
);
261 static int is_alu_vec_unit_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
263 unsigned slots
= r600_isa_alu_slots(bc
->isa
->hw_class
, alu
->op
);
264 return !(slots
& AF_S
);
267 static int is_alu_trans_unit_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
269 unsigned slots
= r600_isa_alu_slots(bc
->isa
->hw_class
, alu
->op
);
270 return !(slots
& AF_V
);
273 /* alu instructions that can execute on any unit */
274 static int is_alu_any_unit_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
276 unsigned slots
= r600_isa_alu_slots(bc
->isa
->hw_class
, alu
->op
);
277 return slots
== AF_VS
;
280 static int is_nop_inst(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
)
282 return alu
->op
== ALU_OP0_NOP
;
285 static int assign_alu_units(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu_first
,
286 struct r600_bytecode_alu
*assignment
[5])
288 struct r600_bytecode_alu
*alu
;
289 unsigned i
, chan
, trans
;
290 int max_slots
= bc
->chip_class
== CAYMAN
? 4 : 5;
292 for (i
= 0; i
< max_slots
; i
++)
293 assignment
[i
] = NULL
;
295 for (alu
= alu_first
; alu
; alu
= LIST_ENTRY(struct r600_bytecode_alu
, alu
->list
.next
, list
)) {
296 chan
= alu
->dst
.chan
;
299 else if (is_alu_trans_unit_inst(bc
, alu
))
301 else if (is_alu_vec_unit_inst(bc
, alu
))
303 else if (assignment
[chan
])
304 trans
= 1; /* Assume ALU_INST_PREFER_VECTOR. */
310 assert(0); /* ALU.Trans has already been allocated. */
315 if (assignment
[chan
]) {
316 assert(0); /* ALU.chan has already been allocated. */
319 assignment
[chan
] = alu
;
328 struct alu_bank_swizzle
{
329 int hw_gpr
[NUM_OF_CYCLES
][NUM_OF_COMPONENTS
];
330 int hw_cfile_addr
[4];
331 int hw_cfile_elem
[4];
334 static const unsigned cycle_for_bank_swizzle_vec
[][3] = {
335 [SQ_ALU_VEC_012
] = { 0, 1, 2 },
336 [SQ_ALU_VEC_021
] = { 0, 2, 1 },
337 [SQ_ALU_VEC_120
] = { 1, 2, 0 },
338 [SQ_ALU_VEC_102
] = { 1, 0, 2 },
339 [SQ_ALU_VEC_201
] = { 2, 0, 1 },
340 [SQ_ALU_VEC_210
] = { 2, 1, 0 }
343 static const unsigned cycle_for_bank_swizzle_scl
[][3] = {
344 [SQ_ALU_SCL_210
] = { 2, 1, 0 },
345 [SQ_ALU_SCL_122
] = { 1, 2, 2 },
346 [SQ_ALU_SCL_212
] = { 2, 1, 2 },
347 [SQ_ALU_SCL_221
] = { 2, 2, 1 }
350 static void init_bank_swizzle(struct alu_bank_swizzle
*bs
)
352 int i
, cycle
, component
;
354 for (cycle
= 0; cycle
< NUM_OF_CYCLES
; cycle
++)
355 for (component
= 0; component
< NUM_OF_COMPONENTS
; component
++)
356 bs
->hw_gpr
[cycle
][component
] = -1;
357 for (i
= 0; i
< 4; i
++)
358 bs
->hw_cfile_addr
[i
] = -1;
359 for (i
= 0; i
< 4; i
++)
360 bs
->hw_cfile_elem
[i
] = -1;
363 static int reserve_gpr(struct alu_bank_swizzle
*bs
, unsigned sel
, unsigned chan
, unsigned cycle
)
365 if (bs
->hw_gpr
[cycle
][chan
] == -1)
366 bs
->hw_gpr
[cycle
][chan
] = sel
;
367 else if (bs
->hw_gpr
[cycle
][chan
] != (int)sel
) {
368 /* Another scalar operation has already used the GPR read port for the channel. */
374 static int reserve_cfile(struct r600_bytecode
*bc
, struct alu_bank_swizzle
*bs
, unsigned sel
, unsigned chan
)
376 int res
, num_res
= 4;
377 if (bc
->chip_class
>= R700
) {
381 for (res
= 0; res
< num_res
; ++res
) {
382 if (bs
->hw_cfile_addr
[res
] == -1) {
383 bs
->hw_cfile_addr
[res
] = sel
;
384 bs
->hw_cfile_elem
[res
] = chan
;
386 } else if (bs
->hw_cfile_addr
[res
] == sel
&&
387 bs
->hw_cfile_elem
[res
] == chan
)
388 return 0; /* Read for this scalar element already reserved, nothing to do here. */
390 /* All cfile read ports are used, cannot reference vector element. */
394 static int is_gpr(unsigned sel
)
399 /* CB constants start at 512, and get translated to a kcache index when ALU
400 * clauses are constructed. Note that we handle kcache constants the same way
401 * as (the now gone) cfile constants, is that really required? */
402 static int is_cfile(unsigned sel
)
404 return (sel
> 255 && sel
< 512) ||
405 (sel
> 511 && sel
< 4607) || /* Kcache before translation. */
406 (sel
> 127 && sel
< 192); /* Kcache after translation. */
409 static int is_const(int sel
)
411 return is_cfile(sel
) ||
412 (sel
>= V_SQ_ALU_SRC_0
&&
413 sel
<= V_SQ_ALU_SRC_LITERAL
);
416 static int check_vector(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
,
417 struct alu_bank_swizzle
*bs
, int bank_swizzle
)
419 int r
, src
, num_src
, sel
, elem
, cycle
;
421 num_src
= r600_bytecode_get_num_operands(bc
, alu
);
422 for (src
= 0; src
< num_src
; src
++) {
423 sel
= alu
->src
[src
].sel
;
424 elem
= alu
->src
[src
].chan
;
426 cycle
= cycle_for_bank_swizzle_vec
[bank_swizzle
][src
];
427 if (src
== 1 && sel
== alu
->src
[0].sel
&& elem
== alu
->src
[0].chan
)
428 /* Nothing to do; special-case optimization,
429 * second source uses first source’s reservation. */
432 r
= reserve_gpr(bs
, sel
, elem
, cycle
);
436 } else if (is_cfile(sel
)) {
437 r
= reserve_cfile(bc
, bs
, (alu
->src
[src
].kc_bank
<<16) + sel
, elem
);
441 /* No restrictions on PV, PS, literal or special constants. */
446 static int check_scalar(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
,
447 struct alu_bank_swizzle
*bs
, int bank_swizzle
)
449 int r
, src
, num_src
, const_count
, sel
, elem
, cycle
;
451 num_src
= r600_bytecode_get_num_operands(bc
, alu
);
452 for (const_count
= 0, src
= 0; src
< num_src
; ++src
) {
453 sel
= alu
->src
[src
].sel
;
454 elem
= alu
->src
[src
].chan
;
455 if (is_const(sel
)) { /* Any constant, including literal and inline constants. */
456 if (const_count
>= 2)
457 /* More than two references to a constant in
458 * transcendental operation. */
464 r
= reserve_cfile(bc
, bs
, (alu
->src
[src
].kc_bank
<<16) + sel
, elem
);
469 for (src
= 0; src
< num_src
; ++src
) {
470 sel
= alu
->src
[src
].sel
;
471 elem
= alu
->src
[src
].chan
;
473 cycle
= cycle_for_bank_swizzle_scl
[bank_swizzle
][src
];
474 if (cycle
< const_count
)
475 /* Cycle for GPR load conflicts with
476 * constant load in transcendental operation. */
478 r
= reserve_gpr(bs
, sel
, elem
, cycle
);
482 /* PV PS restrictions */
483 if (const_count
&& (sel
== 254 || sel
== 255)) {
484 cycle
= cycle_for_bank_swizzle_scl
[bank_swizzle
][src
];
485 if (cycle
< const_count
)
492 static int check_and_set_bank_swizzle(struct r600_bytecode
*bc
,
493 struct r600_bytecode_alu
*slots
[5])
495 struct alu_bank_swizzle bs
;
497 int i
, r
= 0, forced
= 1;
498 boolean scalar_only
= bc
->chip_class
== CAYMAN
? false : true;
499 int max_slots
= bc
->chip_class
== CAYMAN
? 4 : 5;
501 for (i
= 0; i
< max_slots
; i
++) {
503 if (slots
[i
]->bank_swizzle_force
) {
504 slots
[i
]->bank_swizzle
= slots
[i
]->bank_swizzle_force
;
510 if (i
< 4 && slots
[i
])
516 /* Just check every possible combination of bank swizzle.
517 * Not very efficent, but works on the first try in most of the cases. */
518 for (i
= 0; i
< 4; i
++)
519 if (!slots
[i
] || !slots
[i
]->bank_swizzle_force
)
520 bank_swizzle
[i
] = SQ_ALU_VEC_012
;
522 bank_swizzle
[i
] = slots
[i
]->bank_swizzle
;
524 bank_swizzle
[4] = SQ_ALU_SCL_210
;
525 while(bank_swizzle
[4] <= SQ_ALU_SCL_221
) {
527 init_bank_swizzle(&bs
);
528 if (scalar_only
== false) {
529 for (i
= 0; i
< 4; i
++) {
531 r
= check_vector(bc
, slots
[i
], &bs
, bank_swizzle
[i
]);
539 if (!r
&& max_slots
== 5 && slots
[4]) {
540 r
= check_scalar(bc
, slots
[4], &bs
, bank_swizzle
[4]);
543 for (i
= 0; i
< max_slots
; i
++) {
545 slots
[i
]->bank_swizzle
= bank_swizzle
[i
];
553 for (i
= 0; i
< max_slots
; i
++) {
554 if (!slots
[i
] || !slots
[i
]->bank_swizzle_force
) {
556 if (bank_swizzle
[i
] <= SQ_ALU_VEC_210
)
558 else if (i
< max_slots
- 1)
559 bank_swizzle
[i
] = SQ_ALU_VEC_012
;
567 /* Couldn't find a working swizzle. */
571 static int replace_gpr_with_pv_ps(struct r600_bytecode
*bc
,
572 struct r600_bytecode_alu
*slots
[5], struct r600_bytecode_alu
*alu_prev
)
574 struct r600_bytecode_alu
*prev
[5];
576 int i
, j
, r
, src
, num_src
;
577 int max_slots
= bc
->chip_class
== CAYMAN
? 4 : 5;
579 r
= assign_alu_units(bc
, alu_prev
, prev
);
583 for (i
= 0; i
< max_slots
; ++i
) {
584 if (prev
[i
] && (prev
[i
]->dst
.write
|| prev
[i
]->is_op3
) && !prev
[i
]->dst
.rel
) {
586 if (is_alu_64bit_inst(bc
, prev
[i
])) {
591 gpr
[i
] = prev
[i
]->dst
.sel
;
592 /* cube writes more than PV.X */
593 if (is_alu_reduction_inst(bc
, prev
[i
]))
596 chan
[i
] = prev
[i
]->dst
.chan
;
601 for (i
= 0; i
< max_slots
; ++i
) {
602 struct r600_bytecode_alu
*alu
= slots
[i
];
606 if (is_alu_64bit_inst(bc
, alu
))
608 num_src
= r600_bytecode_get_num_operands(bc
, alu
);
609 for (src
= 0; src
< num_src
; ++src
) {
610 if (!is_gpr(alu
->src
[src
].sel
) || alu
->src
[src
].rel
)
613 if (bc
->chip_class
< CAYMAN
) {
614 if (alu
->src
[src
].sel
== gpr
[4] &&
615 alu
->src
[src
].chan
== chan
[4] &&
616 alu_prev
->pred_sel
== alu
->pred_sel
) {
617 alu
->src
[src
].sel
= V_SQ_ALU_SRC_PS
;
618 alu
->src
[src
].chan
= 0;
623 for (j
= 0; j
< 4; ++j
) {
624 if (alu
->src
[src
].sel
== gpr
[j
] &&
625 alu
->src
[src
].chan
== j
&&
626 alu_prev
->pred_sel
== alu
->pred_sel
) {
627 alu
->src
[src
].sel
= V_SQ_ALU_SRC_PV
;
628 alu
->src
[src
].chan
= chan
[j
];
638 void r600_bytecode_special_constants(uint32_t value
, unsigned *sel
, unsigned *neg
)
642 *sel
= V_SQ_ALU_SRC_0
;
645 *sel
= V_SQ_ALU_SRC_1_INT
;
648 *sel
= V_SQ_ALU_SRC_M_1_INT
;
650 case 0x3F800000: /* 1.0f */
651 *sel
= V_SQ_ALU_SRC_1
;
653 case 0x3F000000: /* 0.5f */
654 *sel
= V_SQ_ALU_SRC_0_5
;
656 case 0xBF800000: /* -1.0f */
657 *sel
= V_SQ_ALU_SRC_1
;
660 case 0xBF000000: /* -0.5f */
661 *sel
= V_SQ_ALU_SRC_0_5
;
665 *sel
= V_SQ_ALU_SRC_LITERAL
;
670 /* compute how many literal are needed */
671 static int r600_bytecode_alu_nliterals(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
,
672 uint32_t literal
[4], unsigned *nliteral
)
674 unsigned num_src
= r600_bytecode_get_num_operands(bc
, alu
);
677 for (i
= 0; i
< num_src
; ++i
) {
678 if (alu
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
679 uint32_t value
= alu
->src
[i
].value
;
681 for (j
= 0; j
< *nliteral
; ++j
) {
682 if (literal
[j
] == value
) {
690 literal
[(*nliteral
)++] = value
;
697 static void r600_bytecode_alu_adjust_literals(struct r600_bytecode
*bc
,
698 struct r600_bytecode_alu
*alu
,
699 uint32_t literal
[4], unsigned nliteral
)
701 unsigned num_src
= r600_bytecode_get_num_operands(bc
, alu
);
704 for (i
= 0; i
< num_src
; ++i
) {
705 if (alu
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
706 uint32_t value
= alu
->src
[i
].value
;
707 for (j
= 0; j
< nliteral
; ++j
) {
708 if (literal
[j
] == value
) {
709 alu
->src
[i
].chan
= j
;
717 static int merge_inst_groups(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*slots
[5],
718 struct r600_bytecode_alu
*alu_prev
)
720 struct r600_bytecode_alu
*prev
[5];
721 struct r600_bytecode_alu
*result
[5] = { NULL
};
723 uint32_t literal
[4], prev_literal
[4];
724 unsigned nliteral
= 0, prev_nliteral
= 0;
726 int i
, j
, r
, src
, num_src
;
727 int num_once_inst
= 0;
728 int have_mova
= 0, have_rel
= 0;
729 int max_slots
= bc
->chip_class
== CAYMAN
? 4 : 5;
731 r
= assign_alu_units(bc
, alu_prev
, prev
);
735 for (i
= 0; i
< max_slots
; ++i
) {
737 if (prev
[i
]->pred_sel
)
739 if (is_alu_once_inst(bc
, prev
[i
]))
743 if (slots
[i
]->pred_sel
)
745 if (is_alu_once_inst(bc
, slots
[i
]))
750 for (i
= 0; i
< max_slots
; ++i
) {
751 struct r600_bytecode_alu
*alu
;
753 if (num_once_inst
> 0)
756 /* check number of literals */
758 if (r600_bytecode_alu_nliterals(bc
, prev
[i
], literal
, &nliteral
))
760 if (r600_bytecode_alu_nliterals(bc
, prev
[i
], prev_literal
, &prev_nliteral
))
762 if (is_alu_mova_inst(bc
, prev
[i
])) {
768 if (alu_uses_rel(bc
, prev
[i
])) {
775 num_once_inst
+= is_alu_once_inst(bc
, prev
[i
]);
777 if (slots
[i
] && r600_bytecode_alu_nliterals(bc
, slots
[i
], literal
, &nliteral
))
780 /* Let's check used slots. */
781 if (prev
[i
] && !slots
[i
]) {
784 } else if (prev
[i
] && slots
[i
]) {
785 if (max_slots
== 5 && result
[4] == NULL
&& prev
[4] == NULL
&& slots
[4] == NULL
) {
786 /* Trans unit is still free try to use it. */
787 if (is_alu_any_unit_inst(bc
, slots
[i
])) {
789 result
[4] = slots
[i
];
790 } else if (is_alu_any_unit_inst(bc
, prev
[i
])) {
791 if (slots
[i
]->dst
.sel
== prev
[i
]->dst
.sel
&&
792 (slots
[i
]->dst
.write
== 1 || slots
[i
]->is_op3
) &&
793 (prev
[i
]->dst
.write
== 1 || prev
[i
]->is_op3
))
796 result
[i
] = slots
[i
];
802 } else if(!slots
[i
]) {
805 if (max_slots
== 5 && slots
[i
] && prev
[4] &&
806 slots
[i
]->dst
.sel
== prev
[4]->dst
.sel
&&
807 slots
[i
]->dst
.chan
== prev
[4]->dst
.chan
&&
808 (slots
[i
]->dst
.write
== 1 || slots
[i
]->is_op3
) &&
809 (prev
[4]->dst
.write
== 1 || prev
[4]->is_op3
))
812 result
[i
] = slots
[i
];
816 num_once_inst
+= is_alu_once_inst(bc
, alu
);
818 /* don't reschedule NOPs */
819 if (is_nop_inst(bc
, alu
))
822 if (is_alu_mova_inst(bc
, alu
)) {
829 if (alu_uses_rel(bc
, alu
)) {
836 if (alu
->op
== ALU_OP0_SET_CF_IDX0
||
837 alu
->op
== ALU_OP0_SET_CF_IDX1
)
838 return 0; /* data hazard with MOVA */
840 /* Let's check source gprs */
841 num_src
= r600_bytecode_get_num_operands(bc
, alu
);
842 for (src
= 0; src
< num_src
; ++src
) {
844 /* Constants don't matter. */
845 if (!is_gpr(alu
->src
[src
].sel
))
848 for (j
= 0; j
< max_slots
; ++j
) {
849 if (!prev
[j
] || !(prev
[j
]->dst
.write
|| prev
[j
]->is_op3
))
852 /* If it's relative then we can't determin which gpr is really used. */
853 if (prev
[j
]->dst
.chan
== alu
->src
[src
].chan
&&
854 (prev
[j
]->dst
.sel
== alu
->src
[src
].sel
||
855 prev
[j
]->dst
.rel
|| alu
->src
[src
].rel
))
861 /* more than one PRED_ or KILL_ ? */
862 if (num_once_inst
> 1)
865 /* check if the result can still be swizzlet */
866 r
= check_and_set_bank_swizzle(bc
, result
);
870 /* looks like everything worked out right, apply the changes */
872 /* undo adding previus literals */
873 bc
->cf_last
->ndw
-= align(prev_nliteral
, 2);
875 /* sort instructions */
876 for (i
= 0; i
< max_slots
; ++i
) {
877 slots
[i
] = result
[i
];
879 LIST_DEL(&result
[i
]->list
);
881 LIST_ADDTAIL(&result
[i
]->list
, &bc
->cf_last
->alu
);
885 /* determine new last instruction */
886 LIST_ENTRY(struct r600_bytecode_alu
, bc
->cf_last
->alu
.prev
, list
)->last
= 1;
888 /* determine new first instruction */
889 for (i
= 0; i
< max_slots
; ++i
) {
891 bc
->cf_last
->curr_bs_head
= result
[i
];
896 bc
->cf_last
->prev_bs_head
= bc
->cf_last
->prev2_bs_head
;
897 bc
->cf_last
->prev2_bs_head
= NULL
;
902 /* we'll keep kcache sets sorted by bank & addr */
903 static int r600_bytecode_alloc_kcache_line(struct r600_bytecode
*bc
,
904 struct r600_bytecode_kcache
*kcache
,
905 unsigned bank
, unsigned line
, unsigned index_mode
)
907 int i
, kcache_banks
= bc
->chip_class
>= EVERGREEN
? 4 : 2;
909 for (i
= 0; i
< kcache_banks
; i
++) {
910 if (kcache
[i
].mode
) {
913 if (kcache
[i
].bank
< bank
)
916 if ((kcache
[i
].bank
== bank
&& kcache
[i
].addr
> line
+1) ||
917 kcache
[i
].bank
> bank
) {
918 /* try to insert new line */
919 if (kcache
[kcache_banks
-1].mode
) {
920 /* all sets are in use */
924 memmove(&kcache
[i
+1],&kcache
[i
], (kcache_banks
-i
-1)*sizeof(struct r600_bytecode_kcache
));
925 kcache
[i
].mode
= V_SQ_CF_KCACHE_LOCK_1
;
926 kcache
[i
].bank
= bank
;
927 kcache
[i
].addr
= line
;
928 kcache
[i
].index_mode
= index_mode
;
932 d
= line
- kcache
[i
].addr
;
936 if (kcache
[i
].mode
== V_SQ_CF_KCACHE_LOCK_2
) {
937 /* we are prepending the line to the current set,
938 * discarding the existing second line,
939 * so we'll have to insert line+2 after it */
942 } else if (kcache
[i
].mode
== V_SQ_CF_KCACHE_LOCK_1
) {
943 kcache
[i
].mode
= V_SQ_CF_KCACHE_LOCK_2
;
946 /* V_SQ_CF_KCACHE_LOCK_LOOP_INDEX is not supported */
950 kcache
[i
].mode
= V_SQ_CF_KCACHE_LOCK_2
;
954 } else { /* free kcache set - use it */
955 kcache
[i
].mode
= V_SQ_CF_KCACHE_LOCK_1
;
956 kcache
[i
].bank
= bank
;
957 kcache
[i
].addr
= line
;
958 kcache
[i
].index_mode
= index_mode
;
965 static int r600_bytecode_alloc_inst_kcache_lines(struct r600_bytecode
*bc
,
966 struct r600_bytecode_kcache
*kcache
,
967 struct r600_bytecode_alu
*alu
)
971 for (i
= 0; i
< 3; i
++) {
972 unsigned bank
, line
, sel
= alu
->src
[i
].sel
, index_mode
;
977 bank
= alu
->src
[i
].kc_bank
;
979 index_mode
= alu
->src
[i
].kc_rel
? 1 : 0; // V_SQ_CF_INDEX_0 / V_SQ_CF_INDEX_NONE
981 if ((r
= r600_bytecode_alloc_kcache_line(bc
, kcache
, bank
, line
, index_mode
)))
987 static int r600_bytecode_assign_kcache_banks(struct r600_bytecode
*bc
,
988 struct r600_bytecode_alu
*alu
,
989 struct r600_bytecode_kcache
* kcache
)
993 /* Alter the src operands to refer to the kcache. */
994 for (i
= 0; i
< 3; ++i
) {
995 static const unsigned int base
[] = {128, 160, 256, 288};
996 unsigned int line
, sel
= alu
->src
[i
].sel
, found
= 0;
1004 for (j
= 0; j
< 4 && !found
; ++j
) {
1005 switch (kcache
[j
].mode
) {
1006 case V_SQ_CF_KCACHE_NOP
:
1007 case V_SQ_CF_KCACHE_LOCK_LOOP_INDEX
:
1008 R600_ERR("unexpected kcache line mode\n");
1011 if (kcache
[j
].bank
== alu
->src
[i
].kc_bank
&&
1012 kcache
[j
].addr
<= line
&&
1013 line
< kcache
[j
].addr
+ kcache
[j
].mode
) {
1014 alu
->src
[i
].sel
= sel
- (kcache
[j
].addr
<<4);
1015 alu
->src
[i
].sel
+= base
[j
];
1024 static int r600_bytecode_alloc_kcache_lines(struct r600_bytecode
*bc
,
1025 struct r600_bytecode_alu
*alu
,
1028 struct r600_bytecode_kcache kcache_sets
[4];
1029 struct r600_bytecode_kcache
*kcache
= kcache_sets
;
1032 memcpy(kcache
, bc
->cf_last
->kcache
, 4 * sizeof(struct r600_bytecode_kcache
));
1034 if ((r
= r600_bytecode_alloc_inst_kcache_lines(bc
, kcache
, alu
))) {
1035 /* can't alloc, need to start new clause */
1036 if ((r
= r600_bytecode_add_cf(bc
))) {
1039 bc
->cf_last
->op
= type
;
1041 /* retry with the new clause */
1042 kcache
= bc
->cf_last
->kcache
;
1043 if ((r
= r600_bytecode_alloc_inst_kcache_lines(bc
, kcache
, alu
))) {
1044 /* can't alloc again- should never happen */
1048 /* update kcache sets */
1049 memcpy(bc
->cf_last
->kcache
, kcache
, 4 * sizeof(struct r600_bytecode_kcache
));
1052 /* if we actually used more than 2 kcache sets, or have relative indexing - use ALU_EXTENDED on eg+ */
1053 if (kcache
[2].mode
!= V_SQ_CF_KCACHE_NOP
||
1054 kcache
[0].index_mode
|| kcache
[1].index_mode
|| kcache
[2].index_mode
|| kcache
[3].index_mode
) {
1055 if (bc
->chip_class
< EVERGREEN
)
1057 bc
->cf_last
->eg_alu_extended
= 1;
1063 static int insert_nop_r6xx(struct r600_bytecode
*bc
)
1065 struct r600_bytecode_alu alu
;
1068 for (i
= 0; i
< 4; i
++) {
1069 memset(&alu
, 0, sizeof(alu
));
1070 alu
.op
= ALU_OP0_NOP
;
1071 alu
.src
[0].chan
= i
;
1073 alu
.last
= (i
== 3);
1074 r
= r600_bytecode_add_alu(bc
, &alu
);
1081 /* load AR register from gpr (bc->ar_reg) with MOVA_INT */
1082 static int load_ar_r6xx(struct r600_bytecode
*bc
)
1084 struct r600_bytecode_alu alu
;
1090 /* hack to avoid making MOVA the last instruction in the clause */
1091 if ((bc
->cf_last
->ndw
>>1) >= 110)
1092 bc
->force_add_cf
= 1;
1094 memset(&alu
, 0, sizeof(alu
));
1095 alu
.op
= ALU_OP1_MOVA_GPR_INT
;
1096 alu
.src
[0].sel
= bc
->ar_reg
;
1097 alu
.src
[0].chan
= bc
->ar_chan
;
1099 alu
.index_mode
= INDEX_MODE_LOOP
;
1100 r
= r600_bytecode_add_alu(bc
, &alu
);
1104 /* no requirement to set uses waterfall on MOVA_GPR_INT */
1109 /* load AR register from gpr (bc->ar_reg) with MOVA_INT */
1110 static int load_ar(struct r600_bytecode
*bc
)
1112 struct r600_bytecode_alu alu
;
1115 if (bc
->ar_handling
)
1116 return load_ar_r6xx(bc
);
1121 /* hack to avoid making MOVA the last instruction in the clause */
1122 if ((bc
->cf_last
->ndw
>>1) >= 110)
1123 bc
->force_add_cf
= 1;
1125 memset(&alu
, 0, sizeof(alu
));
1126 alu
.op
= ALU_OP1_MOVA_INT
;
1127 alu
.src
[0].sel
= bc
->ar_reg
;
1128 alu
.src
[0].chan
= bc
->ar_chan
;
1130 r
= r600_bytecode_add_alu(bc
, &alu
);
1134 bc
->cf_last
->r6xx_uses_waterfall
= 1;
1139 int r600_bytecode_add_alu_type(struct r600_bytecode
*bc
,
1140 const struct r600_bytecode_alu
*alu
, unsigned type
)
1142 struct r600_bytecode_alu
*nalu
= r600_bytecode_alu();
1143 struct r600_bytecode_alu
*lalu
;
1148 memcpy(nalu
, alu
, sizeof(struct r600_bytecode_alu
));
1151 /* will fail later since alu does not support it. */
1152 assert(!alu
->src
[0].abs
&& !alu
->src
[1].abs
&& !alu
->src
[2].abs
);
1155 if (bc
->cf_last
!= NULL
&& bc
->cf_last
->op
!= type
) {
1156 /* check if we could add it anyway */
1157 if (bc
->cf_last
->op
== CF_OP_ALU
&&
1158 type
== CF_OP_ALU_PUSH_BEFORE
) {
1159 LIST_FOR_EACH_ENTRY(lalu
, &bc
->cf_last
->alu
, list
) {
1160 if (lalu
->execute_mask
) {
1161 bc
->force_add_cf
= 1;
1166 bc
->force_add_cf
= 1;
1169 /* cf can contains only alu or only vtx or only tex */
1170 if (bc
->cf_last
== NULL
|| bc
->force_add_cf
) {
1171 r
= r600_bytecode_add_cf(bc
);
1177 bc
->cf_last
->op
= type
;
1179 /* Load index register if required */
1180 if (bc
->chip_class
>= EVERGREEN
) {
1181 for (i
= 0; i
< 3; i
++)
1182 if (nalu
->src
[i
].kc_bank
&& nalu
->src
[i
].kc_rel
)
1183 egcm_load_index_reg(bc
, 0, true);
1186 /* Check AR usage and load it if required */
1187 for (i
= 0; i
< 3; i
++)
1188 if (nalu
->src
[i
].rel
&& !bc
->ar_loaded
)
1191 if (nalu
->dst
.rel
&& !bc
->ar_loaded
)
1194 /* Setup the kcache for this ALU instruction. This will start a new
1195 * ALU clause if needed. */
1196 if ((r
= r600_bytecode_alloc_kcache_lines(bc
, nalu
, type
))) {
1201 if (!bc
->cf_last
->curr_bs_head
) {
1202 bc
->cf_last
->curr_bs_head
= nalu
;
1204 /* number of gpr == the last gpr used in any alu */
1205 for (i
= 0; i
< 3; i
++) {
1206 if (nalu
->src
[i
].sel
>= bc
->ngpr
&& nalu
->src
[i
].sel
< 128) {
1207 bc
->ngpr
= nalu
->src
[i
].sel
+ 1;
1209 if (nalu
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
)
1210 r600_bytecode_special_constants(nalu
->src
[i
].value
,
1211 &nalu
->src
[i
].sel
, &nalu
->src
[i
].neg
);
1213 if (nalu
->dst
.sel
>= bc
->ngpr
) {
1214 bc
->ngpr
= nalu
->dst
.sel
+ 1;
1216 LIST_ADDTAIL(&nalu
->list
, &bc
->cf_last
->alu
);
1217 /* each alu use 2 dwords */
1218 bc
->cf_last
->ndw
+= 2;
1221 /* process cur ALU instructions for bank swizzle */
1223 uint32_t literal
[4];
1225 struct r600_bytecode_alu
*slots
[5];
1226 int max_slots
= bc
->chip_class
== CAYMAN
? 4 : 5;
1227 r
= assign_alu_units(bc
, bc
->cf_last
->curr_bs_head
, slots
);
1231 if (bc
->cf_last
->prev_bs_head
) {
1232 r
= merge_inst_groups(bc
, slots
, bc
->cf_last
->prev_bs_head
);
1237 if (bc
->cf_last
->prev_bs_head
) {
1238 r
= replace_gpr_with_pv_ps(bc
, slots
, bc
->cf_last
->prev_bs_head
);
1243 r
= check_and_set_bank_swizzle(bc
, slots
);
1247 for (i
= 0, nliteral
= 0; i
< max_slots
; i
++) {
1249 r
= r600_bytecode_alu_nliterals(bc
, slots
[i
], literal
, &nliteral
);
1254 bc
->cf_last
->ndw
+= align(nliteral
, 2);
1256 /* at most 128 slots, one add alu can add 5 slots + 4 constants(2 slots)
1258 if ((bc
->cf_last
->ndw
>> 1) >= 120) {
1259 bc
->force_add_cf
= 1;
1262 bc
->cf_last
->prev2_bs_head
= bc
->cf_last
->prev_bs_head
;
1263 bc
->cf_last
->prev_bs_head
= bc
->cf_last
->curr_bs_head
;
1264 bc
->cf_last
->curr_bs_head
= NULL
;
1267 if (nalu
->dst
.rel
&& bc
->r6xx_nop_after_rel_dst
)
1268 insert_nop_r6xx(bc
);
1273 int r600_bytecode_add_alu(struct r600_bytecode
*bc
, const struct r600_bytecode_alu
*alu
)
1275 return r600_bytecode_add_alu_type(bc
, alu
, CF_OP_ALU
);
1278 static unsigned r600_bytecode_num_tex_and_vtx_instructions(const struct r600_bytecode
*bc
)
1280 switch (bc
->chip_class
) {
1290 R600_ERR("Unknown chip class %d.\n", bc
->chip_class
);
1295 static inline boolean
last_inst_was_not_vtx_fetch(struct r600_bytecode
*bc
)
1297 return !((r600_isa_cf(bc
->cf_last
->op
)->flags
& CF_FETCH
) &&
1298 (bc
->chip_class
== CAYMAN
||
1299 bc
->cf_last
->op
!= CF_OP_TEX
));
1302 int r600_bytecode_add_vtx(struct r600_bytecode
*bc
, const struct r600_bytecode_vtx
*vtx
)
1304 struct r600_bytecode_vtx
*nvtx
= r600_bytecode_vtx();
1309 memcpy(nvtx
, vtx
, sizeof(struct r600_bytecode_vtx
));
1311 /* Load index register if required */
1312 if (bc
->chip_class
>= EVERGREEN
) {
1313 if (vtx
->buffer_index_mode
)
1314 egcm_load_index_reg(bc
, 0, false);
1317 /* cf can contains only alu or only vtx or only tex */
1318 if (bc
->cf_last
== NULL
||
1319 last_inst_was_not_vtx_fetch(bc
) ||
1321 r
= r600_bytecode_add_cf(bc
);
1326 switch (bc
->chip_class
) {
1330 bc
->cf_last
->op
= CF_OP_VTX
;
1333 bc
->cf_last
->op
= CF_OP_TEX
;
1336 R600_ERR("Unknown chip class %d.\n", bc
->chip_class
);
1341 LIST_ADDTAIL(&nvtx
->list
, &bc
->cf_last
->vtx
);
1342 /* each fetch use 4 dwords */
1343 bc
->cf_last
->ndw
+= 4;
1345 if ((bc
->cf_last
->ndw
/ 4) >= r600_bytecode_num_tex_and_vtx_instructions(bc
))
1346 bc
->force_add_cf
= 1;
1348 bc
->ngpr
= MAX2(bc
->ngpr
, vtx
->src_gpr
+ 1);
1349 bc
->ngpr
= MAX2(bc
->ngpr
, vtx
->dst_gpr
+ 1);
1354 int r600_bytecode_add_tex(struct r600_bytecode
*bc
, const struct r600_bytecode_tex
*tex
)
1356 struct r600_bytecode_tex
*ntex
= r600_bytecode_tex();
1361 memcpy(ntex
, tex
, sizeof(struct r600_bytecode_tex
));
1363 /* Load index register if required */
1364 if (bc
->chip_class
>= EVERGREEN
) {
1365 if (tex
->sampler_index_mode
|| tex
->resource_index_mode
)
1366 egcm_load_index_reg(bc
, 1, false);
1369 /* we can't fetch data und use it as texture lookup address in the same TEX clause */
1370 if (bc
->cf_last
!= NULL
&&
1371 bc
->cf_last
->op
== CF_OP_TEX
) {
1372 struct r600_bytecode_tex
*ttex
;
1373 LIST_FOR_EACH_ENTRY(ttex
, &bc
->cf_last
->tex
, list
) {
1374 if (ttex
->dst_gpr
== ntex
->src_gpr
) {
1375 bc
->force_add_cf
= 1;
1379 /* slight hack to make gradients always go into same cf */
1380 if (ntex
->op
== FETCH_OP_SET_GRADIENTS_H
)
1381 bc
->force_add_cf
= 1;
1384 /* cf can contains only alu or only vtx or only tex */
1385 if (bc
->cf_last
== NULL
||
1386 bc
->cf_last
->op
!= CF_OP_TEX
||
1388 r
= r600_bytecode_add_cf(bc
);
1393 bc
->cf_last
->op
= CF_OP_TEX
;
1395 if (ntex
->src_gpr
>= bc
->ngpr
) {
1396 bc
->ngpr
= ntex
->src_gpr
+ 1;
1398 if (ntex
->dst_gpr
>= bc
->ngpr
) {
1399 bc
->ngpr
= ntex
->dst_gpr
+ 1;
1401 LIST_ADDTAIL(&ntex
->list
, &bc
->cf_last
->tex
);
1402 /* each texture fetch use 4 dwords */
1403 bc
->cf_last
->ndw
+= 4;
1405 if ((bc
->cf_last
->ndw
/ 4) >= r600_bytecode_num_tex_and_vtx_instructions(bc
))
1406 bc
->force_add_cf
= 1;
1410 int r600_bytecode_add_cfinst(struct r600_bytecode
*bc
, unsigned op
)
1413 r
= r600_bytecode_add_cf(bc
);
1417 bc
->cf_last
->cond
= V_SQ_CF_COND_ACTIVE
;
1418 bc
->cf_last
->op
= op
;
1422 int cm_bytecode_add_cf_end(struct r600_bytecode
*bc
)
1424 return r600_bytecode_add_cfinst(bc
, CF_OP_CF_END
);
1427 /* common to all 3 families */
1428 static int r600_bytecode_vtx_build(struct r600_bytecode
*bc
, struct r600_bytecode_vtx
*vtx
, unsigned id
)
1430 bc
->bytecode
[id
] = S_SQ_VTX_WORD0_BUFFER_ID(vtx
->buffer_id
) |
1431 S_SQ_VTX_WORD0_FETCH_TYPE(vtx
->fetch_type
) |
1432 S_SQ_VTX_WORD0_SRC_GPR(vtx
->src_gpr
) |
1433 S_SQ_VTX_WORD0_SRC_SEL_X(vtx
->src_sel_x
);
1434 if (bc
->chip_class
< CAYMAN
)
1435 bc
->bytecode
[id
] |= S_SQ_VTX_WORD0_MEGA_FETCH_COUNT(vtx
->mega_fetch_count
);
1437 bc
->bytecode
[id
++] = S_SQ_VTX_WORD1_DST_SEL_X(vtx
->dst_sel_x
) |
1438 S_SQ_VTX_WORD1_DST_SEL_Y(vtx
->dst_sel_y
) |
1439 S_SQ_VTX_WORD1_DST_SEL_Z(vtx
->dst_sel_z
) |
1440 S_SQ_VTX_WORD1_DST_SEL_W(vtx
->dst_sel_w
) |
1441 S_SQ_VTX_WORD1_USE_CONST_FIELDS(vtx
->use_const_fields
) |
1442 S_SQ_VTX_WORD1_DATA_FORMAT(vtx
->data_format
) |
1443 S_SQ_VTX_WORD1_NUM_FORMAT_ALL(vtx
->num_format_all
) |
1444 S_SQ_VTX_WORD1_FORMAT_COMP_ALL(vtx
->format_comp_all
) |
1445 S_SQ_VTX_WORD1_SRF_MODE_ALL(vtx
->srf_mode_all
) |
1446 S_SQ_VTX_WORD1_GPR_DST_GPR(vtx
->dst_gpr
);
1447 bc
->bytecode
[id
] = S_SQ_VTX_WORD2_OFFSET(vtx
->offset
)|
1448 S_SQ_VTX_WORD2_ENDIAN_SWAP(vtx
->endian
);
1449 if (bc
->chip_class
>= EVERGREEN
)
1450 bc
->bytecode
[id
] |= ((vtx
->buffer_index_mode
& 0x3) << 21); // S_SQ_VTX_WORD2_BIM(vtx->buffer_index_mode);
1451 if (bc
->chip_class
< CAYMAN
)
1452 bc
->bytecode
[id
] |= S_SQ_VTX_WORD2_MEGA_FETCH(1);
1454 bc
->bytecode
[id
++] = 0;
1458 /* common to all 3 families */
1459 static int r600_bytecode_tex_build(struct r600_bytecode
*bc
, struct r600_bytecode_tex
*tex
, unsigned id
)
1461 bc
->bytecode
[id
] = S_SQ_TEX_WORD0_TEX_INST(
1462 r600_isa_fetch_opcode(bc
->isa
->hw_class
, tex
->op
)) |
1463 EG_S_SQ_TEX_WORD0_INST_MOD(tex
->inst_mod
) |
1464 S_SQ_TEX_WORD0_RESOURCE_ID(tex
->resource_id
) |
1465 S_SQ_TEX_WORD0_SRC_GPR(tex
->src_gpr
) |
1466 S_SQ_TEX_WORD0_SRC_REL(tex
->src_rel
);
1467 if (bc
->chip_class
>= EVERGREEN
)
1468 bc
->bytecode
[id
] |= ((tex
->sampler_index_mode
& 0x3) << 27) | // S_SQ_TEX_WORD0_SIM(tex->sampler_index_mode);
1469 ((tex
->resource_index_mode
& 0x3) << 25); // S_SQ_TEX_WORD0_RIM(tex->resource_index_mode)
1471 bc
->bytecode
[id
++] = S_SQ_TEX_WORD1_DST_GPR(tex
->dst_gpr
) |
1472 S_SQ_TEX_WORD1_DST_REL(tex
->dst_rel
) |
1473 S_SQ_TEX_WORD1_DST_SEL_X(tex
->dst_sel_x
) |
1474 S_SQ_TEX_WORD1_DST_SEL_Y(tex
->dst_sel_y
) |
1475 S_SQ_TEX_WORD1_DST_SEL_Z(tex
->dst_sel_z
) |
1476 S_SQ_TEX_WORD1_DST_SEL_W(tex
->dst_sel_w
) |
1477 S_SQ_TEX_WORD1_LOD_BIAS(tex
->lod_bias
) |
1478 S_SQ_TEX_WORD1_COORD_TYPE_X(tex
->coord_type_x
) |
1479 S_SQ_TEX_WORD1_COORD_TYPE_Y(tex
->coord_type_y
) |
1480 S_SQ_TEX_WORD1_COORD_TYPE_Z(tex
->coord_type_z
) |
1481 S_SQ_TEX_WORD1_COORD_TYPE_W(tex
->coord_type_w
);
1482 bc
->bytecode
[id
++] = S_SQ_TEX_WORD2_OFFSET_X(tex
->offset_x
) |
1483 S_SQ_TEX_WORD2_OFFSET_Y(tex
->offset_y
) |
1484 S_SQ_TEX_WORD2_OFFSET_Z(tex
->offset_z
) |
1485 S_SQ_TEX_WORD2_SAMPLER_ID(tex
->sampler_id
) |
1486 S_SQ_TEX_WORD2_SRC_SEL_X(tex
->src_sel_x
) |
1487 S_SQ_TEX_WORD2_SRC_SEL_Y(tex
->src_sel_y
) |
1488 S_SQ_TEX_WORD2_SRC_SEL_Z(tex
->src_sel_z
) |
1489 S_SQ_TEX_WORD2_SRC_SEL_W(tex
->src_sel_w
);
1490 bc
->bytecode
[id
++] = 0;
1494 /* r600 only, r700/eg bits in r700_asm.c */
1495 static int r600_bytecode_alu_build(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
, unsigned id
)
1497 unsigned opcode
= r600_isa_alu_opcode(bc
->isa
->hw_class
, alu
->op
);
1499 /* don't replace gpr by pv or ps for destination register */
1500 bc
->bytecode
[id
++] = S_SQ_ALU_WORD0_SRC0_SEL(alu
->src
[0].sel
) |
1501 S_SQ_ALU_WORD0_SRC0_REL(alu
->src
[0].rel
) |
1502 S_SQ_ALU_WORD0_SRC0_CHAN(alu
->src
[0].chan
) |
1503 S_SQ_ALU_WORD0_SRC0_NEG(alu
->src
[0].neg
) |
1504 S_SQ_ALU_WORD0_SRC1_SEL(alu
->src
[1].sel
) |
1505 S_SQ_ALU_WORD0_SRC1_REL(alu
->src
[1].rel
) |
1506 S_SQ_ALU_WORD0_SRC1_CHAN(alu
->src
[1].chan
) |
1507 S_SQ_ALU_WORD0_SRC1_NEG(alu
->src
[1].neg
) |
1508 S_SQ_ALU_WORD0_INDEX_MODE(alu
->index_mode
) |
1509 S_SQ_ALU_WORD0_PRED_SEL(alu
->pred_sel
) |
1510 S_SQ_ALU_WORD0_LAST(alu
->last
);
1513 assert(!alu
->src
[0].abs
&& !alu
->src
[1].abs
&& !alu
->src
[2].abs
);
1514 bc
->bytecode
[id
++] = S_SQ_ALU_WORD1_DST_GPR(alu
->dst
.sel
) |
1515 S_SQ_ALU_WORD1_DST_CHAN(alu
->dst
.chan
) |
1516 S_SQ_ALU_WORD1_DST_REL(alu
->dst
.rel
) |
1517 S_SQ_ALU_WORD1_CLAMP(alu
->dst
.clamp
) |
1518 S_SQ_ALU_WORD1_OP3_SRC2_SEL(alu
->src
[2].sel
) |
1519 S_SQ_ALU_WORD1_OP3_SRC2_REL(alu
->src
[2].rel
) |
1520 S_SQ_ALU_WORD1_OP3_SRC2_CHAN(alu
->src
[2].chan
) |
1521 S_SQ_ALU_WORD1_OP3_SRC2_NEG(alu
->src
[2].neg
) |
1522 S_SQ_ALU_WORD1_OP3_ALU_INST(opcode
) |
1523 S_SQ_ALU_WORD1_BANK_SWIZZLE(alu
->bank_swizzle
);
1525 bc
->bytecode
[id
++] = S_SQ_ALU_WORD1_DST_GPR(alu
->dst
.sel
) |
1526 S_SQ_ALU_WORD1_DST_CHAN(alu
->dst
.chan
) |
1527 S_SQ_ALU_WORD1_DST_REL(alu
->dst
.rel
) |
1528 S_SQ_ALU_WORD1_CLAMP(alu
->dst
.clamp
) |
1529 S_SQ_ALU_WORD1_OP2_SRC0_ABS(alu
->src
[0].abs
) |
1530 S_SQ_ALU_WORD1_OP2_SRC1_ABS(alu
->src
[1].abs
) |
1531 S_SQ_ALU_WORD1_OP2_WRITE_MASK(alu
->dst
.write
) |
1532 S_SQ_ALU_WORD1_OP2_OMOD(alu
->omod
) |
1533 S_SQ_ALU_WORD1_OP2_ALU_INST(opcode
) |
1534 S_SQ_ALU_WORD1_BANK_SWIZZLE(alu
->bank_swizzle
) |
1535 S_SQ_ALU_WORD1_OP2_UPDATE_EXECUTE_MASK(alu
->execute_mask
) |
1536 S_SQ_ALU_WORD1_OP2_UPDATE_PRED(alu
->update_pred
);
1541 static void r600_bytecode_cf_vtx_build(uint32_t *bytecode
, const struct r600_bytecode_cf
*cf
)
1543 *bytecode
++ = S_SQ_CF_WORD0_ADDR(cf
->addr
>> 1);
1544 *bytecode
++ = S_SQ_CF_WORD1_CF_INST(r600_isa_cf_opcode(ISA_CC_R600
, cf
->op
)) |
1545 S_SQ_CF_WORD1_BARRIER(1) |
1546 S_SQ_CF_WORD1_COUNT((cf
->ndw
/ 4) - 1);
1549 /* common for r600/r700 - eg in eg_asm.c */
1550 static int r600_bytecode_cf_build(struct r600_bytecode
*bc
, struct r600_bytecode_cf
*cf
)
1552 unsigned id
= cf
->id
;
1553 const struct cf_op_info
*cfop
= r600_isa_cf(cf
->op
);
1554 unsigned opcode
= r600_isa_cf_opcode(bc
->isa
->hw_class
, cf
->op
);
1557 if (cf
->op
== CF_NATIVE
) {
1558 bc
->bytecode
[id
++] = cf
->isa
[0];
1559 bc
->bytecode
[id
++] = cf
->isa
[1];
1560 } else if (cfop
->flags
& CF_ALU
) {
1561 bc
->bytecode
[id
++] = S_SQ_CF_ALU_WORD0_ADDR(cf
->addr
>> 1) |
1562 S_SQ_CF_ALU_WORD0_KCACHE_MODE0(cf
->kcache
[0].mode
) |
1563 S_SQ_CF_ALU_WORD0_KCACHE_BANK0(cf
->kcache
[0].bank
) |
1564 S_SQ_CF_ALU_WORD0_KCACHE_BANK1(cf
->kcache
[1].bank
);
1566 bc
->bytecode
[id
++] = S_SQ_CF_ALU_WORD1_CF_INST(opcode
) |
1567 S_SQ_CF_ALU_WORD1_KCACHE_MODE1(cf
->kcache
[1].mode
) |
1568 S_SQ_CF_ALU_WORD1_KCACHE_ADDR0(cf
->kcache
[0].addr
) |
1569 S_SQ_CF_ALU_WORD1_KCACHE_ADDR1(cf
->kcache
[1].addr
) |
1570 S_SQ_CF_ALU_WORD1_BARRIER(1) |
1571 S_SQ_CF_ALU_WORD1_USES_WATERFALL(bc
->chip_class
== R600
? cf
->r6xx_uses_waterfall
: 0) |
1572 S_SQ_CF_ALU_WORD1_COUNT((cf
->ndw
/ 2) - 1);
1573 } else if (cfop
->flags
& CF_FETCH
) {
1574 if (bc
->chip_class
== R700
)
1575 r700_bytecode_cf_vtx_build(&bc
->bytecode
[id
], cf
);
1577 r600_bytecode_cf_vtx_build(&bc
->bytecode
[id
], cf
);
1578 } else if (cfop
->flags
& CF_EXP
) {
1579 bc
->bytecode
[id
++] = S_SQ_CF_ALLOC_EXPORT_WORD0_RW_GPR(cf
->output
.gpr
) |
1580 S_SQ_CF_ALLOC_EXPORT_WORD0_ELEM_SIZE(cf
->output
.elem_size
) |
1581 S_SQ_CF_ALLOC_EXPORT_WORD0_ARRAY_BASE(cf
->output
.array_base
) |
1582 S_SQ_CF_ALLOC_EXPORT_WORD0_TYPE(cf
->output
.type
) |
1583 S_SQ_CF_ALLOC_EXPORT_WORD0_INDEX_GPR(cf
->output
.index_gpr
);
1584 bc
->bytecode
[id
++] = S_SQ_CF_ALLOC_EXPORT_WORD1_BURST_COUNT(cf
->output
.burst_count
- 1) |
1585 S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_X(cf
->output
.swizzle_x
) |
1586 S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Y(cf
->output
.swizzle_y
) |
1587 S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Z(cf
->output
.swizzle_z
) |
1588 S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_W(cf
->output
.swizzle_w
) |
1589 S_SQ_CF_ALLOC_EXPORT_WORD1_BARRIER(cf
->barrier
) |
1590 S_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(opcode
) |
1591 S_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM(cf
->end_of_program
);
1592 } else if (cfop
->flags
& CF_MEM
) {
1593 bc
->bytecode
[id
++] = S_SQ_CF_ALLOC_EXPORT_WORD0_RW_GPR(cf
->output
.gpr
) |
1594 S_SQ_CF_ALLOC_EXPORT_WORD0_ELEM_SIZE(cf
->output
.elem_size
) |
1595 S_SQ_CF_ALLOC_EXPORT_WORD0_ARRAY_BASE(cf
->output
.array_base
) |
1596 S_SQ_CF_ALLOC_EXPORT_WORD0_TYPE(cf
->output
.type
) |
1597 S_SQ_CF_ALLOC_EXPORT_WORD0_INDEX_GPR(cf
->output
.index_gpr
);
1598 bc
->bytecode
[id
++] = S_SQ_CF_ALLOC_EXPORT_WORD1_BURST_COUNT(cf
->output
.burst_count
- 1) |
1599 S_SQ_CF_ALLOC_EXPORT_WORD1_BARRIER(cf
->barrier
) |
1600 S_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(opcode
) |
1601 S_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM(cf
->end_of_program
) |
1602 S_SQ_CF_ALLOC_EXPORT_WORD1_BUF_ARRAY_SIZE(cf
->output
.array_size
) |
1603 S_SQ_CF_ALLOC_EXPORT_WORD1_BUF_COMP_MASK(cf
->output
.comp_mask
);
1605 bc
->bytecode
[id
++] = S_SQ_CF_WORD0_ADDR(cf
->cf_addr
>> 1);
1606 bc
->bytecode
[id
++] = S_SQ_CF_WORD1_CF_INST(opcode
) |
1607 S_SQ_CF_WORD1_BARRIER(1) |
1608 S_SQ_CF_WORD1_COND(cf
->cond
) |
1609 S_SQ_CF_WORD1_POP_COUNT(cf
->pop_count
) |
1610 S_SQ_CF_WORD1_END_OF_PROGRAM(cf
->end_of_program
);
1615 int r600_bytecode_build(struct r600_bytecode
*bc
)
1617 struct r600_bytecode_cf
*cf
;
1618 struct r600_bytecode_alu
*alu
;
1619 struct r600_bytecode_vtx
*vtx
;
1620 struct r600_bytecode_tex
*tex
;
1621 uint32_t literal
[4];
1626 if (!bc
->nstack
) // If not 0, Stack_size already provided by llvm
1627 bc
->nstack
= bc
->stack
.max_entries
;
1629 if (bc
->type
== TGSI_PROCESSOR_VERTEX
&& !bc
->nstack
) {
1633 /* first path compute addr of each CF block */
1634 /* addr start after all the CF instructions */
1635 addr
= bc
->cf_last
->id
+ 2;
1636 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
1637 if (r600_isa_cf(cf
->op
)->flags
& CF_FETCH
) {
1639 addr
&= 0xFFFFFFFCUL
;
1643 bc
->ndw
= cf
->addr
+ cf
->ndw
;
1646 bc
->bytecode
= calloc(4, bc
->ndw
);
1647 if (bc
->bytecode
== NULL
)
1649 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
1650 const struct cf_op_info
*cfop
= r600_isa_cf(cf
->op
);
1652 if (bc
->chip_class
>= EVERGREEN
)
1653 r
= eg_bytecode_cf_build(bc
, cf
);
1655 r
= r600_bytecode_cf_build(bc
, cf
);
1658 if (cfop
->flags
& CF_ALU
) {
1660 memset(literal
, 0, sizeof(literal
));
1661 LIST_FOR_EACH_ENTRY(alu
, &cf
->alu
, list
) {
1662 r
= r600_bytecode_alu_nliterals(bc
, alu
, literal
, &nliteral
);
1665 r600_bytecode_alu_adjust_literals(bc
, alu
, literal
, nliteral
);
1666 r600_bytecode_assign_kcache_banks(bc
, alu
, cf
->kcache
);
1668 switch(bc
->chip_class
) {
1670 r
= r600_bytecode_alu_build(bc
, alu
, addr
);
1673 case EVERGREEN
: /* eg alu is same encoding as r700 */
1675 r
= r700_bytecode_alu_build(bc
, alu
, addr
);
1678 R600_ERR("unknown chip class %d.\n", bc
->chip_class
);
1685 for (i
= 0; i
< align(nliteral
, 2); ++i
) {
1686 bc
->bytecode
[addr
++] = literal
[i
];
1689 memset(literal
, 0, sizeof(literal
));
1692 } else if (cf
->op
== CF_OP_VTX
) {
1693 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
1694 r
= r600_bytecode_vtx_build(bc
, vtx
, addr
);
1699 } else if (cf
->op
== CF_OP_TEX
) {
1700 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
1701 assert(bc
->chip_class
>= EVERGREEN
);
1702 r
= r600_bytecode_vtx_build(bc
, vtx
, addr
);
1707 LIST_FOR_EACH_ENTRY(tex
, &cf
->tex
, list
) {
1708 r
= r600_bytecode_tex_build(bc
, tex
, addr
);
1718 void r600_bytecode_clear(struct r600_bytecode
*bc
)
1720 struct r600_bytecode_cf
*cf
= NULL
, *next_cf
;
1723 bc
->bytecode
= NULL
;
1725 LIST_FOR_EACH_ENTRY_SAFE(cf
, next_cf
, &bc
->cf
, list
) {
1726 struct r600_bytecode_alu
*alu
= NULL
, *next_alu
;
1727 struct r600_bytecode_tex
*tex
= NULL
, *next_tex
;
1728 struct r600_bytecode_tex
*vtx
= NULL
, *next_vtx
;
1730 LIST_FOR_EACH_ENTRY_SAFE(alu
, next_alu
, &cf
->alu
, list
) {
1734 LIST_INITHEAD(&cf
->alu
);
1736 LIST_FOR_EACH_ENTRY_SAFE(tex
, next_tex
, &cf
->tex
, list
) {
1740 LIST_INITHEAD(&cf
->tex
);
1742 LIST_FOR_EACH_ENTRY_SAFE(vtx
, next_vtx
, &cf
->vtx
, list
) {
1746 LIST_INITHEAD(&cf
->vtx
);
1751 LIST_INITHEAD(&cf
->list
);
1754 static int print_swizzle(unsigned swz
)
1756 const char * swzchars
= "xyzw01?_";
1757 assert(swz
<8 && swz
!= 6);
1758 return fprintf(stderr
, "%c", swzchars
[swz
]);
1761 static int print_sel(unsigned sel
, unsigned rel
, unsigned index_mode
,
1762 unsigned need_brackets
)
1765 if (rel
&& index_mode
>= 5 && sel
< 128)
1766 o
+= fprintf(stderr
, "G");
1767 if (rel
|| need_brackets
) {
1768 o
+= fprintf(stderr
, "[");
1770 o
+= fprintf(stderr
, "%d", sel
);
1772 if (index_mode
== 0 || index_mode
== 6)
1773 o
+= fprintf(stderr
, "+AR");
1774 else if (index_mode
== 4)
1775 o
+= fprintf(stderr
, "+AL");
1777 if (rel
|| need_brackets
) {
1778 o
+= fprintf(stderr
, "]");
1783 static int print_dst(struct r600_bytecode_alu
*alu
)
1786 unsigned sel
= alu
->dst
.sel
;
1787 char reg_char
= 'R';
1788 if (sel
> 128 - 4) { /* clause temporary gpr */
1793 if (alu
->dst
.write
|| alu
->is_op3
) {
1794 o
+= fprintf(stderr
, "%c", reg_char
);
1795 o
+= print_sel(alu
->dst
.sel
, alu
->dst
.rel
, alu
->index_mode
, 0);
1797 o
+= fprintf(stderr
, "__");
1799 o
+= fprintf(stderr
, ".");
1800 o
+= print_swizzle(alu
->dst
.chan
);
1804 static int print_src(struct r600_bytecode_alu
*alu
, unsigned idx
)
1807 struct r600_bytecode_alu_src
*src
= &alu
->src
[idx
];
1808 unsigned sel
= src
->sel
, need_sel
= 1, need_chan
= 1, need_brackets
= 0;
1811 o
+= fprintf(stderr
,"-");
1813 o
+= fprintf(stderr
,"|");
1815 if (sel
< 128 - 4) {
1816 o
+= fprintf(stderr
, "R");
1817 } else if (sel
< 128) {
1818 o
+= fprintf(stderr
, "T");
1820 } else if (sel
< 160) {
1821 o
+= fprintf(stderr
, "KC0");
1824 } else if (sel
< 192) {
1825 o
+= fprintf(stderr
, "KC1");
1828 } else if (sel
>= 512) {
1829 o
+= fprintf(stderr
, "C%d", src
->kc_bank
);
1832 } else if (sel
>= 448) {
1833 o
+= fprintf(stderr
, "Param");
1836 } else if (sel
>= 288) {
1837 o
+= fprintf(stderr
, "KC3");
1840 } else if (sel
>= 256) {
1841 o
+= fprintf(stderr
, "KC2");
1848 case V_SQ_ALU_SRC_PS
:
1849 o
+= fprintf(stderr
, "PS");
1851 case V_SQ_ALU_SRC_PV
:
1852 o
+= fprintf(stderr
, "PV");
1855 case V_SQ_ALU_SRC_LITERAL
:
1856 o
+= fprintf(stderr
, "[0x%08X %f]", src
->value
, *(float*)&src
->value
);
1858 case V_SQ_ALU_SRC_0_5
:
1859 o
+= fprintf(stderr
, "0.5");
1861 case V_SQ_ALU_SRC_M_1_INT
:
1862 o
+= fprintf(stderr
, "-1");
1864 case V_SQ_ALU_SRC_1_INT
:
1865 o
+= fprintf(stderr
, "1");
1867 case V_SQ_ALU_SRC_1
:
1868 o
+= fprintf(stderr
, "1.0");
1870 case V_SQ_ALU_SRC_0
:
1871 o
+= fprintf(stderr
, "0");
1874 o
+= fprintf(stderr
, "??IMM_%d", sel
);
1880 o
+= print_sel(sel
, src
->rel
, alu
->index_mode
, need_brackets
);
1883 o
+= fprintf(stderr
, ".");
1884 o
+= print_swizzle(src
->chan
);
1888 o
+= fprintf(stderr
,"|");
1893 static int print_indent(int p
, int c
)
1897 o
+= fprintf(stderr
, " ");
1901 void r600_bytecode_disasm(struct r600_bytecode
*bc
)
1903 const char *index_mode
[] = {"CF_INDEX_NONE", "CF_INDEX_0", "CF_INDEX_1"};
1904 static int index
= 0;
1905 struct r600_bytecode_cf
*cf
= NULL
;
1906 struct r600_bytecode_alu
*alu
= NULL
;
1907 struct r600_bytecode_vtx
*vtx
= NULL
;
1908 struct r600_bytecode_tex
*tex
= NULL
;
1910 unsigned i
, id
, ngr
= 0, last
;
1911 uint32_t literal
[4];
1915 switch (bc
->chip_class
) {
1930 fprintf(stderr
, "bytecode %d dw -- %d gprs -- %d nstack -------------\n",
1931 bc
->ndw
, bc
->ngpr
, bc
->nstack
);
1932 fprintf(stderr
, "shader %d -- %c\n", index
++, chip
);
1934 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
1936 if (cf
->op
== CF_NATIVE
) {
1937 fprintf(stderr
, "%04d %08X %08X CF_NATIVE\n", id
, bc
->bytecode
[id
],
1938 bc
->bytecode
[id
+ 1]);
1940 const struct cf_op_info
*cfop
= r600_isa_cf(cf
->op
);
1941 if (cfop
->flags
& CF_ALU
) {
1942 if (cf
->eg_alu_extended
) {
1943 fprintf(stderr
, "%04d %08X %08X %s\n", id
, bc
->bytecode
[id
],
1944 bc
->bytecode
[id
+ 1], "ALU_EXT");
1947 fprintf(stderr
, "%04d %08X %08X %s ", id
, bc
->bytecode
[id
],
1948 bc
->bytecode
[id
+ 1], cfop
->name
);
1949 fprintf(stderr
, "%d @%d ", cf
->ndw
/ 2, cf
->addr
);
1950 for (i
= 0; i
< 4; ++i
) {
1951 if (cf
->kcache
[i
].mode
) {
1952 int c_start
= (cf
->kcache
[i
].addr
<< 4);
1953 int c_end
= c_start
+ (cf
->kcache
[i
].mode
<< 4);
1954 fprintf(stderr
, "KC%d[CB%d:%d-%d%s%s] ",
1955 i
, cf
->kcache
[i
].bank
, c_start
, c_end
,
1956 cf
->kcache
[i
].index_mode
? " " : "",
1957 cf
->kcache
[i
].index_mode
? index_mode
[cf
->kcache
[i
].index_mode
] : "");
1960 fprintf(stderr
, "\n");
1961 } else if (cfop
->flags
& CF_FETCH
) {
1962 fprintf(stderr
, "%04d %08X %08X %s ", id
, bc
->bytecode
[id
],
1963 bc
->bytecode
[id
+ 1], cfop
->name
);
1964 fprintf(stderr
, "%d @%d ", cf
->ndw
/ 4, cf
->addr
);
1965 fprintf(stderr
, "\n");
1966 } else if (cfop
->flags
& CF_EXP
) {
1968 const char *exp_type
[] = {"PIXEL", "POS ", "PARAM"};
1969 o
+= fprintf(stderr
, "%04d %08X %08X %s ", id
, bc
->bytecode
[id
],
1970 bc
->bytecode
[id
+ 1], cfop
->name
);
1971 o
+= print_indent(o
, 43);
1972 o
+= fprintf(stderr
, "%s ", exp_type
[cf
->output
.type
]);
1973 if (cf
->output
.burst_count
> 1) {
1974 o
+= fprintf(stderr
, "%d-%d ", cf
->output
.array_base
,
1975 cf
->output
.array_base
+ cf
->output
.burst_count
- 1);
1977 o
+= print_indent(o
, 55);
1978 o
+= fprintf(stderr
, "R%d-%d.", cf
->output
.gpr
,
1979 cf
->output
.gpr
+ cf
->output
.burst_count
- 1);
1981 o
+= fprintf(stderr
, "%d ", cf
->output
.array_base
);
1982 o
+= print_indent(o
, 55);
1983 o
+= fprintf(stderr
, "R%d.", cf
->output
.gpr
);
1986 o
+= print_swizzle(cf
->output
.swizzle_x
);
1987 o
+= print_swizzle(cf
->output
.swizzle_y
);
1988 o
+= print_swizzle(cf
->output
.swizzle_z
);
1989 o
+= print_swizzle(cf
->output
.swizzle_w
);
1991 print_indent(o
, 67);
1993 fprintf(stderr
, " ES:%X ", cf
->output
.elem_size
);
1995 fprintf(stderr
, "NO_BARRIER ");
1996 if (cf
->end_of_program
)
1997 fprintf(stderr
, "EOP ");
1998 fprintf(stderr
, "\n");
1999 } else if (r600_isa_cf(cf
->op
)->flags
& CF_MEM
) {
2001 const char *exp_type
[] = {"WRITE", "WRITE_IND", "WRITE_ACK",
2003 o
+= fprintf(stderr
, "%04d %08X %08X %s ", id
,
2004 bc
->bytecode
[id
], bc
->bytecode
[id
+ 1], cfop
->name
);
2005 o
+= print_indent(o
, 43);
2006 o
+= fprintf(stderr
, "%s ", exp_type
[cf
->output
.type
]);
2007 if (cf
->output
.burst_count
> 1) {
2008 o
+= fprintf(stderr
, "%d-%d ", cf
->output
.array_base
,
2009 cf
->output
.array_base
+ cf
->output
.burst_count
- 1);
2010 o
+= print_indent(o
, 55);
2011 o
+= fprintf(stderr
, "R%d-%d.", cf
->output
.gpr
,
2012 cf
->output
.gpr
+ cf
->output
.burst_count
- 1);
2014 o
+= fprintf(stderr
, "%d ", cf
->output
.array_base
);
2015 o
+= print_indent(o
, 55);
2016 o
+= fprintf(stderr
, "R%d.", cf
->output
.gpr
);
2018 for (i
= 0; i
< 4; ++i
) {
2019 if (cf
->output
.comp_mask
& (1 << i
))
2020 o
+= print_swizzle(i
);
2022 o
+= print_swizzle(7);
2025 if (cf
->output
.type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_WRITE_IND
)
2026 o
+= fprintf(stderr
, " R%d", cf
->output
.index_gpr
);
2028 o
+= print_indent(o
, 67);
2030 fprintf(stderr
, " ES:%i ", cf
->output
.elem_size
);
2031 if (cf
->output
.array_size
!= 0xFFF)
2032 fprintf(stderr
, "AS:%i ", cf
->output
.array_size
);
2034 fprintf(stderr
, "NO_BARRIER ");
2035 if (cf
->end_of_program
)
2036 fprintf(stderr
, "EOP ");
2037 fprintf(stderr
, "\n");
2039 fprintf(stderr
, "%04d %08X %08X %s ", id
, bc
->bytecode
[id
],
2040 bc
->bytecode
[id
+ 1], cfop
->name
);
2041 fprintf(stderr
, "@%d ", cf
->cf_addr
);
2043 fprintf(stderr
, "CND:%X ", cf
->cond
);
2045 fprintf(stderr
, "POP:%X ", cf
->pop_count
);
2046 if (cf
->count
&& (cfop
->flags
& CF_EMIT
))
2047 fprintf(stderr
, "STREAM%d ", cf
->count
);
2048 if (cf
->end_of_program
)
2049 fprintf(stderr
, "EOP ");
2050 fprintf(stderr
, "\n");
2057 LIST_FOR_EACH_ENTRY(alu
, &cf
->alu
, list
) {
2058 const char *omod_str
[] = {"","*2","*4","/2"};
2059 const struct alu_op_info
*aop
= r600_isa_alu(alu
->op
);
2062 r600_bytecode_alu_nliterals(bc
, alu
, literal
, &nliteral
);
2063 o
+= fprintf(stderr
, " %04d %08X %08X ", id
, bc
->bytecode
[id
], bc
->bytecode
[id
+1]);
2065 o
+= fprintf(stderr
, "%4d ", ++ngr
);
2067 o
+= fprintf(stderr
, " ");
2068 o
+= fprintf(stderr
, "%c%c %c ", alu
->execute_mask
? 'M':' ',
2069 alu
->update_pred
? 'P':' ',
2070 alu
->pred_sel
? alu
->pred_sel
==2 ? '0':'1':' ');
2072 o
+= fprintf(stderr
, "%s%s%s ", aop
->name
,
2073 omod_str
[alu
->omod
], alu
->dst
.clamp
? "_sat":"");
2075 o
+= print_indent(o
,60);
2076 o
+= print_dst(alu
);
2077 for (i
= 0; i
< aop
->src_count
; ++i
) {
2078 o
+= fprintf(stderr
, i
== 0 ? ", ": ", ");
2079 o
+= print_src(alu
, i
);
2082 if (alu
->bank_swizzle
) {
2083 o
+= print_indent(o
,75);
2084 o
+= fprintf(stderr
, " BS:%d", alu
->bank_swizzle
);
2087 fprintf(stderr
, "\n");
2091 for (i
= 0; i
< nliteral
; i
++, id
++) {
2092 float *f
= (float*)(bc
->bytecode
+ id
);
2093 o
= fprintf(stderr
, " %04d %08X", id
, bc
->bytecode
[id
]);
2094 print_indent(o
, 60);
2095 fprintf(stderr
, " %f (%d)\n", *f
, *(bc
->bytecode
+ id
));
2103 LIST_FOR_EACH_ENTRY(tex
, &cf
->tex
, list
) {
2105 o
+= fprintf(stderr
, " %04d %08X %08X %08X ", id
, bc
->bytecode
[id
],
2106 bc
->bytecode
[id
+ 1], bc
->bytecode
[id
+ 2]);
2108 o
+= fprintf(stderr
, "%s ", r600_isa_fetch(tex
->op
)->name
);
2110 o
+= print_indent(o
, 50);
2112 o
+= fprintf(stderr
, "R%d.", tex
->dst_gpr
);
2113 o
+= print_swizzle(tex
->dst_sel_x
);
2114 o
+= print_swizzle(tex
->dst_sel_y
);
2115 o
+= print_swizzle(tex
->dst_sel_z
);
2116 o
+= print_swizzle(tex
->dst_sel_w
);
2118 o
+= fprintf(stderr
, ", R%d.", tex
->src_gpr
);
2119 o
+= print_swizzle(tex
->src_sel_x
);
2120 o
+= print_swizzle(tex
->src_sel_y
);
2121 o
+= print_swizzle(tex
->src_sel_z
);
2122 o
+= print_swizzle(tex
->src_sel_w
);
2124 o
+= fprintf(stderr
, ", RID:%d", tex
->resource_id
);
2125 o
+= fprintf(stderr
, ", SID:%d ", tex
->sampler_id
);
2127 if (tex
->sampler_index_mode
)
2128 fprintf(stderr
, "SQ_%s ", index_mode
[tex
->sampler_index_mode
]);
2131 fprintf(stderr
, "LB:%d ", tex
->lod_bias
);
2133 fprintf(stderr
, "CT:%c%c%c%c ",
2134 tex
->coord_type_x
? 'N' : 'U',
2135 tex
->coord_type_y
? 'N' : 'U',
2136 tex
->coord_type_z
? 'N' : 'U',
2137 tex
->coord_type_w
? 'N' : 'U');
2140 fprintf(stderr
, "OX:%d ", tex
->offset_x
);
2142 fprintf(stderr
, "OY:%d ", tex
->offset_y
);
2144 fprintf(stderr
, "OZ:%d ", tex
->offset_z
);
2147 fprintf(stderr
, "\n");
2150 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
2152 const char * fetch_type
[] = {"VERTEX", "INSTANCE", ""};
2153 o
+= fprintf(stderr
, " %04d %08X %08X %08X ", id
, bc
->bytecode
[id
],
2154 bc
->bytecode
[id
+ 1], bc
->bytecode
[id
+ 2]);
2156 o
+= fprintf(stderr
, "%s ", r600_isa_fetch(vtx
->op
)->name
);
2158 o
+= print_indent(o
, 50);
2160 o
+= fprintf(stderr
, "R%d.", vtx
->dst_gpr
);
2161 o
+= print_swizzle(vtx
->dst_sel_x
);
2162 o
+= print_swizzle(vtx
->dst_sel_y
);
2163 o
+= print_swizzle(vtx
->dst_sel_z
);
2164 o
+= print_swizzle(vtx
->dst_sel_w
);
2166 o
+= fprintf(stderr
, ", R%d.", vtx
->src_gpr
);
2167 o
+= print_swizzle(vtx
->src_sel_x
);
2170 fprintf(stderr
, " +%db", vtx
->offset
);
2172 o
+= print_indent(o
, 55);
2174 fprintf(stderr
, ", RID:%d ", vtx
->buffer_id
);
2176 fprintf(stderr
, "%s ", fetch_type
[vtx
->fetch_type
]);
2178 if (bc
->chip_class
< CAYMAN
&& vtx
->mega_fetch_count
)
2179 fprintf(stderr
, "MFC:%d ", vtx
->mega_fetch_count
);
2181 if (bc
->chip_class
>= EVERGREEN
&& vtx
->buffer_index_mode
)
2182 fprintf(stderr
, "SQ_%s ", index_mode
[vtx
->buffer_index_mode
]);
2184 fprintf(stderr
, "UCF:%d ", vtx
->use_const_fields
);
2185 fprintf(stderr
, "FMT(DTA:%d ", vtx
->data_format
);
2186 fprintf(stderr
, "NUM:%d ", vtx
->num_format_all
);
2187 fprintf(stderr
, "COMP:%d ", vtx
->format_comp_all
);
2188 fprintf(stderr
, "MODE:%d)\n", vtx
->srf_mode_all
);
2194 fprintf(stderr
, "--------------------------------------\n");
2197 void r600_vertex_data_type(enum pipe_format pformat
,
2199 unsigned *num_format
, unsigned *format_comp
, unsigned *endian
)
2201 const struct util_format_description
*desc
;
2207 *endian
= ENDIAN_NONE
;
2209 if (pformat
== PIPE_FORMAT_R11G11B10_FLOAT
) {
2210 *format
= FMT_10_11_11_FLOAT
;
2211 *endian
= r600_endian_swap(32);
2215 desc
= util_format_description(pformat
);
2216 if (desc
->layout
!= UTIL_FORMAT_LAYOUT_PLAIN
) {
2220 /* Find the first non-VOID channel. */
2221 for (i
= 0; i
< 4; i
++) {
2222 if (desc
->channel
[i
].type
!= UTIL_FORMAT_TYPE_VOID
) {
2227 *endian
= r600_endian_swap(desc
->channel
[i
].size
);
2229 switch (desc
->channel
[i
].type
) {
2230 /* Half-floats, floats, ints */
2231 case UTIL_FORMAT_TYPE_FLOAT
:
2232 switch (desc
->channel
[i
].size
) {
2234 switch (desc
->nr_channels
) {
2236 *format
= FMT_16_FLOAT
;
2239 *format
= FMT_16_16_FLOAT
;
2243 *format
= FMT_16_16_16_16_FLOAT
;
2248 switch (desc
->nr_channels
) {
2250 *format
= FMT_32_FLOAT
;
2253 *format
= FMT_32_32_FLOAT
;
2256 *format
= FMT_32_32_32_FLOAT
;
2259 *format
= FMT_32_32_32_32_FLOAT
;
2268 case UTIL_FORMAT_TYPE_UNSIGNED
:
2270 case UTIL_FORMAT_TYPE_SIGNED
:
2271 switch (desc
->channel
[i
].size
) {
2273 switch (desc
->nr_channels
) {
2282 *format
= FMT_8_8_8_8
;
2287 if (desc
->nr_channels
!= 4)
2290 *format
= FMT_2_10_10_10
;
2293 switch (desc
->nr_channels
) {
2298 *format
= FMT_16_16
;
2302 *format
= FMT_16_16_16_16
;
2307 switch (desc
->nr_channels
) {
2312 *format
= FMT_32_32
;
2315 *format
= FMT_32_32_32
;
2318 *format
= FMT_32_32_32_32
;
2330 if (desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_SIGNED
) {
2335 if (desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_UNSIGNED
||
2336 desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_SIGNED
) {
2337 if (!desc
->channel
[i
].normalized
) {
2338 if (desc
->channel
[i
].pure_integer
)
2346 R600_ERR("unsupported vertex format %s\n", util_format_name(pformat
));
2349 void *r600_create_vertex_fetch_shader(struct pipe_context
*ctx
,
2351 const struct pipe_vertex_element
*elements
)
2353 struct r600_context
*rctx
= (struct r600_context
*)ctx
;
2354 struct r600_bytecode bc
;
2355 struct r600_bytecode_vtx vtx
;
2356 const struct util_format_description
*desc
;
2357 unsigned fetch_resource_start
= rctx
->b
.chip_class
>= EVERGREEN
? 0 : 160;
2358 unsigned format
, num_format
, format_comp
, endian
;
2360 int i
, j
, r
, fs_size
;
2361 struct r600_fetch_shader
*shader
;
2362 unsigned no_sb
= rctx
->screen
->b
.debug_flags
& DBG_NO_SB
;
2363 unsigned sb_disasm
= !no_sb
|| (rctx
->screen
->b
.debug_flags
& DBG_SB_DISASM
);
2367 memset(&bc
, 0, sizeof(bc
));
2368 r600_bytecode_init(&bc
, rctx
->b
.chip_class
, rctx
->b
.family
,
2369 rctx
->screen
->has_compressed_msaa_texturing
);
2373 for (i
= 0; i
< count
; i
++) {
2374 if (elements
[i
].instance_divisor
> 1) {
2375 if (rctx
->b
.chip_class
== CAYMAN
) {
2376 for (j
= 0; j
< 4; j
++) {
2377 struct r600_bytecode_alu alu
;
2378 memset(&alu
, 0, sizeof(alu
));
2379 alu
.op
= ALU_OP2_MULHI_UINT
;
2381 alu
.src
[0].chan
= 3;
2382 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
2383 alu
.src
[1].value
= (1ll << 32) / elements
[i
].instance_divisor
+ 1;
2384 alu
.dst
.sel
= i
+ 1;
2386 alu
.dst
.write
= j
== 3;
2388 if ((r
= r600_bytecode_add_alu(&bc
, &alu
))) {
2389 r600_bytecode_clear(&bc
);
2394 struct r600_bytecode_alu alu
;
2395 memset(&alu
, 0, sizeof(alu
));
2396 alu
.op
= ALU_OP2_MULHI_UINT
;
2398 alu
.src
[0].chan
= 3;
2399 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
2400 alu
.src
[1].value
= (1ll << 32) / elements
[i
].instance_divisor
+ 1;
2401 alu
.dst
.sel
= i
+ 1;
2405 if ((r
= r600_bytecode_add_alu(&bc
, &alu
))) {
2406 r600_bytecode_clear(&bc
);
2413 for (i
= 0; i
< count
; i
++) {
2414 r600_vertex_data_type(elements
[i
].src_format
,
2415 &format
, &num_format
, &format_comp
, &endian
);
2417 desc
= util_format_description(elements
[i
].src_format
);
2419 r600_bytecode_clear(&bc
);
2420 R600_ERR("unknown format %d\n", elements
[i
].src_format
);
2424 if (elements
[i
].src_offset
> 65535) {
2425 r600_bytecode_clear(&bc
);
2426 R600_ERR("too big src_offset: %u\n", elements
[i
].src_offset
);
2430 memset(&vtx
, 0, sizeof(vtx
));
2431 vtx
.buffer_id
= elements
[i
].vertex_buffer_index
+ fetch_resource_start
;
2432 vtx
.fetch_type
= elements
[i
].instance_divisor
? SQ_VTX_FETCH_INSTANCE_DATA
: SQ_VTX_FETCH_VERTEX_DATA
;
2433 vtx
.src_gpr
= elements
[i
].instance_divisor
> 1 ? i
+ 1 : 0;
2434 vtx
.src_sel_x
= elements
[i
].instance_divisor
? 3 : 0;
2435 vtx
.mega_fetch_count
= 0x1F;
2436 vtx
.dst_gpr
= i
+ 1;
2437 vtx
.dst_sel_x
= desc
->swizzle
[0];
2438 vtx
.dst_sel_y
= desc
->swizzle
[1];
2439 vtx
.dst_sel_z
= desc
->swizzle
[2];
2440 vtx
.dst_sel_w
= desc
->swizzle
[3];
2441 vtx
.data_format
= format
;
2442 vtx
.num_format_all
= num_format
;
2443 vtx
.format_comp_all
= format_comp
;
2444 vtx
.offset
= elements
[i
].src_offset
;
2445 vtx
.endian
= endian
;
2447 if ((r
= r600_bytecode_add_vtx(&bc
, &vtx
))) {
2448 r600_bytecode_clear(&bc
);
2453 r600_bytecode_add_cfinst(&bc
, CF_OP_RET
);
2455 if ((r
= r600_bytecode_build(&bc
))) {
2456 r600_bytecode_clear(&bc
);
2460 if (rctx
->screen
->b
.debug_flags
& DBG_FS
) {
2461 fprintf(stderr
, "--------------------------------------------------------------\n");
2462 fprintf(stderr
, "Vertex elements state:\n");
2463 for (i
= 0; i
< count
; i
++) {
2464 fprintf(stderr
, " ");
2465 util_dump_vertex_element(stderr
, elements
+i
);
2466 fprintf(stderr
, "\n");
2470 r600_bytecode_disasm(&bc
);
2472 fprintf(stderr
, "______________________________________________________________\n");
2474 r600_sb_bytecode_process(rctx
, &bc
, NULL
, 1 /*dump*/, 0 /*optimize*/);
2480 /* Allocate the CSO. */
2481 shader
= CALLOC_STRUCT(r600_fetch_shader
);
2483 r600_bytecode_clear(&bc
);
2487 u_suballocator_alloc(rctx
->allocator_fetch_shader
, fs_size
, &shader
->offset
,
2488 (struct pipe_resource
**)&shader
->buffer
);
2489 if (!shader
->buffer
) {
2490 r600_bytecode_clear(&bc
);
2495 bytecode
= r600_buffer_map_sync_with_rings(&rctx
->b
, shader
->buffer
, PIPE_TRANSFER_WRITE
| PIPE_TRANSFER_UNSYNCHRONIZED
);
2496 bytecode
+= shader
->offset
/ 4;
2498 if (R600_BIG_ENDIAN
) {
2499 for (i
= 0; i
< fs_size
/ 4; ++i
) {
2500 bytecode
[i
] = util_cpu_to_le32(bc
.bytecode
[i
]);
2503 memcpy(bytecode
, bc
.bytecode
, fs_size
);
2505 rctx
->b
.ws
->buffer_unmap(shader
->buffer
->cs_buf
);
2507 r600_bytecode_clear(&bc
);
2511 void r600_bytecode_alu_read(struct r600_bytecode
*bc
,
2512 struct r600_bytecode_alu
*alu
, uint32_t word0
, uint32_t word1
)
2515 alu
->src
[0].sel
= G_SQ_ALU_WORD0_SRC0_SEL(word0
);
2516 alu
->src
[0].rel
= G_SQ_ALU_WORD0_SRC0_REL(word0
);
2517 alu
->src
[0].chan
= G_SQ_ALU_WORD0_SRC0_CHAN(word0
);
2518 alu
->src
[0].neg
= G_SQ_ALU_WORD0_SRC0_NEG(word0
);
2519 alu
->src
[1].sel
= G_SQ_ALU_WORD0_SRC1_SEL(word0
);
2520 alu
->src
[1].rel
= G_SQ_ALU_WORD0_SRC1_REL(word0
);
2521 alu
->src
[1].chan
= G_SQ_ALU_WORD0_SRC1_CHAN(word0
);
2522 alu
->src
[1].neg
= G_SQ_ALU_WORD0_SRC1_NEG(word0
);
2523 alu
->index_mode
= G_SQ_ALU_WORD0_INDEX_MODE(word0
);
2524 alu
->pred_sel
= G_SQ_ALU_WORD0_PRED_SEL(word0
);
2525 alu
->last
= G_SQ_ALU_WORD0_LAST(word0
);
2528 alu
->bank_swizzle
= G_SQ_ALU_WORD1_BANK_SWIZZLE(word1
);
2529 if (alu
->bank_swizzle
)
2530 alu
->bank_swizzle_force
= alu
->bank_swizzle
;
2531 alu
->dst
.sel
= G_SQ_ALU_WORD1_DST_GPR(word1
);
2532 alu
->dst
.rel
= G_SQ_ALU_WORD1_DST_REL(word1
);
2533 alu
->dst
.chan
= G_SQ_ALU_WORD1_DST_CHAN(word1
);
2534 alu
->dst
.clamp
= G_SQ_ALU_WORD1_CLAMP(word1
);
2535 if (G_SQ_ALU_WORD1_ENCODING(word1
)) /*ALU_DWORD1_OP3*/
2538 alu
->src
[2].sel
= G_SQ_ALU_WORD1_OP3_SRC2_SEL(word1
);
2539 alu
->src
[2].rel
= G_SQ_ALU_WORD1_OP3_SRC2_REL(word1
);
2540 alu
->src
[2].chan
= G_SQ_ALU_WORD1_OP3_SRC2_CHAN(word1
);
2541 alu
->src
[2].neg
= G_SQ_ALU_WORD1_OP3_SRC2_NEG(word1
);
2542 alu
->op
= r600_isa_alu_by_opcode(bc
->isa
,
2543 G_SQ_ALU_WORD1_OP3_ALU_INST(word1
), /* is_op3 = */ 1);
2546 else /*ALU_DWORD1_OP2*/
2548 alu
->src
[0].abs
= G_SQ_ALU_WORD1_OP2_SRC0_ABS(word1
);
2549 alu
->src
[1].abs
= G_SQ_ALU_WORD1_OP2_SRC1_ABS(word1
);
2550 alu
->op
= r600_isa_alu_by_opcode(bc
->isa
,
2551 G_SQ_ALU_WORD1_OP2_ALU_INST(word1
), /* is_op3 = */ 0);
2552 alu
->omod
= G_SQ_ALU_WORD1_OP2_OMOD(word1
);
2553 alu
->dst
.write
= G_SQ_ALU_WORD1_OP2_WRITE_MASK(word1
);
2554 alu
->update_pred
= G_SQ_ALU_WORD1_OP2_UPDATE_PRED(word1
);
2556 G_SQ_ALU_WORD1_OP2_UPDATE_EXECUTE_MASK(word1
);
2561 void r600_bytecode_export_read(struct r600_bytecode
*bc
,
2562 struct r600_bytecode_output
*output
, uint32_t word0
, uint32_t word1
)
2564 output
->array_base
= G_SQ_CF_ALLOC_EXPORT_WORD0_ARRAY_BASE(word0
);
2565 output
->type
= G_SQ_CF_ALLOC_EXPORT_WORD0_TYPE(word0
);
2566 output
->gpr
= G_SQ_CF_ALLOC_EXPORT_WORD0_RW_GPR(word0
);
2567 output
->elem_size
= G_SQ_CF_ALLOC_EXPORT_WORD0_ELEM_SIZE(word0
);
2569 output
->swizzle_x
= G_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_X(word1
);
2570 output
->swizzle_y
= G_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Y(word1
);
2571 output
->swizzle_z
= G_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Z(word1
);
2572 output
->swizzle_w
= G_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_W(word1
);
2573 output
->burst_count
= G_SQ_CF_ALLOC_EXPORT_WORD1_BURST_COUNT(word1
);
2574 output
->end_of_program
= G_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM(word1
);
2575 output
->op
= r600_isa_cf_by_opcode(bc
->isa
,
2576 G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(word1
), 0);
2577 output
->barrier
= G_SQ_CF_ALLOC_EXPORT_WORD1_BARRIER(word1
);
2578 output
->array_size
= G_SQ_CF_ALLOC_EXPORT_WORD1_BUF_ARRAY_SIZE(word1
);
2579 output
->comp_mask
= G_SQ_CF_ALLOC_EXPORT_WORD1_BUF_COMP_MASK(word1
);