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_llvm.h"
25 #include "r600_formats.h"
26 #include "r600_opcodes.h"
29 #include "pipe/p_shader_tokens.h"
30 #include "tgsi/tgsi_info.h"
31 #include "tgsi/tgsi_parse.h"
32 #include "tgsi/tgsi_scan.h"
33 #include "tgsi/tgsi_dump.h"
34 #include "util/u_memory.h"
40 Why CAYMAN got loops for lots of instructions is explained here.
42 -These 8xx t-slot only ops are implemented in all vector slots.
43 MUL_LIT, FLT_TO_UINT, INT_TO_FLT, UINT_TO_FLT
44 These 8xx t-slot only opcodes become vector ops, with all four
45 slots expecting the arguments on sources a and b. Result is
46 broadcast to all channels.
47 MULLO_INT, MULHI_INT, MULLO_UINT, MULHI_UINT
48 These 8xx t-slot only opcodes become vector ops in the z, y, and
50 EXP_IEEE, LOG_IEEE/CLAMPED, RECIP_IEEE/CLAMPED/FF/INT/UINT/_64/CLAMPED_64
51 RECIPSQRT_IEEE/CLAMPED/FF/_64/CLAMPED_64
54 The w slot may have an independent co-issued operation, or if the
55 result is required to be in the w slot, the opcode above may be
56 issued in the w slot as well.
57 The compiler must issue the source argument to slots z, y, and x
60 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
62 struct r600_context
*rctx
= (struct r600_context
*)ctx
;
63 struct r600_shader
*rshader
= &shader
->shader
;
68 if (shader
->bo
== NULL
) {
69 shader
->bo
= (struct r600_resource
*)
70 pipe_buffer_create(ctx
->screen
, PIPE_BIND_CUSTOM
, PIPE_USAGE_IMMUTABLE
, rshader
->bc
.ndw
* 4);
71 if (shader
->bo
== NULL
) {
74 ptr
= (uint32_t*)rctx
->ws
->buffer_map(shader
->bo
->cs_buf
, rctx
->cs
, PIPE_TRANSFER_WRITE
);
75 if (R600_BIG_ENDIAN
) {
76 for (i
= 0; i
< rshader
->bc
.ndw
; ++i
) {
77 ptr
[i
] = bswap_32(rshader
->bc
.bytecode
[i
]);
80 memcpy(ptr
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* sizeof(*ptr
));
82 rctx
->ws
->buffer_unmap(shader
->bo
->cs_buf
);
85 switch (rshader
->processor_type
) {
86 case TGSI_PROCESSOR_VERTEX
:
87 if (rctx
->chip_class
>= EVERGREEN
) {
88 evergreen_pipe_shader_vs(ctx
, shader
);
90 r600_pipe_shader_vs(ctx
, shader
);
93 case TGSI_PROCESSOR_FRAGMENT
:
94 if (rctx
->chip_class
>= EVERGREEN
) {
95 evergreen_pipe_shader_ps(ctx
, shader
);
97 r600_pipe_shader_ps(ctx
, shader
);
106 static int r600_shader_from_tgsi(struct r600_context
* rctx
, struct r600_pipe_shader
*pipeshader
);
108 int r600_pipe_shader_create(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
110 static int dump_shaders
= -1;
111 struct r600_context
*rctx
= (struct r600_context
*)ctx
;
112 struct r600_pipe_shader_selector
*sel
= shader
->selector
;
115 /* Would like some magic "get_bool_option_once" routine.
117 if (dump_shaders
== -1)
118 dump_shaders
= debug_get_bool_option("R600_DUMP_SHADERS", FALSE
);
121 fprintf(stderr
, "--------------------------------------------------------------\n");
122 tgsi_dump(sel
->tokens
, 0);
124 if (sel
->so
.num_outputs
) {
126 fprintf(stderr
, "STREAMOUT\n");
127 for (i
= 0; i
< sel
->so
.num_outputs
; i
++) {
128 unsigned mask
= ((1 << sel
->so
.output
[i
].num_components
) - 1) <<
129 sel
->so
.output
[i
].start_component
;
130 fprintf(stderr
, " %i: MEM_STREAM0_BUF%i OUT[%i].%s%s%s%s\n", i
,
131 sel
->so
.output
[i
].output_buffer
, sel
->so
.output
[i
].register_index
,
132 mask
& 1 ? "x" : "_",
133 (mask
>> 1) & 1 ? "y" : "_",
134 (mask
>> 2) & 1 ? "z" : "_",
135 (mask
>> 3) & 1 ? "w" : "_");
139 r
= r600_shader_from_tgsi(rctx
, shader
);
141 R600_ERR("translation from TGSI failed !\n");
144 r
= r600_bytecode_build(&shader
->shader
.bc
);
146 R600_ERR("building bytecode failed !\n");
150 r600_bytecode_dump(&shader
->shader
.bc
);
151 fprintf(stderr
, "______________________________________________________________\n");
153 return r600_pipe_shader(ctx
, shader
);
156 void r600_pipe_shader_destroy(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
158 pipe_resource_reference((struct pipe_resource
**)&shader
->bo
, NULL
);
159 r600_bytecode_clear(&shader
->shader
.bc
);
163 * tgsi -> r600 shader
165 struct r600_shader_tgsi_instruction
;
167 struct r600_shader_src
{
176 struct r600_shader_ctx
{
177 struct tgsi_shader_info info
;
178 struct tgsi_parse_context parse
;
179 const struct tgsi_token
*tokens
;
181 unsigned file_offset
[TGSI_FILE_COUNT
];
183 struct r600_shader_tgsi_instruction
*inst_info
;
184 struct r600_bytecode
*bc
;
185 struct r600_shader
*shader
;
186 struct r600_shader_src src
[4];
189 uint32_t max_driver_temp_used
;
190 /* needed for evergreen interpolation */
191 boolean input_centroid
;
192 boolean input_linear
;
193 boolean input_perspective
;
197 boolean clip_vertex_write
;
203 struct r600_shader_tgsi_instruction
{
204 unsigned tgsi_opcode
;
206 unsigned r600_opcode
;
207 int (*process
)(struct r600_shader_ctx
*ctx
);
210 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[], eg_shader_tgsi_instruction
[], cm_shader_tgsi_instruction
[];
211 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
212 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
);
213 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
);
214 static int tgsi_else(struct r600_shader_ctx
*ctx
);
215 static int tgsi_endif(struct r600_shader_ctx
*ctx
);
216 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
);
217 static int tgsi_endloop(struct r600_shader_ctx
*ctx
);
218 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
);
221 * bytestream -> r600 shader
223 * These functions are used to transform the output of the LLVM backend into
224 * struct r600_bytecode.
227 static void r600_bytecode_from_byte_stream(struct r600_shader_ctx
*ctx
,
228 unsigned char * bytes
, unsigned num_bytes
);
231 int r600_compute_shader_create(struct pipe_context
* ctx
,
232 LLVMModuleRef mod
, struct r600_bytecode
* bytecode
)
234 struct r600_context
*r600_ctx
= (struct r600_context
*)ctx
;
235 unsigned char * bytes
;
237 struct r600_shader_ctx shader_ctx
;
240 if (debug_get_bool_option("R600_DUMP_SHADERS", FALSE
)) {
244 r600_llvm_compile(mod
, &bytes
, &byte_count
, r600_ctx
->family
, dump
);
245 shader_ctx
.bc
= bytecode
;
246 r600_bytecode_init(shader_ctx
.bc
, r600_ctx
->chip_class
, r600_ctx
->family
);
247 shader_ctx
.bc
->type
= TGSI_PROCESSOR_COMPUTE
;
248 r600_bytecode_from_byte_stream(&shader_ctx
, bytes
, byte_count
);
249 if (shader_ctx
.bc
->chip_class
== CAYMAN
) {
250 cm_bytecode_add_cf_end(shader_ctx
.bc
);
252 r600_bytecode_build(shader_ctx
.bc
);
254 r600_bytecode_dump(shader_ctx
.bc
);
259 #endif /* HAVE_OPENCL */
261 static uint32_t i32_from_byte_stream(unsigned char * bytes
,
262 unsigned * bytes_read
)
266 for (i
= 0; i
< 4; i
++) {
267 out
|= bytes
[(*bytes_read
)++] << (8 * i
);
272 static unsigned r600_src_from_byte_stream(unsigned char * bytes
,
273 unsigned bytes_read
, struct r600_bytecode_alu
* alu
, unsigned src_idx
)
277 sel0
= bytes
[bytes_read
++];
278 sel1
= bytes
[bytes_read
++];
279 alu
->src
[src_idx
].sel
= sel0
| (sel1
<< 8);
280 alu
->src
[src_idx
].chan
= bytes
[bytes_read
++];
281 alu
->src
[src_idx
].neg
= bytes
[bytes_read
++];
282 alu
->src
[src_idx
].abs
= bytes
[bytes_read
++];
283 alu
->src
[src_idx
].rel
= bytes
[bytes_read
++];
284 alu
->src
[src_idx
].kc_bank
= bytes
[bytes_read
++];
285 for (i
= 0; i
< 4; i
++) {
286 alu
->src
[src_idx
].value
|= bytes
[bytes_read
++] << (i
* 8);
291 static unsigned r600_alu_from_byte_stream(struct r600_shader_ctx
*ctx
,
292 unsigned char * bytes
, unsigned bytes_read
)
295 unsigned inst0
, inst1
;
296 unsigned push_modifier
;
297 struct r600_bytecode_alu alu
;
298 memset(&alu
, 0, sizeof(alu
));
299 for(src_idx
= 0; src_idx
< 3; src_idx
++) {
300 bytes_read
= r600_src_from_byte_stream(bytes
, bytes_read
,
304 alu
.dst
.sel
= bytes
[bytes_read
++];
305 alu
.dst
.chan
= bytes
[bytes_read
++];
306 alu
.dst
.clamp
= bytes
[bytes_read
++];
307 alu
.dst
.write
= bytes
[bytes_read
++];
308 alu
.dst
.rel
= bytes
[bytes_read
++];
309 inst0
= bytes
[bytes_read
++];
310 inst1
= bytes
[bytes_read
++];
311 alu
.inst
= inst0
| (inst1
<< 8);
312 alu
.last
= bytes
[bytes_read
++];
313 alu
.is_op3
= bytes
[bytes_read
++];
314 push_modifier
= bytes
[bytes_read
++];
315 alu
.pred_sel
= bytes
[bytes_read
++];
316 alu
.bank_swizzle
= bytes
[bytes_read
++];
317 alu
.bank_swizzle_force
= bytes
[bytes_read
++];
318 alu
.omod
= bytes
[bytes_read
++];
319 alu
.index_mode
= bytes
[bytes_read
++];
322 if (alu
.inst
== CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
) ||
323 alu
.inst
== CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE
) ||
324 alu
.inst
== CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_INT
) ||
325 alu
.inst
== CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
)) {
328 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
335 alu
.execute_mask
= 1;
336 r600_bytecode_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
338 r600_bytecode_add_alu(ctx
->bc
, &alu
);
341 /* XXX: Handle other KILL instructions */
342 if (alu
.inst
== CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
)) {
343 ctx
->shader
->uses_kill
= 1;
344 /* XXX: This should be enforced in the LLVM backend. */
345 ctx
->bc
->force_add_cf
= 1;
350 static void llvm_if(struct r600_shader_ctx
*ctx
, struct r600_bytecode_alu
* alu
,
353 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
354 fc_pushlevel(ctx
, FC_IF
);
355 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
358 static void r600_break_from_byte_stream(struct r600_shader_ctx
*ctx
,
359 struct r600_bytecode_alu
*alu
, unsigned compare_opcode
)
361 unsigned opcode
= TGSI_OPCODE_BRK
;
362 if (ctx
->bc
->chip_class
== CAYMAN
)
363 ctx
->inst_info
= &cm_shader_tgsi_instruction
[opcode
];
364 else if (ctx
->bc
->chip_class
>= EVERGREEN
)
365 ctx
->inst_info
= &eg_shader_tgsi_instruction
[opcode
];
367 ctx
->inst_info
= &r600_shader_tgsi_instruction
[opcode
];
368 llvm_if(ctx
, alu
, compare_opcode
);
369 tgsi_loop_brk_cont(ctx
);
373 static unsigned r600_fc_from_byte_stream(struct r600_shader_ctx
*ctx
,
374 unsigned char * bytes
, unsigned bytes_read
)
376 struct r600_bytecode_alu alu
;
378 memset(&alu
, 0, sizeof(alu
));
379 bytes_read
= r600_src_from_byte_stream(bytes
, bytes_read
, &alu
, 0);
380 inst
= bytes
[bytes_read
++];
384 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
386 case 1: /* FC_IF_INT */
388 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
));
390 case 2: /* FC_ELSE */
393 case 3: /* FC_ENDIF */
396 case 4: /* FC_BGNLOOP */
399 case 5: /* FC_ENDLOOP */
402 case 6: /* FC_BREAK */
403 r600_break_from_byte_stream(ctx
, &alu
,
404 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_INT
));
406 case 7: /* FC_BREAK_NZ_INT */
407 r600_break_from_byte_stream(ctx
, &alu
,
408 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
));
410 case 8: /* FC_CONTINUE */
412 unsigned opcode
= TGSI_OPCODE_CONT
;
413 if (ctx
->bc
->chip_class
== CAYMAN
) {
415 &cm_shader_tgsi_instruction
[opcode
];
416 } else if (ctx
->bc
->chip_class
>= EVERGREEN
) {
418 &eg_shader_tgsi_instruction
[opcode
];
421 &r600_shader_tgsi_instruction
[opcode
];
423 tgsi_loop_brk_cont(ctx
);
426 case 9: /* FC_BREAK_Z_INT */
427 r600_break_from_byte_stream(ctx
, &alu
,
428 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_INT
));
430 case 10: /* FC_BREAK_NZ */
431 r600_break_from_byte_stream(ctx
, &alu
,
432 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
439 static unsigned r600_tex_from_byte_stream(struct r600_shader_ctx
*ctx
,
440 unsigned char * bytes
, unsigned bytes_read
)
442 struct r600_bytecode_tex tex
;
444 tex
.inst
= bytes
[bytes_read
++];
445 tex
.resource_id
= bytes
[bytes_read
++];
446 tex
.src_gpr
= bytes
[bytes_read
++];
447 tex
.src_rel
= bytes
[bytes_read
++];
448 tex
.dst_gpr
= bytes
[bytes_read
++];
449 tex
.dst_rel
= bytes
[bytes_read
++];
450 tex
.dst_sel_x
= bytes
[bytes_read
++];
451 tex
.dst_sel_y
= bytes
[bytes_read
++];
452 tex
.dst_sel_z
= bytes
[bytes_read
++];
453 tex
.dst_sel_w
= bytes
[bytes_read
++];
454 tex
.lod_bias
= bytes
[bytes_read
++];
455 tex
.coord_type_x
= bytes
[bytes_read
++];
456 tex
.coord_type_y
= bytes
[bytes_read
++];
457 tex
.coord_type_z
= bytes
[bytes_read
++];
458 tex
.coord_type_w
= bytes
[bytes_read
++];
459 tex
.offset_x
= bytes
[bytes_read
++];
460 tex
.offset_y
= bytes
[bytes_read
++];
461 tex
.offset_z
= bytes
[bytes_read
++];
462 tex
.sampler_id
= bytes
[bytes_read
++];
463 tex
.src_sel_x
= bytes
[bytes_read
++];
464 tex
.src_sel_y
= bytes
[bytes_read
++];
465 tex
.src_sel_z
= bytes
[bytes_read
++];
466 tex
.src_sel_w
= bytes
[bytes_read
++];
468 r600_bytecode_add_tex(ctx
->bc
, &tex
);
473 static int r600_vtx_from_byte_stream(struct r600_shader_ctx
*ctx
,
474 unsigned char * bytes
, unsigned bytes_read
)
476 struct r600_bytecode_vtx vtx
;
478 uint32_t word0
= i32_from_byte_stream(bytes
, &bytes_read
);
479 uint32_t word1
= i32_from_byte_stream(bytes
, &bytes_read
);
480 uint32_t word2
= i32_from_byte_stream(bytes
, &bytes_read
);
482 memset(&vtx
, 0, sizeof(vtx
));
485 vtx
.inst
= G_SQ_VTX_WORD0_VTX_INST(word0
);
486 vtx
.fetch_type
= G_SQ_VTX_WORD0_FETCH_TYPE(word0
);
487 vtx
.buffer_id
= G_SQ_VTX_WORD0_BUFFER_ID(word0
);
488 vtx
.src_gpr
= G_SQ_VTX_WORD0_SRC_GPR(word0
);
489 vtx
.src_sel_x
= G_SQ_VTX_WORD0_SRC_SEL_X(word0
);
490 vtx
.mega_fetch_count
= G_SQ_VTX_WORD0_MEGA_FETCH_COUNT(word0
);
493 vtx
.dst_gpr
= G_SQ_VTX_WORD1_GPR_DST_GPR(word1
);
494 vtx
.dst_sel_x
= G_SQ_VTX_WORD1_DST_SEL_X(word1
);
495 vtx
.dst_sel_y
= G_SQ_VTX_WORD1_DST_SEL_Y(word1
);
496 vtx
.dst_sel_z
= G_SQ_VTX_WORD1_DST_SEL_Z(word1
);
497 vtx
.dst_sel_w
= G_SQ_VTX_WORD1_DST_SEL_W(word1
);
498 vtx
.use_const_fields
= G_SQ_VTX_WORD1_USE_CONST_FIELDS(word1
);
499 vtx
.data_format
= G_SQ_VTX_WORD1_DATA_FORMAT(word1
);
500 vtx
.num_format_all
= G_SQ_VTX_WORD1_NUM_FORMAT_ALL(word1
);
501 vtx
.format_comp_all
= G_SQ_VTX_WORD1_FORMAT_COMP_ALL(word1
);
502 vtx
.srf_mode_all
= G_SQ_VTX_WORD1_SRF_MODE_ALL(word1
);
505 vtx
.offset
= G_SQ_VTX_WORD2_OFFSET(word2
);
506 vtx
.endian
= G_SQ_VTX_WORD2_ENDIAN_SWAP(word2
);
508 if (r600_bytecode_add_vtx(ctx
->bc
, &vtx
)) {
509 fprintf(stderr
, "Error adding vtx\n");
511 /* Use the Texture Cache */
512 ctx
->bc
->cf_last
->inst
= EG_V_SQ_CF_WORD1_SQ_CF_INST_TEX
;
516 static void r600_bytecode_from_byte_stream(struct r600_shader_ctx
*ctx
,
517 unsigned char * bytes
, unsigned num_bytes
)
519 unsigned bytes_read
= 0;
521 while (bytes_read
< num_bytes
) {
522 char inst_type
= bytes
[bytes_read
++];
525 bytes_read
= r600_alu_from_byte_stream(ctx
, bytes
,
529 bytes_read
= r600_tex_from_byte_stream(ctx
, bytes
,
533 bytes_read
= r600_fc_from_byte_stream(ctx
, bytes
,
537 r600_bytecode_add_cfinst(ctx
->bc
, CF_NATIVE
);
538 for (i
= 0; i
< 2; i
++) {
539 for (byte
= 0 ; byte
< 4; byte
++) {
540 ctx
->bc
->cf_last
->isa
[i
] |=
541 (bytes
[bytes_read
++] << (byte
* 8));
547 bytes_read
= r600_vtx_from_byte_stream(ctx
, bytes
,
551 /* XXX: Error here */
557 /* End bytestream -> r600 shader functions*/
559 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
561 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
564 if (i
->Instruction
.NumDstRegs
> 1) {
565 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
568 if (i
->Instruction
.Predicate
) {
569 R600_ERR("predicate unsupported\n");
573 if (i
->Instruction
.Label
) {
574 R600_ERR("label unsupported\n");
578 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
579 if (i
->Src
[j
].Register
.Dimension
) {
580 R600_ERR("unsupported src %d (dimension %d)\n", j
,
581 i
->Src
[j
].Register
.Dimension
);
585 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
586 if (i
->Dst
[j
].Register
.Dimension
) {
587 R600_ERR("unsupported dst (dimension)\n");
594 static int evergreen_interp_alu(struct r600_shader_ctx
*ctx
, int input
)
597 struct r600_bytecode_alu alu
;
598 int gpr
= 0, base_chan
= 0;
601 if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_PERSPECTIVE
) {
603 if (ctx
->shader
->input
[input
].centroid
)
605 } else if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_LINEAR
) {
607 /* if we have perspective add one */
608 if (ctx
->input_perspective
) {
610 /* if we have perspective centroid */
611 if (ctx
->input_centroid
)
614 if (ctx
->shader
->input
[input
].centroid
)
618 /* work out gpr and base_chan from index */
620 base_chan
= (2 * (ij_index
% 2)) + 1;
622 for (i
= 0; i
< 8; i
++) {
623 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
626 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INTERP_ZW
;
628 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INTERP_XY
;
630 if ((i
> 1) && (i
< 6)) {
631 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
635 alu
.dst
.chan
= i
% 4;
637 alu
.src
[0].sel
= gpr
;
638 alu
.src
[0].chan
= (base_chan
- (i
% 2));
640 alu
.src
[1].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
642 alu
.bank_swizzle_force
= SQ_ALU_VEC_210
;
645 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
652 static int evergreen_interp_flat(struct r600_shader_ctx
*ctx
, int input
)
655 struct r600_bytecode_alu alu
;
657 for (i
= 0; i
< 4; i
++) {
658 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
660 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INTERP_LOAD_P0
;
662 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
667 alu
.src
[0].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
672 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
680 * Special export handling in shaders
682 * shader export ARRAY_BASE for EXPORT_POS:
685 * 62, 63 are clip distance vectors
687 * The use of the values exported in 61-63 are controlled by PA_CL_VS_OUT_CNTL:
688 * VS_OUT_MISC_VEC_ENA - enables the use of all fields in export 61
689 * USE_VTX_POINT_SIZE - point size in the X channel of export 61
690 * USE_VTX_EDGE_FLAG - edge flag in the Y channel of export 61
691 * USE_VTX_RENDER_TARGET_INDX - render target index in the Z channel of export 61
692 * USE_VTX_VIEWPORT_INDX - viewport index in the W channel of export 61
693 * USE_VTX_KILL_FLAG - kill flag in the Z channel of export 61 (mutually
694 * exclusive from render target index)
695 * VS_OUT_CCDIST0_VEC_ENA/VS_OUT_CCDIST1_VEC_ENA - enable clip distance vectors
698 * shader export ARRAY_BASE for EXPORT_PIXEL:
700 * 61 computed Z vector
702 * The use of the values exported in the computed Z vector are controlled
703 * by DB_SHADER_CONTROL:
704 * Z_EXPORT_ENABLE - Z as a float in RED
705 * STENCIL_REF_EXPORT_ENABLE - stencil ref as int in GREEN
706 * COVERAGE_TO_MASK_ENABLE - alpha to mask in ALPHA
707 * MASK_EXPORT_ENABLE - pixel sample mask in BLUE
708 * DB_SOURCE_FORMAT - export control restrictions
713 /* Map name/sid pair from tgsi to the 8-bit semantic index for SPI setup */
714 static int r600_spi_sid(struct r600_shader_io
* io
)
716 int index
, name
= io
->name
;
718 /* These params are handled differently, they don't need
719 * semantic indices, so we'll use 0 for them.
721 if (name
== TGSI_SEMANTIC_POSITION
||
722 name
== TGSI_SEMANTIC_PSIZE
||
723 name
== TGSI_SEMANTIC_FACE
)
726 if (name
== TGSI_SEMANTIC_GENERIC
) {
727 /* For generic params simply use sid from tgsi */
730 /* For non-generic params - pack name and sid into 8 bits */
731 index
= 0x80 | (name
<<3) | (io
->sid
);
734 /* Make sure that all really used indices have nonzero value, so
735 * we can just compare it to 0 later instead of comparing the name
736 * with different values to detect special cases. */
743 /* turn input into interpolate on EG */
744 static int evergreen_interp_input(struct r600_shader_ctx
*ctx
, int index
)
748 if (ctx
->shader
->input
[index
].spi_sid
) {
749 ctx
->shader
->input
[index
].lds_pos
= ctx
->shader
->nlds
++;
750 if (ctx
->shader
->input
[index
].interpolate
> 0) {
751 r
= evergreen_interp_alu(ctx
, index
);
753 r
= evergreen_interp_flat(ctx
, index
);
759 static int select_twoside_color(struct r600_shader_ctx
*ctx
, int front
, int back
)
761 struct r600_bytecode_alu alu
;
763 int gpr_front
= ctx
->shader
->input
[front
].gpr
;
764 int gpr_back
= ctx
->shader
->input
[back
].gpr
;
766 for (i
= 0; i
< 4; i
++) {
767 memset(&alu
, 0, sizeof(alu
));
768 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
771 alu
.dst
.sel
= gpr_front
;
772 alu
.src
[0].sel
= ctx
->face_gpr
;
773 alu
.src
[1].sel
= gpr_front
;
774 alu
.src
[2].sel
= gpr_back
;
781 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
788 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
790 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
794 switch (d
->Declaration
.File
) {
795 case TGSI_FILE_INPUT
:
796 i
= ctx
->shader
->ninput
++;
797 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
798 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
799 ctx
->shader
->input
[i
].spi_sid
= r600_spi_sid(&ctx
->shader
->input
[i
]);
800 ctx
->shader
->input
[i
].interpolate
= d
->Interp
.Interpolate
;
801 ctx
->shader
->input
[i
].centroid
= d
->Interp
.Centroid
;
802 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + d
->Range
.First
;
803 if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
) {
804 switch (ctx
->shader
->input
[i
].name
) {
805 case TGSI_SEMANTIC_FACE
:
806 ctx
->face_gpr
= ctx
->shader
->input
[i
].gpr
;
808 case TGSI_SEMANTIC_COLOR
:
811 case TGSI_SEMANTIC_POSITION
:
812 ctx
->fragcoord_input
= i
;
815 if (ctx
->bc
->chip_class
>= EVERGREEN
) {
816 if ((r
= evergreen_interp_input(ctx
, i
)))
821 case TGSI_FILE_OUTPUT
:
822 i
= ctx
->shader
->noutput
++;
823 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
824 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
825 ctx
->shader
->output
[i
].spi_sid
= r600_spi_sid(&ctx
->shader
->output
[i
]);
826 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + d
->Range
.First
;
827 ctx
->shader
->output
[i
].interpolate
= d
->Interp
.Interpolate
;
828 ctx
->shader
->output
[i
].write_mask
= d
->Declaration
.UsageMask
;
829 if (ctx
->type
== TGSI_PROCESSOR_VERTEX
) {
830 switch (d
->Semantic
.Name
) {
831 case TGSI_SEMANTIC_CLIPDIST
:
832 ctx
->shader
->clip_dist_write
|= d
->Declaration
.UsageMask
<< (d
->Semantic
.Index
<< 2);
834 case TGSI_SEMANTIC_PSIZE
:
835 ctx
->shader
->vs_out_misc_write
= 1;
836 ctx
->shader
->vs_out_point_size
= 1;
838 case TGSI_SEMANTIC_CLIPVERTEX
:
839 ctx
->clip_vertex_write
= TRUE
;
843 } else if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
) {
844 switch (d
->Semantic
.Name
) {
845 case TGSI_SEMANTIC_COLOR
:
846 ctx
->shader
->nr_ps_max_color_exports
++;
851 case TGSI_FILE_CONSTANT
:
852 case TGSI_FILE_TEMPORARY
:
853 case TGSI_FILE_SAMPLER
:
854 case TGSI_FILE_ADDRESS
:
857 case TGSI_FILE_SYSTEM_VALUE
:
858 if (d
->Semantic
.Name
== TGSI_SEMANTIC_INSTANCEID
) {
859 if (!ctx
->native_integers
) {
860 struct r600_bytecode_alu alu
;
861 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
863 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
);
872 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
876 } else if (d
->Semantic
.Name
== TGSI_SEMANTIC_VERTEXID
)
879 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
885 static int r600_get_temp(struct r600_shader_ctx
*ctx
)
887 return ctx
->temp_reg
+ ctx
->max_driver_temp_used
++;
891 * for evergreen we need to scan the shader to find the number of GPRs we need to
892 * reserve for interpolation.
894 * we need to know if we are going to emit
895 * any centroid inputs
896 * if perspective and linear are required
898 static int evergreen_gpr_count(struct r600_shader_ctx
*ctx
)
903 ctx
->input_linear
= FALSE
;
904 ctx
->input_perspective
= FALSE
;
905 ctx
->input_centroid
= FALSE
;
906 ctx
->num_interp_gpr
= 1;
908 /* any centroid inputs */
909 for (i
= 0; i
< ctx
->info
.num_inputs
; i
++) {
910 /* skip position/face */
911 if (ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_POSITION
||
912 ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_FACE
)
914 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_LINEAR
)
915 ctx
->input_linear
= TRUE
;
916 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_PERSPECTIVE
)
917 ctx
->input_perspective
= TRUE
;
918 if (ctx
->info
.input_centroid
[i
])
919 ctx
->input_centroid
= TRUE
;
923 /* ignoring sample for now */
924 if (ctx
->input_perspective
)
926 if (ctx
->input_linear
)
928 if (ctx
->input_centroid
)
931 ctx
->num_interp_gpr
+= (num_baryc
+ 1) >> 1;
933 /* XXX PULL MODEL and LINE STIPPLE, FIXED PT POS */
934 return ctx
->num_interp_gpr
;
937 static void tgsi_src(struct r600_shader_ctx
*ctx
,
938 const struct tgsi_full_src_register
*tgsi_src
,
939 struct r600_shader_src
*r600_src
)
941 memset(r600_src
, 0, sizeof(*r600_src
));
942 r600_src
->swizzle
[0] = tgsi_src
->Register
.SwizzleX
;
943 r600_src
->swizzle
[1] = tgsi_src
->Register
.SwizzleY
;
944 r600_src
->swizzle
[2] = tgsi_src
->Register
.SwizzleZ
;
945 r600_src
->swizzle
[3] = tgsi_src
->Register
.SwizzleW
;
946 r600_src
->neg
= tgsi_src
->Register
.Negate
;
947 r600_src
->abs
= tgsi_src
->Register
.Absolute
;
949 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
951 if ((tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleY
) &&
952 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleZ
) &&
953 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleW
)) {
955 index
= tgsi_src
->Register
.Index
* 4 + tgsi_src
->Register
.SwizzleX
;
956 r600_bytecode_special_constants(ctx
->literals
[index
], &r600_src
->sel
, &r600_src
->neg
);
957 if (r600_src
->sel
!= V_SQ_ALU_SRC_LITERAL
)
960 index
= tgsi_src
->Register
.Index
;
961 r600_src
->sel
= V_SQ_ALU_SRC_LITERAL
;
962 memcpy(r600_src
->value
, ctx
->literals
+ index
* 4, sizeof(r600_src
->value
));
963 } else if (tgsi_src
->Register
.File
== TGSI_FILE_SYSTEM_VALUE
) {
964 if (ctx
->info
.system_value_semantic_name
[tgsi_src
->Register
.Index
] == TGSI_SEMANTIC_INSTANCEID
) {
965 r600_src
->swizzle
[0] = 3;
966 r600_src
->swizzle
[1] = 3;
967 r600_src
->swizzle
[2] = 3;
968 r600_src
->swizzle
[3] = 3;
970 } else if (ctx
->info
.system_value_semantic_name
[tgsi_src
->Register
.Index
] == TGSI_SEMANTIC_VERTEXID
) {
971 r600_src
->swizzle
[0] = 0;
972 r600_src
->swizzle
[1] = 0;
973 r600_src
->swizzle
[2] = 0;
974 r600_src
->swizzle
[3] = 0;
978 if (tgsi_src
->Register
.Indirect
)
979 r600_src
->rel
= V_SQ_REL_RELATIVE
;
980 r600_src
->sel
= tgsi_src
->Register
.Index
;
981 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
985 static int tgsi_fetch_rel_const(struct r600_shader_ctx
*ctx
, unsigned int offset
, unsigned int dst_reg
)
987 struct r600_bytecode_vtx vtx
;
992 struct r600_bytecode_alu alu
;
994 memset(&alu
, 0, sizeof(alu
));
996 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
997 alu
.src
[0].sel
= ctx
->bc
->ar_reg
;
999 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1000 alu
.src
[1].value
= offset
;
1002 alu
.dst
.sel
= dst_reg
;
1006 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
1011 ar_reg
= ctx
->bc
->ar_reg
;
1014 memset(&vtx
, 0, sizeof(vtx
));
1015 vtx
.fetch_type
= 2; /* VTX_FETCH_NO_INDEX_OFFSET */
1016 vtx
.src_gpr
= ar_reg
;
1017 vtx
.mega_fetch_count
= 16;
1018 vtx
.dst_gpr
= dst_reg
;
1019 vtx
.dst_sel_x
= 0; /* SEL_X */
1020 vtx
.dst_sel_y
= 1; /* SEL_Y */
1021 vtx
.dst_sel_z
= 2; /* SEL_Z */
1022 vtx
.dst_sel_w
= 3; /* SEL_W */
1023 vtx
.data_format
= FMT_32_32_32_32_FLOAT
;
1024 vtx
.num_format_all
= 2; /* NUM_FORMAT_SCALED */
1025 vtx
.format_comp_all
= 1; /* FORMAT_COMP_SIGNED */
1026 vtx
.srf_mode_all
= 1; /* SRF_MODE_NO_ZERO */
1027 vtx
.endian
= r600_endian_swap(32);
1029 if ((r
= r600_bytecode_add_vtx(ctx
->bc
, &vtx
)))
1035 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
)
1037 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1038 struct r600_bytecode_alu alu
;
1039 int i
, j
, k
, nconst
, r
;
1041 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1042 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
1045 tgsi_src(ctx
, &inst
->Src
[i
], &ctx
->src
[i
]);
1047 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1048 if (inst
->Src
[i
].Register
.File
!= TGSI_FILE_CONSTANT
) {
1052 if (ctx
->src
[i
].rel
) {
1053 int treg
= r600_get_temp(ctx
);
1054 if ((r
= tgsi_fetch_rel_const(ctx
, ctx
->src
[i
].sel
- 512, treg
)))
1057 ctx
->src
[i
].sel
= treg
;
1058 ctx
->src
[i
].rel
= 0;
1061 int treg
= r600_get_temp(ctx
);
1062 for (k
= 0; k
< 4; k
++) {
1063 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1064 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1065 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
1066 alu
.src
[0].chan
= k
;
1067 alu
.src
[0].rel
= ctx
->src
[i
].rel
;
1073 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1077 ctx
->src
[i
].sel
= treg
;
1085 /* need to move any immediate into a temp - for trig functions which use literal for PI stuff */
1086 static int tgsi_split_literal_constant(struct r600_shader_ctx
*ctx
)
1088 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1089 struct r600_bytecode_alu alu
;
1090 int i
, j
, k
, nliteral
, r
;
1092 for (i
= 0, nliteral
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1093 if (ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
1097 for (i
= 0, j
= nliteral
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1098 if (j
> 0 && ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
1099 int treg
= r600_get_temp(ctx
);
1100 for (k
= 0; k
< 4; k
++) {
1101 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1102 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1103 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
1104 alu
.src
[0].chan
= k
;
1105 alu
.src
[0].value
= ctx
->src
[i
].value
[k
];
1111 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1115 ctx
->src
[i
].sel
= treg
;
1122 static int process_twoside_color_inputs(struct r600_shader_ctx
*ctx
)
1124 int i
, r
, count
= ctx
->shader
->ninput
;
1126 /* additional inputs will be allocated right after the existing inputs,
1127 * we won't need them after the color selection, so we don't need to
1128 * reserve these gprs for the rest of the shader code and to adjust
1129 * output offsets etc. */
1130 int gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] +
1131 ctx
->info
.file_max
[TGSI_FILE_INPUT
] + 1;
1133 if (ctx
->face_gpr
== -1) {
1134 i
= ctx
->shader
->ninput
++;
1135 ctx
->shader
->input
[i
].name
= TGSI_SEMANTIC_FACE
;
1136 ctx
->shader
->input
[i
].spi_sid
= 0;
1137 ctx
->shader
->input
[i
].gpr
= gpr
++;
1138 ctx
->face_gpr
= ctx
->shader
->input
[i
].gpr
;
1141 for (i
= 0; i
< count
; i
++) {
1142 if (ctx
->shader
->input
[i
].name
== TGSI_SEMANTIC_COLOR
) {
1143 int ni
= ctx
->shader
->ninput
++;
1144 memcpy(&ctx
->shader
->input
[ni
],&ctx
->shader
->input
[i
], sizeof(struct r600_shader_io
));
1145 ctx
->shader
->input
[ni
].name
= TGSI_SEMANTIC_BCOLOR
;
1146 ctx
->shader
->input
[ni
].spi_sid
= r600_spi_sid(&ctx
->shader
->input
[ni
]);
1147 ctx
->shader
->input
[ni
].gpr
= gpr
++;
1149 if (ctx
->bc
->chip_class
>= EVERGREEN
) {
1150 r
= evergreen_interp_input(ctx
, ni
);
1155 r
= select_twoside_color(ctx
, i
, ni
);
1163 static int r600_shader_from_tgsi(struct r600_context
* rctx
, struct r600_pipe_shader
*pipeshader
)
1165 struct r600_shader
*shader
= &pipeshader
->shader
;
1166 struct tgsi_token
*tokens
= pipeshader
->selector
->tokens
;
1167 struct pipe_stream_output_info so
= pipeshader
->selector
->so
;
1168 struct tgsi_full_immediate
*immediate
;
1169 struct tgsi_full_property
*property
;
1170 struct r600_shader_ctx ctx
;
1171 struct r600_bytecode_output output
[32];
1172 unsigned output_done
, noutput
;
1175 int next_pixel_base
= 0, next_pos_base
= 60, next_param_base
= 0;
1176 /* Declarations used by llvm code */
1177 bool use_llvm
= false;
1178 unsigned char * inst_bytes
= NULL
;
1179 unsigned inst_byte_count
= 0;
1181 #ifdef R600_USE_LLVM
1182 use_llvm
= debug_get_bool_option("R600_LLVM", TRUE
);
1184 ctx
.bc
= &shader
->bc
;
1185 ctx
.shader
= shader
;
1186 ctx
.native_integers
= true;
1188 r600_bytecode_init(ctx
.bc
, rctx
->chip_class
, rctx
->family
);
1189 ctx
.tokens
= tokens
;
1190 tgsi_scan_shader(tokens
, &ctx
.info
);
1191 tgsi_parse_init(&ctx
.parse
, tokens
);
1192 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
1193 shader
->processor_type
= ctx
.type
;
1194 ctx
.bc
->type
= shader
->processor_type
;
1197 ctx
.fragcoord_input
= -1;
1198 ctx
.colors_used
= 0;
1199 ctx
.clip_vertex_write
= 0;
1201 shader
->nr_ps_color_exports
= 0;
1202 shader
->nr_ps_max_color_exports
= 0;
1204 shader
->two_side
= (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
) && rctx
->two_side
;
1206 /* register allocations */
1207 /* Values [0,127] correspond to GPR[0..127].
1208 * Values [128,159] correspond to constant buffer bank 0
1209 * Values [160,191] correspond to constant buffer bank 1
1210 * Values [256,511] correspond to cfile constants c[0..255]. (Gone on EG)
1211 * Values [256,287] correspond to constant buffer bank 2 (EG)
1212 * Values [288,319] correspond to constant buffer bank 3 (EG)
1213 * Other special values are shown in the list below.
1214 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
1215 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
1216 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
1217 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
1218 * 248 SQ_ALU_SRC_0: special constant 0.0.
1219 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
1220 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
1221 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
1222 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
1223 * 253 SQ_ALU_SRC_LITERAL: literal constant.
1224 * 254 SQ_ALU_SRC_PV: previous vector result.
1225 * 255 SQ_ALU_SRC_PS: previous scalar result.
1227 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
1228 ctx
.file_offset
[i
] = 0;
1230 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
1231 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
1232 if (ctx
.bc
->chip_class
>= EVERGREEN
) {
1233 r600_bytecode_add_cfinst(ctx
.bc
, EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
1235 r600_bytecode_add_cfinst(ctx
.bc
, V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
1238 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
.bc
->chip_class
>= EVERGREEN
) {
1239 ctx
.file_offset
[TGSI_FILE_INPUT
] = evergreen_gpr_count(&ctx
);
1242 /* LLVM backend setup */
1243 #ifdef R600_USE_LLVM
1244 if (use_llvm
&& ctx
.info
.indirect_files
) {
1245 fprintf(stderr
, "Warning: R600 LLVM backend does not support "
1246 "indirect adressing. Falling back to TGSI "
1251 struct radeon_llvm_context radeon_llvm_ctx
;
1254 memset(&radeon_llvm_ctx
, 0, sizeof(radeon_llvm_ctx
));
1255 radeon_llvm_ctx
.reserved_reg_count
= ctx
.file_offset
[TGSI_FILE_INPUT
];
1256 mod
= r600_tgsi_llvm(&radeon_llvm_ctx
, tokens
);
1257 if (debug_get_bool_option("R600_DUMP_SHADERS", FALSE
)) {
1260 if (r600_llvm_compile(mod
, &inst_bytes
, &inst_byte_count
,
1261 rctx
->family
, dump
)) {
1263 radeon_llvm_dispose(&radeon_llvm_ctx
);
1265 fprintf(stderr
, "R600 LLVM backend failed to compile "
1266 "shader. Falling back to TGSI\n");
1268 ctx
.file_offset
[TGSI_FILE_OUTPUT
] =
1269 ctx
.file_offset
[TGSI_FILE_INPUT
];
1271 radeon_llvm_dispose(&radeon_llvm_ctx
);
1274 /* End of LLVM backend setup */
1277 ctx
.file_offset
[TGSI_FILE_OUTPUT
] =
1278 ctx
.file_offset
[TGSI_FILE_INPUT
] +
1279 ctx
.info
.file_max
[TGSI_FILE_INPUT
] + 1;
1281 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
1282 ctx
.info
.file_max
[TGSI_FILE_OUTPUT
] + 1;
1284 /* Outside the GPR range. This will be translated to one of the
1285 * kcache banks later. */
1286 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 512;
1288 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = V_SQ_ALU_SRC_LITERAL
;
1289 ctx
.bc
->ar_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
1290 ctx
.info
.file_max
[TGSI_FILE_TEMPORARY
] + 1;
1291 ctx
.temp_reg
= ctx
.bc
->ar_reg
+ 1;
1294 ctx
.literals
= NULL
;
1295 shader
->fs_write_all
= FALSE
;
1296 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
1297 tgsi_parse_token(&ctx
.parse
);
1298 switch (ctx
.parse
.FullToken
.Token
.Type
) {
1299 case TGSI_TOKEN_TYPE_IMMEDIATE
:
1300 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
1301 ctx
.literals
= realloc(ctx
.literals
, (ctx
.nliterals
+ 1) * 16);
1302 if(ctx
.literals
== NULL
) {
1306 ctx
.literals
[ctx
.nliterals
* 4 + 0] = immediate
->u
[0].Uint
;
1307 ctx
.literals
[ctx
.nliterals
* 4 + 1] = immediate
->u
[1].Uint
;
1308 ctx
.literals
[ctx
.nliterals
* 4 + 2] = immediate
->u
[2].Uint
;
1309 ctx
.literals
[ctx
.nliterals
* 4 + 3] = immediate
->u
[3].Uint
;
1312 case TGSI_TOKEN_TYPE_DECLARATION
:
1313 r
= tgsi_declaration(&ctx
);
1317 case TGSI_TOKEN_TYPE_INSTRUCTION
:
1319 case TGSI_TOKEN_TYPE_PROPERTY
:
1320 property
= &ctx
.parse
.FullToken
.FullProperty
;
1321 switch (property
->Property
.PropertyName
) {
1322 case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS
:
1323 if (property
->u
[0].Data
== 1)
1324 shader
->fs_write_all
= TRUE
;
1326 case TGSI_PROPERTY_VS_PROHIBIT_UCPS
:
1327 if (property
->u
[0].Data
== 1)
1328 shader
->vs_prohibit_ucps
= TRUE
;
1333 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
1339 if (shader
->fs_write_all
&& rctx
->chip_class
>= EVERGREEN
)
1340 shader
->nr_ps_max_color_exports
= 8;
1342 if (ctx
.fragcoord_input
>= 0) {
1343 if (ctx
.bc
->chip_class
== CAYMAN
) {
1344 for (j
= 0 ; j
< 4; j
++) {
1345 struct r600_bytecode_alu alu
;
1346 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1347 alu
.inst
= BC_INST(ctx
.bc
, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1348 alu
.src
[0].sel
= shader
->input
[ctx
.fragcoord_input
].gpr
;
1349 alu
.src
[0].chan
= 3;
1351 alu
.dst
.sel
= shader
->input
[ctx
.fragcoord_input
].gpr
;
1353 alu
.dst
.write
= (j
== 3);
1355 if ((r
= r600_bytecode_add_alu(ctx
.bc
, &alu
)))
1359 struct r600_bytecode_alu alu
;
1360 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1361 alu
.inst
= BC_INST(ctx
.bc
, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1362 alu
.src
[0].sel
= shader
->input
[ctx
.fragcoord_input
].gpr
;
1363 alu
.src
[0].chan
= 3;
1365 alu
.dst
.sel
= shader
->input
[ctx
.fragcoord_input
].gpr
;
1369 if ((r
= r600_bytecode_add_alu(ctx
.bc
, &alu
)))
1374 if (shader
->two_side
&& ctx
.colors_used
) {
1375 if ((r
= process_twoside_color_inputs(&ctx
)))
1379 tgsi_parse_init(&ctx
.parse
, tokens
);
1380 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
1381 tgsi_parse_token(&ctx
.parse
);
1382 switch (ctx
.parse
.FullToken
.Token
.Type
) {
1383 case TGSI_TOKEN_TYPE_INSTRUCTION
:
1387 r
= tgsi_is_supported(&ctx
);
1390 ctx
.max_driver_temp_used
= 0;
1391 /* reserve first tmp for everyone */
1392 r600_get_temp(&ctx
);
1394 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
1395 if ((r
= tgsi_split_constant(&ctx
)))
1397 if ((r
= tgsi_split_literal_constant(&ctx
)))
1399 if (ctx
.bc
->chip_class
== CAYMAN
)
1400 ctx
.inst_info
= &cm_shader_tgsi_instruction
[opcode
];
1401 else if (ctx
.bc
->chip_class
>= EVERGREEN
)
1402 ctx
.inst_info
= &eg_shader_tgsi_instruction
[opcode
];
1404 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
1405 r
= ctx
.inst_info
->process(&ctx
);
1414 /* Get instructions if we are using the LLVM backend. */
1416 r600_bytecode_from_byte_stream(&ctx
, inst_bytes
, inst_byte_count
);
1420 noutput
= shader
->noutput
;
1422 if (ctx
.clip_vertex_write
) {
1423 /* need to convert a clipvertex write into clipdistance writes and not export
1424 the clip vertex anymore */
1426 memset(&shader
->output
[noutput
], 0, 2*sizeof(struct r600_shader_io
));
1427 shader
->output
[noutput
].name
= TGSI_SEMANTIC_CLIPDIST
;
1428 shader
->output
[noutput
].gpr
= ctx
.temp_reg
;
1430 shader
->output
[noutput
].name
= TGSI_SEMANTIC_CLIPDIST
;
1431 shader
->output
[noutput
].gpr
= ctx
.temp_reg
+1;
1434 /* reset spi_sid for clipvertex output to avoid confusing spi */
1435 shader
->output
[ctx
.cv_output
].spi_sid
= 0;
1437 shader
->clip_dist_write
= 0xFF;
1439 for (i
= 0; i
< 8; i
++) {
1443 for (j
= 0; j
< 4; j
++) {
1444 struct r600_bytecode_alu alu
;
1445 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1446 alu
.inst
= BC_INST(ctx
.bc
, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
);
1447 alu
.src
[0].sel
= shader
->output
[ctx
.cv_output
].gpr
;
1448 alu
.src
[0].chan
= j
;
1450 alu
.src
[1].sel
= 512 + i
;
1451 alu
.src
[1].kc_bank
= 1;
1452 alu
.src
[1].chan
= j
;
1454 alu
.dst
.sel
= ctx
.temp_reg
+ oreg
;
1456 alu
.dst
.write
= (j
== ochan
);
1459 r
= r600_bytecode_add_alu(ctx
.bc
, &alu
);
1466 /* Add stream outputs. */
1467 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
&& so
.num_outputs
) {
1468 for (i
= 0; i
< so
.num_outputs
; i
++) {
1469 struct r600_bytecode_output output
;
1471 if (so
.output
[i
].output_buffer
>= 4) {
1472 R600_ERR("exceeded the max number of stream output buffers, got: %d\n",
1473 so
.output
[i
].output_buffer
);
1477 if (so
.output
[i
].dst_offset
< so
.output
[i
].start_component
) {
1478 R600_ERR("stream_output - dst_offset cannot be less than start_component\n");
1483 memset(&output
, 0, sizeof(struct r600_bytecode_output
));
1484 output
.gpr
= shader
->output
[so
.output
[i
].register_index
].gpr
;
1485 output
.elem_size
= 0;
1486 output
.array_base
= so
.output
[i
].dst_offset
- so
.output
[i
].start_component
;
1487 output
.type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_WRITE
;
1488 output
.burst_count
= 1;
1490 /* array_size is an upper limit for the burst_count
1491 * with MEM_STREAM instructions */
1492 output
.array_size
= 0xFFF;
1493 output
.comp_mask
= ((1 << so
.output
[i
].num_components
) - 1) << so
.output
[i
].start_component
;
1494 if (ctx
.bc
->chip_class
>= EVERGREEN
) {
1495 switch (so
.output
[i
].output_buffer
) {
1497 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF0
;
1500 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF1
;
1503 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF2
;
1506 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF3
;
1510 switch (so
.output
[i
].output_buffer
) {
1512 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0
;
1515 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1
;
1518 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2
;
1521 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3
;
1525 r
= r600_bytecode_add_output(ctx
.bc
, &output
);
1532 for (i
= 0, j
= 0; i
< noutput
; i
++, j
++) {
1533 memset(&output
[j
], 0, sizeof(struct r600_bytecode_output
));
1534 output
[j
].gpr
= shader
->output
[i
].gpr
;
1535 output
[j
].elem_size
= 3;
1536 output
[j
].swizzle_x
= 0;
1537 output
[j
].swizzle_y
= 1;
1538 output
[j
].swizzle_z
= 2;
1539 output
[j
].swizzle_w
= 3;
1540 output
[j
].burst_count
= 1;
1541 output
[j
].barrier
= 1;
1542 output
[j
].type
= -1;
1543 output
[j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1545 case TGSI_PROCESSOR_VERTEX
:
1546 switch (shader
->output
[i
].name
) {
1547 case TGSI_SEMANTIC_POSITION
:
1548 output
[j
].array_base
= next_pos_base
++;
1549 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
1552 case TGSI_SEMANTIC_PSIZE
:
1553 output
[j
].array_base
= next_pos_base
++;
1554 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
1556 case TGSI_SEMANTIC_CLIPVERTEX
:
1559 case TGSI_SEMANTIC_CLIPDIST
:
1560 output
[j
].array_base
= next_pos_base
++;
1561 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
1562 /* spi_sid is 0 for clipdistance outputs that were generated
1563 * for clipvertex - we don't need to pass them to PS */
1564 if (shader
->output
[i
].spi_sid
) {
1566 /* duplicate it as PARAM to pass to the pixel shader */
1567 memcpy(&output
[j
], &output
[j
-1], sizeof(struct r600_bytecode_output
));
1568 output
[j
].array_base
= next_param_base
++;
1569 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
1572 case TGSI_SEMANTIC_FOG
:
1573 output
[j
].swizzle_y
= 4; /* 0 */
1574 output
[j
].swizzle_z
= 4; /* 0 */
1575 output
[j
].swizzle_w
= 5; /* 1 */
1579 case TGSI_PROCESSOR_FRAGMENT
:
1580 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
1581 /* never export more colors than the number of CBs */
1582 if (next_pixel_base
&& next_pixel_base
>= (rctx
->nr_cbufs
+ rctx
->dual_src_blend
* 1)) {
1587 output
[j
].swizzle_w
= rctx
->alpha_to_one
&& rctx
->multisample_enable
&& !rctx
->cb0_is_integer
? 5 : 3;
1588 output
[j
].array_base
= next_pixel_base
++;
1589 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1590 shader
->nr_ps_color_exports
++;
1591 if (shader
->fs_write_all
&& (rctx
->chip_class
>= EVERGREEN
)) {
1592 for (k
= 1; k
< rctx
->nr_cbufs
; k
++) {
1594 memset(&output
[j
], 0, sizeof(struct r600_bytecode_output
));
1595 output
[j
].gpr
= shader
->output
[i
].gpr
;
1596 output
[j
].elem_size
= 3;
1597 output
[j
].swizzle_x
= 0;
1598 output
[j
].swizzle_y
= 1;
1599 output
[j
].swizzle_z
= 2;
1600 output
[j
].swizzle_w
= rctx
->alpha_to_one
&& rctx
->multisample_enable
&& !rctx
->cb0_is_integer
? 5 : 3;
1601 output
[j
].burst_count
= 1;
1602 output
[j
].barrier
= 1;
1603 output
[j
].array_base
= next_pixel_base
++;
1604 output
[j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1605 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1606 shader
->nr_ps_color_exports
++;
1609 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
1610 output
[j
].array_base
= 61;
1611 output
[j
].swizzle_x
= 2;
1612 output
[j
].swizzle_y
= 7;
1613 output
[j
].swizzle_z
= output
[j
].swizzle_w
= 7;
1614 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1615 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
) {
1616 output
[j
].array_base
= 61;
1617 output
[j
].swizzle_x
= 7;
1618 output
[j
].swizzle_y
= 1;
1619 output
[j
].swizzle_z
= output
[j
].swizzle_w
= 7;
1620 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1622 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
1628 R600_ERR("unsupported processor type %d\n", ctx
.type
);
1633 if (output
[j
].type
==-1) {
1634 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
1635 output
[j
].array_base
= next_param_base
++;
1639 /* add fake param output for vertex shader if no param is exported */
1640 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
&& next_param_base
== 0) {
1641 memset(&output
[j
], 0, sizeof(struct r600_bytecode_output
));
1643 output
[j
].elem_size
= 3;
1644 output
[j
].swizzle_x
= 7;
1645 output
[j
].swizzle_y
= 7;
1646 output
[j
].swizzle_z
= 7;
1647 output
[j
].swizzle_w
= 7;
1648 output
[j
].burst_count
= 1;
1649 output
[j
].barrier
= 1;
1650 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
1651 output
[j
].array_base
= 0;
1652 output
[j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1656 /* add fake pixel export */
1657 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& next_pixel_base
== 0) {
1658 memset(&output
[j
], 0, sizeof(struct r600_bytecode_output
));
1660 output
[j
].elem_size
= 3;
1661 output
[j
].swizzle_x
= 7;
1662 output
[j
].swizzle_y
= 7;
1663 output
[j
].swizzle_z
= 7;
1664 output
[j
].swizzle_w
= 7;
1665 output
[j
].burst_count
= 1;
1666 output
[j
].barrier
= 1;
1667 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1668 output
[j
].array_base
= 0;
1669 output
[j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1675 /* set export done on last export of each type */
1676 for (i
= noutput
- 1, output_done
= 0; i
>= 0; i
--) {
1677 if (ctx
.bc
->chip_class
< CAYMAN
) {
1678 if (i
== (noutput
- 1)) {
1679 output
[i
].end_of_program
= 1;
1682 if (!(output_done
& (1 << output
[i
].type
))) {
1683 output_done
|= (1 << output
[i
].type
);
1684 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
);
1687 /* add output to bytecode */
1688 for (i
= 0; i
< noutput
; i
++) {
1689 r
= r600_bytecode_add_output(ctx
.bc
, &output
[i
]);
1693 /* add program end */
1694 if (ctx
.bc
->chip_class
== CAYMAN
)
1695 cm_bytecode_add_cf_end(ctx
.bc
);
1697 /* check GPR limit - we have 124 = 128 - 4
1698 * (4 are reserved as alu clause temporary registers) */
1699 if (ctx
.bc
->ngpr
> 124) {
1700 R600_ERR("GPR limit exceeded - shader requires %d registers\n", ctx
.bc
->ngpr
);
1706 tgsi_parse_free(&ctx
.parse
);
1710 tgsi_parse_free(&ctx
.parse
);
1714 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
1716 R600_ERR("%s tgsi opcode unsupported\n",
1717 tgsi_get_opcode_name(ctx
->inst_info
->tgsi_opcode
));
1721 static int tgsi_end(struct r600_shader_ctx
*ctx
)
1726 static void r600_bytecode_src(struct r600_bytecode_alu_src
*bc_src
,
1727 const struct r600_shader_src
*shader_src
,
1730 bc_src
->sel
= shader_src
->sel
;
1731 bc_src
->chan
= shader_src
->swizzle
[chan
];
1732 bc_src
->neg
= shader_src
->neg
;
1733 bc_src
->abs
= shader_src
->abs
;
1734 bc_src
->rel
= shader_src
->rel
;
1735 bc_src
->value
= shader_src
->value
[bc_src
->chan
];
1738 static void r600_bytecode_src_set_abs(struct r600_bytecode_alu_src
*bc_src
)
1744 static void r600_bytecode_src_toggle_neg(struct r600_bytecode_alu_src
*bc_src
)
1746 bc_src
->neg
= !bc_src
->neg
;
1749 static void tgsi_dst(struct r600_shader_ctx
*ctx
,
1750 const struct tgsi_full_dst_register
*tgsi_dst
,
1752 struct r600_bytecode_alu_dst
*r600_dst
)
1754 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1756 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
1757 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
1758 r600_dst
->chan
= swizzle
;
1759 r600_dst
->write
= 1;
1760 if (tgsi_dst
->Register
.Indirect
)
1761 r600_dst
->rel
= V_SQ_REL_RELATIVE
;
1762 if (inst
->Instruction
.Saturate
) {
1763 r600_dst
->clamp
= 1;
1767 static int tgsi_last_instruction(unsigned writemask
)
1771 for (i
= 0; i
< 4; i
++) {
1772 if (writemask
& (1 << i
)) {
1779 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
, int trans_only
)
1781 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1782 struct r600_bytecode_alu alu
;
1784 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1786 for (i
= 0; i
< lasti
+ 1; i
++) {
1787 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1790 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1791 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1793 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1795 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1796 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
1799 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
1800 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
1802 /* handle some special cases */
1803 switch (ctx
->inst_info
->tgsi_opcode
) {
1804 case TGSI_OPCODE_SUB
:
1805 r600_bytecode_src_toggle_neg(&alu
.src
[1]);
1807 case TGSI_OPCODE_ABS
:
1808 r600_bytecode_src_set_abs(&alu
.src
[0]);
1813 if (i
== lasti
|| trans_only
) {
1816 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1823 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
1825 return tgsi_op2_s(ctx
, 0, 0);
1828 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
1830 return tgsi_op2_s(ctx
, 1, 0);
1833 static int tgsi_op2_trans(struct r600_shader_ctx
*ctx
)
1835 return tgsi_op2_s(ctx
, 0, 1);
1838 static int tgsi_ineg(struct r600_shader_ctx
*ctx
)
1840 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1841 struct r600_bytecode_alu alu
;
1843 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1845 for (i
= 0; i
< lasti
+ 1; i
++) {
1847 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1849 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1850 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1852 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1854 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
1856 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1861 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1869 static int cayman_emit_float_instr(struct r600_shader_ctx
*ctx
)
1871 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1873 struct r600_bytecode_alu alu
;
1874 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
1876 for (i
= 0 ; i
< last_slot
; i
++) {
1877 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1878 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1879 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1880 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], 0);
1882 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1883 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1885 if (i
== last_slot
- 1)
1887 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1894 static int cayman_mul_int_instr(struct r600_shader_ctx
*ctx
)
1896 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1898 struct r600_bytecode_alu alu
;
1899 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
1900 for (k
= 0; k
< last_slot
; k
++) {
1901 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << k
)))
1904 for (i
= 0 ; i
< 4; i
++) {
1905 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1906 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1907 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1908 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], k
);
1910 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1911 alu
.dst
.write
= (i
== k
);
1914 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1923 * r600 - trunc to -PI..PI range
1924 * r700 - normalize by dividing by 2PI
1927 static int tgsi_setup_trig(struct r600_shader_ctx
*ctx
)
1929 static float half_inv_pi
= 1.0 /(3.1415926535 * 2);
1930 static float double_pi
= 3.1415926535 * 2;
1931 static float neg_pi
= -3.1415926535;
1934 struct r600_bytecode_alu alu
;
1936 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1937 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1941 alu
.dst
.sel
= ctx
->temp_reg
;
1944 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
1946 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1947 alu
.src
[1].chan
= 0;
1948 alu
.src
[1].value
= *(uint32_t *)&half_inv_pi
;
1949 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
1950 alu
.src
[2].chan
= 0;
1952 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1956 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1957 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
1960 alu
.dst
.sel
= ctx
->temp_reg
;
1963 alu
.src
[0].sel
= ctx
->temp_reg
;
1964 alu
.src
[0].chan
= 0;
1966 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1970 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1971 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1975 alu
.dst
.sel
= ctx
->temp_reg
;
1978 alu
.src
[0].sel
= ctx
->temp_reg
;
1979 alu
.src
[0].chan
= 0;
1981 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1982 alu
.src
[1].chan
= 0;
1983 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1984 alu
.src
[2].chan
= 0;
1986 if (ctx
->bc
->chip_class
== R600
) {
1987 alu
.src
[1].value
= *(uint32_t *)&double_pi
;
1988 alu
.src
[2].value
= *(uint32_t *)&neg_pi
;
1990 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1991 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
1996 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2002 static int cayman_trig(struct r600_shader_ctx
*ctx
)
2004 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2005 struct r600_bytecode_alu alu
;
2006 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
2009 r
= tgsi_setup_trig(ctx
);
2014 for (i
= 0; i
< last_slot
; i
++) {
2015 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2016 alu
.inst
= ctx
->inst_info
->r600_opcode
;
2019 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2020 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
2022 alu
.src
[0].sel
= ctx
->temp_reg
;
2023 alu
.src
[0].chan
= 0;
2024 if (i
== last_slot
- 1)
2026 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2033 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
2035 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2036 struct r600_bytecode_alu alu
;
2038 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
2040 r
= tgsi_setup_trig(ctx
);
2044 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2045 alu
.inst
= ctx
->inst_info
->r600_opcode
;
2047 alu
.dst
.sel
= ctx
->temp_reg
;
2050 alu
.src
[0].sel
= ctx
->temp_reg
;
2051 alu
.src
[0].chan
= 0;
2053 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2057 /* replicate result */
2058 for (i
= 0; i
< lasti
+ 1; i
++) {
2059 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
2062 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2063 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2065 alu
.src
[0].sel
= ctx
->temp_reg
;
2066 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2069 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2076 static int tgsi_scs(struct r600_shader_ctx
*ctx
)
2078 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2079 struct r600_bytecode_alu alu
;
2082 /* We'll only need the trig stuff if we are going to write to the
2083 * X or Y components of the destination vector.
2085 if (likely(inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_XY
)) {
2086 r
= tgsi_setup_trig(ctx
);
2092 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_X
) {
2093 if (ctx
->bc
->chip_class
== CAYMAN
) {
2094 for (i
= 0 ; i
< 3; i
++) {
2095 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2096 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
2097 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2103 alu
.src
[0].sel
= ctx
->temp_reg
;
2104 alu
.src
[0].chan
= 0;
2107 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2112 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2113 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
2114 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
2116 alu
.src
[0].sel
= ctx
->temp_reg
;
2117 alu
.src
[0].chan
= 0;
2119 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2126 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Y
) {
2127 if (ctx
->bc
->chip_class
== CAYMAN
) {
2128 for (i
= 0 ; i
< 3; i
++) {
2129 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2130 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
2131 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2136 alu
.src
[0].sel
= ctx
->temp_reg
;
2137 alu
.src
[0].chan
= 0;
2140 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2145 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2146 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
2147 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
2149 alu
.src
[0].sel
= ctx
->temp_reg
;
2150 alu
.src
[0].chan
= 0;
2152 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2159 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Z
) {
2160 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2162 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2164 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
2166 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2167 alu
.src
[0].chan
= 0;
2171 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2177 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
2178 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2180 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2182 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
2184 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2185 alu
.src
[0].chan
= 0;
2189 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2197 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
2199 struct r600_bytecode_alu alu
;
2202 for (i
= 0; i
< 4; i
++) {
2203 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2204 alu
.inst
= ctx
->inst_info
->r600_opcode
;
2208 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2210 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
2211 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2214 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
2219 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2224 /* kill must be last in ALU */
2225 ctx
->bc
->force_add_cf
= 1;
2226 ctx
->shader
->uses_kill
= TRUE
;
2230 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
2232 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2233 struct r600_bytecode_alu alu
;
2236 /* tmp.x = max(src.y, 0.0) */
2237 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2238 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
2239 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 1);
2240 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
2241 alu
.src
[1].chan
= 1;
2243 alu
.dst
.sel
= ctx
->temp_reg
;
2248 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2252 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
2258 if (ctx
->bc
->chip_class
== CAYMAN
) {
2259 for (i
= 0; i
< 3; i
++) {
2260 /* tmp.z = log(tmp.x) */
2261 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2262 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
2263 alu
.src
[0].sel
= ctx
->temp_reg
;
2264 alu
.src
[0].chan
= 0;
2265 alu
.dst
.sel
= ctx
->temp_reg
;
2273 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2278 /* tmp.z = log(tmp.x) */
2279 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2280 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
2281 alu
.src
[0].sel
= ctx
->temp_reg
;
2282 alu
.src
[0].chan
= 0;
2283 alu
.dst
.sel
= ctx
->temp_reg
;
2287 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2292 chan
= alu
.dst
.chan
;
2295 /* tmp.x = amd MUL_LIT(tmp.z, src.w, src.x ) */
2296 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2297 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
2298 alu
.src
[0].sel
= sel
;
2299 alu
.src
[0].chan
= chan
;
2300 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], 3);
2301 r600_bytecode_src(&alu
.src
[2], &ctx
->src
[0], 0);
2302 alu
.dst
.sel
= ctx
->temp_reg
;
2307 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2311 if (ctx
->bc
->chip_class
== CAYMAN
) {
2312 for (i
= 0; i
< 3; i
++) {
2313 /* dst.z = exp(tmp.x) */
2314 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2315 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2316 alu
.src
[0].sel
= ctx
->temp_reg
;
2317 alu
.src
[0].chan
= 0;
2318 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2324 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2329 /* dst.z = exp(tmp.x) */
2330 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2331 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2332 alu
.src
[0].sel
= ctx
->temp_reg
;
2333 alu
.src
[0].chan
= 0;
2334 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
2336 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2343 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2344 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2345 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
2346 alu
.src
[0].chan
= 0;
2347 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
2348 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
2349 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2353 /* dst.y = max(src.x, 0.0) */
2354 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2355 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
2356 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
2357 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
2358 alu
.src
[1].chan
= 0;
2359 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
2360 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
2361 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2366 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2367 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2368 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2369 alu
.src
[0].chan
= 0;
2370 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
2371 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
2373 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2380 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
2382 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2383 struct r600_bytecode_alu alu
;
2386 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2389 * For state trackers other than OpenGL, we'll want to use
2390 * _RECIPSQRT_IEEE instead.
2392 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
2394 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
2395 r600_bytecode_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
2396 r600_bytecode_src_set_abs(&alu
.src
[i
]);
2398 alu
.dst
.sel
= ctx
->temp_reg
;
2401 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2404 /* replicate result */
2405 return tgsi_helper_tempx_replicate(ctx
);
2408 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
2410 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2411 struct r600_bytecode_alu alu
;
2414 for (i
= 0; i
< 4; i
++) {
2415 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2416 alu
.src
[0].sel
= ctx
->temp_reg
;
2417 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2419 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2420 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
2423 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2430 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
2432 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2433 struct r600_bytecode_alu alu
;
2436 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2437 alu
.inst
= ctx
->inst_info
->r600_opcode
;
2438 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
2439 r600_bytecode_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
2441 alu
.dst
.sel
= ctx
->temp_reg
;
2444 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2447 /* replicate result */
2448 return tgsi_helper_tempx_replicate(ctx
);
2451 static int cayman_pow(struct r600_shader_ctx
*ctx
)
2453 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2455 struct r600_bytecode_alu alu
;
2456 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
2458 for (i
= 0; i
< 3; i
++) {
2459 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2460 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2461 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
2462 alu
.dst
.sel
= ctx
->temp_reg
;
2467 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2473 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2474 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2475 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], 0);
2476 alu
.src
[1].sel
= ctx
->temp_reg
;
2477 alu
.dst
.sel
= ctx
->temp_reg
;
2480 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2484 for (i
= 0; i
< last_slot
; i
++) {
2485 /* POW(a,b) = EXP2(b * LOG2(a))*/
2486 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2487 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2488 alu
.src
[0].sel
= ctx
->temp_reg
;
2490 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2491 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
2492 if (i
== last_slot
- 1)
2494 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2501 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
2503 struct r600_bytecode_alu alu
;
2507 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2508 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2509 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
2510 alu
.dst
.sel
= ctx
->temp_reg
;
2513 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2517 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2518 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2519 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], 0);
2520 alu
.src
[1].sel
= ctx
->temp_reg
;
2521 alu
.dst
.sel
= ctx
->temp_reg
;
2524 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2527 /* POW(a,b) = EXP2(b * LOG2(a))*/
2528 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2529 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2530 alu
.src
[0].sel
= ctx
->temp_reg
;
2531 alu
.dst
.sel
= ctx
->temp_reg
;
2534 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2537 return tgsi_helper_tempx_replicate(ctx
);
2540 static int tgsi_divmod(struct r600_shader_ctx
*ctx
, int mod
, int signed_op
)
2542 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2543 struct r600_bytecode_alu alu
;
2545 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
2546 int tmp0
= ctx
->temp_reg
;
2547 int tmp1
= r600_get_temp(ctx
);
2548 int tmp2
= r600_get_temp(ctx
);
2549 int tmp3
= r600_get_temp(ctx
);
2552 * we need to represent src1 as src2*q + r, where q - quotient, r - remainder
2554 * 1. tmp0.x = rcp (src2) = 2^32/src2 + e, where e is rounding error
2555 * 2. tmp0.z = lo (tmp0.x * src2)
2556 * 3. tmp0.w = -tmp0.z
2557 * 4. tmp0.y = hi (tmp0.x * src2)
2558 * 5. tmp0.z = (tmp0.y == 0 ? tmp0.w : tmp0.z) = abs(lo(rcp*src2))
2559 * 6. tmp0.w = hi (tmp0.z * tmp0.x) = e, rounding error
2560 * 7. tmp1.x = tmp0.x - tmp0.w
2561 * 8. tmp1.y = tmp0.x + tmp0.w
2562 * 9. tmp0.x = (tmp0.y == 0 ? tmp1.y : tmp1.x)
2563 * 10. tmp0.z = hi(tmp0.x * src1) = q
2564 * 11. tmp0.y = lo (tmp0.z * src2) = src2*q = src1 - r
2566 * 12. tmp0.w = src1 - tmp0.y = r
2567 * 13. tmp1.x = tmp0.w >= src2 = r >= src2 (uint comparison)
2568 * 14. tmp1.y = src1 >= tmp0.y = r >= 0 (uint comparison)
2572 * 15. tmp1.z = tmp0.z + 1 = q + 1
2573 * 16. tmp1.w = tmp0.z - 1 = q - 1
2577 * 15. tmp1.z = tmp0.w - src2 = r - src2
2578 * 16. tmp1.w = tmp0.w + src2 = r + src2
2582 * 17. tmp1.x = tmp1.x & tmp1.y
2584 * DIV: 18. tmp0.z = tmp1.x==0 ? tmp0.z : tmp1.z
2585 * MOD: 18. tmp0.z = tmp1.x==0 ? tmp0.w : tmp1.z
2587 * 19. tmp0.z = tmp1.y==0 ? tmp1.w : tmp0.z
2588 * 20. dst = src2==0 ? MAX_UINT : tmp0.z
2592 * Same as unsigned, using abs values of the operands,
2593 * and fixing the sign of the result in the end.
2596 for (i
= 0; i
< 4; i
++) {
2597 if (!(write_mask
& (1<<i
)))
2602 /* tmp2.x = -src0 */
2603 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2604 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
2610 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2612 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
2615 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2618 /* tmp2.y = -src1 */
2619 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2620 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
2626 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2628 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2631 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2634 /* tmp2.z sign bit is set if src0 and src2 signs are different */
2635 /* it will be a sign of the quotient */
2638 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2639 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
);
2645 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
2646 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2649 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2653 /* tmp2.x = |src0| */
2654 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2655 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
2662 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
2663 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
2664 alu
.src
[2].sel
= tmp2
;
2665 alu
.src
[2].chan
= 0;
2668 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2671 /* tmp2.y = |src1| */
2672 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2673 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
2680 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
2681 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2682 alu
.src
[2].sel
= tmp2
;
2683 alu
.src
[2].chan
= 1;
2686 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2691 /* 1. tmp0.x = rcp_u (src2) = 2^32/src2 + e, where e is rounding error */
2692 if (ctx
->bc
->chip_class
== CAYMAN
) {
2693 /* tmp3.x = u2f(src2) */
2694 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2695 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
);
2702 alu
.src
[0].sel
= tmp2
;
2703 alu
.src
[0].chan
= 1;
2705 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
2709 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2712 /* tmp0.x = recip(tmp3.x) */
2713 for (j
= 0 ; j
< 3; j
++) {
2714 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2715 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
;
2719 alu
.dst
.write
= (j
== 0);
2721 alu
.src
[0].sel
= tmp3
;
2722 alu
.src
[0].chan
= 0;
2726 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2730 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2731 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2733 alu
.src
[0].sel
= tmp0
;
2734 alu
.src
[0].chan
= 0;
2736 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
2737 alu
.src
[1].value
= 0x4f800000;
2742 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2746 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2747 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
);
2753 alu
.src
[0].sel
= tmp3
;
2754 alu
.src
[0].chan
= 0;
2757 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2761 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2762 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_UINT
);
2769 alu
.src
[0].sel
= tmp2
;
2770 alu
.src
[0].chan
= 1;
2772 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
2776 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2780 /* 2. tmp0.z = lo (tmp0.x * src2) */
2781 if (ctx
->bc
->chip_class
== CAYMAN
) {
2782 for (j
= 0 ; j
< 4; j
++) {
2783 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2784 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
);
2788 alu
.dst
.write
= (j
== 2);
2790 alu
.src
[0].sel
= tmp0
;
2791 alu
.src
[0].chan
= 0;
2793 alu
.src
[1].sel
= tmp2
;
2794 alu
.src
[1].chan
= 1;
2796 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2799 alu
.last
= (j
== 3);
2800 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2804 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2805 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
);
2811 alu
.src
[0].sel
= tmp0
;
2812 alu
.src
[0].chan
= 0;
2814 alu
.src
[1].sel
= tmp2
;
2815 alu
.src
[1].chan
= 1;
2817 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2821 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2825 /* 3. tmp0.w = -tmp0.z */
2826 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2827 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
2833 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2834 alu
.src
[1].sel
= tmp0
;
2835 alu
.src
[1].chan
= 2;
2838 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2841 /* 4. tmp0.y = hi (tmp0.x * src2) */
2842 if (ctx
->bc
->chip_class
== CAYMAN
) {
2843 for (j
= 0 ; j
< 4; j
++) {
2844 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2845 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
2849 alu
.dst
.write
= (j
== 1);
2851 alu
.src
[0].sel
= tmp0
;
2852 alu
.src
[0].chan
= 0;
2855 alu
.src
[1].sel
= tmp2
;
2856 alu
.src
[1].chan
= 1;
2858 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2860 alu
.last
= (j
== 3);
2861 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2865 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2866 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
2872 alu
.src
[0].sel
= tmp0
;
2873 alu
.src
[0].chan
= 0;
2876 alu
.src
[1].sel
= tmp2
;
2877 alu
.src
[1].chan
= 1;
2879 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2883 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2887 /* 5. tmp0.z = (tmp0.y == 0 ? tmp0.w : tmp0.z) = abs(lo(rcp*src)) */
2888 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2889 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDE_INT
);
2896 alu
.src
[0].sel
= tmp0
;
2897 alu
.src
[0].chan
= 1;
2898 alu
.src
[1].sel
= tmp0
;
2899 alu
.src
[1].chan
= 3;
2900 alu
.src
[2].sel
= tmp0
;
2901 alu
.src
[2].chan
= 2;
2904 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2907 /* 6. tmp0.w = hi (tmp0.z * tmp0.x) = e, rounding error */
2908 if (ctx
->bc
->chip_class
== CAYMAN
) {
2909 for (j
= 0 ; j
< 4; j
++) {
2910 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2911 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
2915 alu
.dst
.write
= (j
== 3);
2917 alu
.src
[0].sel
= tmp0
;
2918 alu
.src
[0].chan
= 2;
2920 alu
.src
[1].sel
= tmp0
;
2921 alu
.src
[1].chan
= 0;
2923 alu
.last
= (j
== 3);
2924 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2928 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2929 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
2935 alu
.src
[0].sel
= tmp0
;
2936 alu
.src
[0].chan
= 2;
2938 alu
.src
[1].sel
= tmp0
;
2939 alu
.src
[1].chan
= 0;
2942 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2946 /* 7. tmp1.x = tmp0.x - tmp0.w */
2947 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2948 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
2954 alu
.src
[0].sel
= tmp0
;
2955 alu
.src
[0].chan
= 0;
2956 alu
.src
[1].sel
= tmp0
;
2957 alu
.src
[1].chan
= 3;
2960 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2963 /* 8. tmp1.y = tmp0.x + tmp0.w */
2964 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2965 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
2971 alu
.src
[0].sel
= tmp0
;
2972 alu
.src
[0].chan
= 0;
2973 alu
.src
[1].sel
= tmp0
;
2974 alu
.src
[1].chan
= 3;
2977 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2980 /* 9. tmp0.x = (tmp0.y == 0 ? tmp1.y : tmp1.x) */
2981 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2982 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDE_INT
);
2989 alu
.src
[0].sel
= tmp0
;
2990 alu
.src
[0].chan
= 1;
2991 alu
.src
[1].sel
= tmp1
;
2992 alu
.src
[1].chan
= 1;
2993 alu
.src
[2].sel
= tmp1
;
2994 alu
.src
[2].chan
= 0;
2997 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3000 /* 10. tmp0.z = hi(tmp0.x * src1) = q */
3001 if (ctx
->bc
->chip_class
== CAYMAN
) {
3002 for (j
= 0 ; j
< 4; j
++) {
3003 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3004 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
3008 alu
.dst
.write
= (j
== 2);
3010 alu
.src
[0].sel
= tmp0
;
3011 alu
.src
[0].chan
= 0;
3014 alu
.src
[1].sel
= tmp2
;
3015 alu
.src
[1].chan
= 0;
3017 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3020 alu
.last
= (j
== 3);
3021 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3025 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3026 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
3032 alu
.src
[0].sel
= tmp0
;
3033 alu
.src
[0].chan
= 0;
3036 alu
.src
[1].sel
= tmp2
;
3037 alu
.src
[1].chan
= 0;
3039 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3043 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3047 /* 11. tmp0.y = lo (src2 * tmp0.z) = src2*q = src1 - r */
3048 if (ctx
->bc
->chip_class
== CAYMAN
) {
3049 for (j
= 0 ; j
< 4; j
++) {
3050 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3051 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
);
3055 alu
.dst
.write
= (j
== 1);
3058 alu
.src
[0].sel
= tmp2
;
3059 alu
.src
[0].chan
= 1;
3061 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
3064 alu
.src
[1].sel
= tmp0
;
3065 alu
.src
[1].chan
= 2;
3067 alu
.last
= (j
== 3);
3068 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3072 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3073 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
);
3080 alu
.src
[0].sel
= tmp2
;
3081 alu
.src
[0].chan
= 1;
3083 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
3086 alu
.src
[1].sel
= tmp0
;
3087 alu
.src
[1].chan
= 2;
3090 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3094 /* 12. tmp0.w = src1 - tmp0.y = r */
3095 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3096 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
3103 alu
.src
[0].sel
= tmp2
;
3104 alu
.src
[0].chan
= 0;
3106 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3109 alu
.src
[1].sel
= tmp0
;
3110 alu
.src
[1].chan
= 1;
3113 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3116 /* 13. tmp1.x = tmp0.w >= src2 = r >= src2 */
3117 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3118 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
);
3124 alu
.src
[0].sel
= tmp0
;
3125 alu
.src
[0].chan
= 3;
3127 alu
.src
[1].sel
= tmp2
;
3128 alu
.src
[1].chan
= 1;
3130 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
3134 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3137 /* 14. tmp1.y = src1 >= tmp0.y = r >= 0 */
3138 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3139 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
);
3146 alu
.src
[0].sel
= tmp2
;
3147 alu
.src
[0].chan
= 0;
3149 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3152 alu
.src
[1].sel
= tmp0
;
3153 alu
.src
[1].chan
= 1;
3156 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3159 if (mod
) { /* UMOD */
3161 /* 15. tmp1.z = tmp0.w - src2 = r - src2 */
3162 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3163 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
3169 alu
.src
[0].sel
= tmp0
;
3170 alu
.src
[0].chan
= 3;
3173 alu
.src
[1].sel
= tmp2
;
3174 alu
.src
[1].chan
= 1;
3176 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
3180 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3183 /* 16. tmp1.w = tmp0.w + src2 = r + src2 */
3184 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3185 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
3191 alu
.src
[0].sel
= tmp0
;
3192 alu
.src
[0].chan
= 3;
3194 alu
.src
[1].sel
= tmp2
;
3195 alu
.src
[1].chan
= 1;
3197 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
3201 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3206 /* 15. tmp1.z = tmp0.z + 1 = q + 1 DIV */
3207 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3208 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
3214 alu
.src
[0].sel
= tmp0
;
3215 alu
.src
[0].chan
= 2;
3216 alu
.src
[1].sel
= V_SQ_ALU_SRC_1_INT
;
3219 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3222 /* 16. tmp1.w = tmp0.z - 1 = q - 1 */
3223 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3224 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
3230 alu
.src
[0].sel
= tmp0
;
3231 alu
.src
[0].chan
= 2;
3232 alu
.src
[1].sel
= V_SQ_ALU_SRC_M_1_INT
;
3235 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3240 /* 17. tmp1.x = tmp1.x & tmp1.y */
3241 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3242 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
);
3248 alu
.src
[0].sel
= tmp1
;
3249 alu
.src
[0].chan
= 0;
3250 alu
.src
[1].sel
= tmp1
;
3251 alu
.src
[1].chan
= 1;
3254 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3257 /* 18. tmp0.z = tmp1.x==0 ? tmp0.z : tmp1.z DIV */
3258 /* 18. tmp0.z = tmp1.x==0 ? tmp0.w : tmp1.z MOD */
3259 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3260 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDE_INT
);
3267 alu
.src
[0].sel
= tmp1
;
3268 alu
.src
[0].chan
= 0;
3269 alu
.src
[1].sel
= tmp0
;
3270 alu
.src
[1].chan
= mod
? 3 : 2;
3271 alu
.src
[2].sel
= tmp1
;
3272 alu
.src
[2].chan
= 2;
3275 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3278 /* 19. tmp0.z = tmp1.y==0 ? tmp1.w : tmp0.z */
3279 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3280 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDE_INT
);
3288 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3291 alu
.src
[0].sel
= tmp1
;
3292 alu
.src
[0].chan
= 1;
3293 alu
.src
[1].sel
= tmp1
;
3294 alu
.src
[1].chan
= 3;
3295 alu
.src
[2].sel
= tmp0
;
3296 alu
.src
[2].chan
= 2;
3299 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3304 /* fix the sign of the result */
3308 /* tmp0.x = -tmp0.z */
3309 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3310 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
3316 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
3317 alu
.src
[1].sel
= tmp0
;
3318 alu
.src
[1].chan
= 2;
3321 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3324 /* sign of the remainder is the same as the sign of src0 */
3325 /* tmp0.x = src0>=0 ? tmp0.z : tmp0.x */
3326 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3327 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
3330 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3332 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3333 alu
.src
[1].sel
= tmp0
;
3334 alu
.src
[1].chan
= 2;
3335 alu
.src
[2].sel
= tmp0
;
3336 alu
.src
[2].chan
= 0;
3339 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3344 /* tmp0.x = -tmp0.z */
3345 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3346 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
3352 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
3353 alu
.src
[1].sel
= tmp0
;
3354 alu
.src
[1].chan
= 2;
3357 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3360 /* fix the quotient sign (same as the sign of src0*src1) */
3361 /* tmp0.x = tmp2.z>=0 ? tmp0.z : tmp0.x */
3362 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3363 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
3366 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3368 alu
.src
[0].sel
= tmp2
;
3369 alu
.src
[0].chan
= 2;
3370 alu
.src
[1].sel
= tmp0
;
3371 alu
.src
[1].chan
= 2;
3372 alu
.src
[2].sel
= tmp0
;
3373 alu
.src
[2].chan
= 0;
3376 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3384 static int tgsi_udiv(struct r600_shader_ctx
*ctx
)
3386 return tgsi_divmod(ctx
, 0, 0);
3389 static int tgsi_umod(struct r600_shader_ctx
*ctx
)
3391 return tgsi_divmod(ctx
, 1, 0);
3394 static int tgsi_idiv(struct r600_shader_ctx
*ctx
)
3396 return tgsi_divmod(ctx
, 0, 1);
3399 static int tgsi_imod(struct r600_shader_ctx
*ctx
)
3401 return tgsi_divmod(ctx
, 1, 1);
3405 static int tgsi_f2i(struct r600_shader_ctx
*ctx
)
3407 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3408 struct r600_bytecode_alu alu
;
3410 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
3411 int last_inst
= tgsi_last_instruction(write_mask
);
3413 for (i
= 0; i
< 4; i
++) {
3414 if (!(write_mask
& (1<<i
)))
3417 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3418 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
);
3420 alu
.dst
.sel
= ctx
->temp_reg
;
3424 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3427 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3432 for (i
= 0; i
< 4; i
++) {
3433 if (!(write_mask
& (1<<i
)))
3436 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3437 alu
.inst
= ctx
->inst_info
->r600_opcode
;
3439 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3441 alu
.src
[0].sel
= ctx
->temp_reg
;
3442 alu
.src
[0].chan
= i
;
3444 if (i
== last_inst
|| alu
.inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
)
3446 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3454 static int tgsi_iabs(struct r600_shader_ctx
*ctx
)
3456 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3457 struct r600_bytecode_alu alu
;
3459 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
3460 int last_inst
= tgsi_last_instruction(write_mask
);
3463 for (i
= 0; i
< 4; i
++) {
3464 if (!(write_mask
& (1<<i
)))
3467 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3468 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
3470 alu
.dst
.sel
= ctx
->temp_reg
;
3474 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3475 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
3479 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3484 /* dst = (src >= 0 ? src : tmp) */
3485 for (i
= 0; i
< 4; i
++) {
3486 if (!(write_mask
& (1<<i
)))
3489 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3490 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
3494 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3496 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3497 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3498 alu
.src
[2].sel
= ctx
->temp_reg
;
3499 alu
.src
[2].chan
= i
;
3503 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3510 static int tgsi_issg(struct r600_shader_ctx
*ctx
)
3512 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3513 struct r600_bytecode_alu alu
;
3515 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
3516 int last_inst
= tgsi_last_instruction(write_mask
);
3518 /* tmp = (src >= 0 ? src : -1) */
3519 for (i
= 0; i
< 4; i
++) {
3520 if (!(write_mask
& (1<<i
)))
3523 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3524 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
3527 alu
.dst
.sel
= ctx
->temp_reg
;
3531 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3532 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3533 alu
.src
[2].sel
= V_SQ_ALU_SRC_M_1_INT
;
3537 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3542 /* dst = (tmp > 0 ? 1 : tmp) */
3543 for (i
= 0; i
< 4; i
++) {
3544 if (!(write_mask
& (1<<i
)))
3547 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3548 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT_INT
);
3552 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3554 alu
.src
[0].sel
= ctx
->temp_reg
;
3555 alu
.src
[0].chan
= i
;
3557 alu
.src
[1].sel
= V_SQ_ALU_SRC_1_INT
;
3559 alu
.src
[2].sel
= ctx
->temp_reg
;
3560 alu
.src
[2].chan
= i
;
3564 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3573 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
3575 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3576 struct r600_bytecode_alu alu
;
3579 /* tmp = (src > 0 ? 1 : src) */
3580 for (i
= 0; i
< 4; i
++) {
3581 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3582 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
3585 alu
.dst
.sel
= ctx
->temp_reg
;
3588 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3589 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
3590 r600_bytecode_src(&alu
.src
[2], &ctx
->src
[0], i
);
3594 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3599 /* dst = (-tmp > 0 ? -1 : tmp) */
3600 for (i
= 0; i
< 4; i
++) {
3601 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3602 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
3604 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3606 alu
.src
[0].sel
= ctx
->temp_reg
;
3607 alu
.src
[0].chan
= i
;
3610 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
3613 alu
.src
[2].sel
= ctx
->temp_reg
;
3614 alu
.src
[2].chan
= i
;
3618 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3625 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
3627 struct r600_bytecode_alu alu
;
3630 for (i
= 0; i
< 4; i
++) {
3631 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3632 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
3633 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
3636 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
3637 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3638 alu
.src
[0].sel
= ctx
->temp_reg
;
3639 alu
.src
[0].chan
= i
;
3644 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3651 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
3653 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3654 struct r600_bytecode_alu alu
;
3656 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
3658 for (i
= 0; i
< lasti
+ 1; i
++) {
3659 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
3662 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3663 alu
.inst
= ctx
->inst_info
->r600_opcode
;
3664 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
3665 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
3668 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3675 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3682 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
3684 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3685 struct r600_bytecode_alu alu
;
3688 for (i
= 0; i
< 4; i
++) {
3689 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3690 alu
.inst
= ctx
->inst_info
->r600_opcode
;
3691 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
3692 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
3695 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3697 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
3698 /* handle some special cases */
3699 switch (ctx
->inst_info
->tgsi_opcode
) {
3700 case TGSI_OPCODE_DP2
:
3702 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
3703 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
3706 case TGSI_OPCODE_DP3
:
3708 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
3709 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
3712 case TGSI_OPCODE_DPH
:
3714 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
3715 alu
.src
[0].chan
= 0;
3725 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3732 static inline boolean
tgsi_tex_src_requires_loading(struct r600_shader_ctx
*ctx
,
3735 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3736 return (inst
->Src
[index
].Register
.File
!= TGSI_FILE_TEMPORARY
&&
3737 inst
->Src
[index
].Register
.File
!= TGSI_FILE_INPUT
&&
3738 inst
->Src
[index
].Register
.File
!= TGSI_FILE_OUTPUT
) ||
3739 ctx
->src
[index
].neg
|| ctx
->src
[index
].abs
;
3742 static inline unsigned tgsi_tex_get_src_gpr(struct r600_shader_ctx
*ctx
,
3745 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3746 return ctx
->file_offset
[inst
->Src
[index
].Register
.File
] + inst
->Src
[index
].Register
.Index
;
3749 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
3751 static float one_point_five
= 1.5f
;
3752 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3753 struct r600_bytecode_tex tex
;
3754 struct r600_bytecode_alu alu
;
3758 /* Texture fetch instructions can only use gprs as source.
3759 * Also they cannot negate the source or take the absolute value */
3760 const boolean src_requires_loading
= inst
->Instruction
.Opcode
!= TGSI_OPCODE_TXQ_LZ
&&
3761 tgsi_tex_src_requires_loading(ctx
, 0);
3762 boolean src_loaded
= FALSE
;
3763 unsigned sampler_src_reg
= inst
->Instruction
.Opcode
== TGSI_OPCODE_TXQ_LZ
? 0 : 1;
3764 uint8_t offset_x
= 0, offset_y
= 0, offset_z
= 0;
3766 src_gpr
= tgsi_tex_get_src_gpr(ctx
, 0);
3768 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXF
) {
3769 /* get offset values */
3770 if (inst
->Texture
.NumOffsets
) {
3771 assert(inst
->Texture
.NumOffsets
== 1);
3773 offset_x
= ctx
->literals
[inst
->TexOffsets
[0].Index
+ inst
->TexOffsets
[0].SwizzleX
] << 1;
3774 offset_y
= ctx
->literals
[inst
->TexOffsets
[0].Index
+ inst
->TexOffsets
[0].SwizzleY
] << 1;
3775 offset_z
= ctx
->literals
[inst
->TexOffsets
[0].Index
+ inst
->TexOffsets
[0].SwizzleZ
] << 1;
3777 } else if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXD
) {
3778 /* TGSI moves the sampler to src reg 3 for TXD */
3779 sampler_src_reg
= 3;
3781 for (i
= 1; i
< 3; i
++) {
3782 /* set gradients h/v */
3783 memset(&tex
, 0, sizeof(struct r600_bytecode_tex
));
3784 tex
.inst
= (i
== 1) ? SQ_TEX_INST_SET_GRADIENTS_H
:
3785 SQ_TEX_INST_SET_GRADIENTS_V
;
3786 tex
.sampler_id
= tgsi_tex_get_src_gpr(ctx
, sampler_src_reg
);
3787 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
3789 if (tgsi_tex_src_requires_loading(ctx
, i
)) {
3790 tex
.src_gpr
= r600_get_temp(ctx
);
3796 for (j
= 0; j
< 4; j
++) {
3797 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3798 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
3799 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[i
], j
);
3800 alu
.dst
.sel
= tex
.src_gpr
;
3805 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3811 tex
.src_gpr
= tgsi_tex_get_src_gpr(ctx
, i
);
3812 tex
.src_sel_x
= ctx
->src
[i
].swizzle
[0];
3813 tex
.src_sel_y
= ctx
->src
[i
].swizzle
[1];
3814 tex
.src_sel_z
= ctx
->src
[i
].swizzle
[2];
3815 tex
.src_sel_w
= ctx
->src
[i
].swizzle
[3];
3816 tex
.src_rel
= ctx
->src
[i
].rel
;
3818 tex
.dst_gpr
= ctx
->temp_reg
; /* just to avoid confusing the asm scheduler */
3819 tex
.dst_sel_x
= tex
.dst_sel_y
= tex
.dst_sel_z
= tex
.dst_sel_w
= 7;
3820 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
3821 tex
.coord_type_x
= 1;
3822 tex
.coord_type_y
= 1;
3823 tex
.coord_type_z
= 1;
3824 tex
.coord_type_w
= 1;
3826 r
= r600_bytecode_add_tex(ctx
->bc
, &tex
);
3830 } else if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
3832 /* Add perspective divide */
3833 if (ctx
->bc
->chip_class
== CAYMAN
) {
3835 for (i
= 0; i
< 3; i
++) {
3836 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3837 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
3838 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 3);
3840 alu
.dst
.sel
= ctx
->temp_reg
;
3846 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3853 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3854 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
3855 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 3);
3857 alu
.dst
.sel
= ctx
->temp_reg
;
3858 alu
.dst
.chan
= out_chan
;
3861 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3866 for (i
= 0; i
< 3; i
++) {
3867 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3868 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
3869 alu
.src
[0].sel
= ctx
->temp_reg
;
3870 alu
.src
[0].chan
= out_chan
;
3871 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3872 alu
.dst
.sel
= ctx
->temp_reg
;
3875 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3879 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3880 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
3881 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
3882 alu
.src
[0].chan
= 0;
3883 alu
.dst
.sel
= ctx
->temp_reg
;
3887 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3891 src_gpr
= ctx
->temp_reg
;
3894 if ((inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
||
3895 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE
) &&
3896 inst
->Instruction
.Opcode
!= TGSI_OPCODE_TXQ
&&
3897 inst
->Instruction
.Opcode
!= TGSI_OPCODE_TXQ_LZ
) {
3899 static const unsigned src0_swizzle
[] = {2, 2, 0, 1};
3900 static const unsigned src1_swizzle
[] = {1, 0, 2, 2};
3902 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
3903 for (i
= 0; i
< 4; i
++) {
3904 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3905 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
3906 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], src0_swizzle
[i
]);
3907 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], src1_swizzle
[i
]);
3908 alu
.dst
.sel
= ctx
->temp_reg
;
3913 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3918 /* tmp1.z = RCP_e(|tmp1.z|) */
3919 if (ctx
->bc
->chip_class
== CAYMAN
) {
3920 for (i
= 0; i
< 3; i
++) {
3921 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3922 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
3923 alu
.src
[0].sel
= ctx
->temp_reg
;
3924 alu
.src
[0].chan
= 2;
3926 alu
.dst
.sel
= ctx
->temp_reg
;
3932 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3937 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3938 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
3939 alu
.src
[0].sel
= ctx
->temp_reg
;
3940 alu
.src
[0].chan
= 2;
3942 alu
.dst
.sel
= ctx
->temp_reg
;
3946 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3951 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
3952 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
3953 * muladd has no writemask, have to use another temp
3955 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3956 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
3959 alu
.src
[0].sel
= ctx
->temp_reg
;
3960 alu
.src
[0].chan
= 0;
3961 alu
.src
[1].sel
= ctx
->temp_reg
;
3962 alu
.src
[1].chan
= 2;
3964 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
3965 alu
.src
[2].chan
= 0;
3966 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
3968 alu
.dst
.sel
= ctx
->temp_reg
;
3972 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3976 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3977 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
3980 alu
.src
[0].sel
= ctx
->temp_reg
;
3981 alu
.src
[0].chan
= 1;
3982 alu
.src
[1].sel
= ctx
->temp_reg
;
3983 alu
.src
[1].chan
= 2;
3985 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
3986 alu
.src
[2].chan
= 0;
3987 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
3989 alu
.dst
.sel
= ctx
->temp_reg
;
3994 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3997 /* write initial W value into Z component */
3998 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE
) {
3999 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4000 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
4001 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 3);
4002 alu
.dst
.sel
= ctx
->temp_reg
;
4006 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4011 src_gpr
= ctx
->temp_reg
;
4014 if (src_requires_loading
&& !src_loaded
) {
4015 for (i
= 0; i
< 4; i
++) {
4016 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4017 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
4018 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
4019 alu
.dst
.sel
= ctx
->temp_reg
;
4024 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4029 src_gpr
= ctx
->temp_reg
;
4032 opcode
= ctx
->inst_info
->r600_opcode
;
4033 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
||
4034 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
||
4035 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWRECT
||
4036 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE
||
4037 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D_ARRAY
||
4038 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D_ARRAY
) {
4040 case SQ_TEX_INST_SAMPLE
:
4041 opcode
= SQ_TEX_INST_SAMPLE_C
;
4043 case SQ_TEX_INST_SAMPLE_L
:
4044 opcode
= SQ_TEX_INST_SAMPLE_C_L
;
4046 case SQ_TEX_INST_SAMPLE_LB
:
4047 opcode
= SQ_TEX_INST_SAMPLE_C_LB
;
4049 case SQ_TEX_INST_SAMPLE_G
:
4050 opcode
= SQ_TEX_INST_SAMPLE_C_G
;
4055 memset(&tex
, 0, sizeof(struct r600_bytecode_tex
));
4058 tex
.sampler_id
= tgsi_tex_get_src_gpr(ctx
, sampler_src_reg
);
4059 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
4060 tex
.src_gpr
= src_gpr
;
4061 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
4062 tex
.dst_sel_x
= (inst
->Dst
[0].Register
.WriteMask
& 1) ? 0 : 7;
4063 tex
.dst_sel_y
= (inst
->Dst
[0].Register
.WriteMask
& 2) ? 1 : 7;
4064 tex
.dst_sel_z
= (inst
->Dst
[0].Register
.WriteMask
& 4) ? 2 : 7;
4065 tex
.dst_sel_w
= (inst
->Dst
[0].Register
.WriteMask
& 8) ? 3 : 7;
4067 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXQ_LZ
) {
4072 } else if (src_loaded
) {
4078 tex
.src_sel_x
= ctx
->src
[0].swizzle
[0];
4079 tex
.src_sel_y
= ctx
->src
[0].swizzle
[1];
4080 tex
.src_sel_z
= ctx
->src
[0].swizzle
[2];
4081 tex
.src_sel_w
= ctx
->src
[0].swizzle
[3];
4082 tex
.src_rel
= ctx
->src
[0].rel
;
4085 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
4091 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE
) {
4095 tex
.src_sel_w
= 2; /* route Z compare value into W */
4098 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
&&
4099 inst
->Texture
.Texture
!= TGSI_TEXTURE_SHADOWRECT
) {
4100 tex
.coord_type_x
= 1;
4101 tex
.coord_type_y
= 1;
4103 tex
.coord_type_z
= 1;
4104 tex
.coord_type_w
= 1;
4106 tex
.offset_x
= offset_x
;
4107 tex
.offset_y
= offset_y
;
4108 tex
.offset_z
= offset_z
;
4110 /* Put the depth for comparison in W.
4111 * TGSI_TEXTURE_SHADOW2D_ARRAY already has the depth in W.
4112 * Some instructions expect the depth in Z. */
4113 if ((inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
||
4114 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
||
4115 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWRECT
||
4116 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D_ARRAY
) &&
4117 opcode
!= SQ_TEX_INST_SAMPLE_C_L
&&
4118 opcode
!= SQ_TEX_INST_SAMPLE_C_LB
) {
4119 tex
.src_sel_w
= tex
.src_sel_z
;
4122 if (inst
->Texture
.Texture
== TGSI_TEXTURE_1D_ARRAY
||
4123 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D_ARRAY
) {
4124 if (opcode
== SQ_TEX_INST_SAMPLE_C_L
||
4125 opcode
== SQ_TEX_INST_SAMPLE_C_LB
) {
4126 /* the array index is read from Y */
4127 tex
.coord_type_y
= 0;
4129 /* the array index is read from Z */
4130 tex
.coord_type_z
= 0;
4131 tex
.src_sel_z
= tex
.src_sel_y
;
4133 } else if (inst
->Texture
.Texture
== TGSI_TEXTURE_2D_ARRAY
||
4134 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D_ARRAY
)
4135 /* the array index is read from Z */
4136 tex
.coord_type_z
= 0;
4138 r
= r600_bytecode_add_tex(ctx
->bc
, &tex
);
4142 /* add shadow ambient support - gallium doesn't do it yet */
4146 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
4148 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4149 struct r600_bytecode_alu alu
;
4150 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
4154 /* optimize if it's just an equal balance */
4155 if (ctx
->src
[0].sel
== V_SQ_ALU_SRC_0_5
) {
4156 for (i
= 0; i
< lasti
+ 1; i
++) {
4157 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
4160 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4161 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
4162 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
4163 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
4165 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4170 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4178 for (i
= 0; i
< lasti
+ 1; i
++) {
4179 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
4182 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4183 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
4184 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
4185 alu
.src
[0].chan
= 0;
4186 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
4187 r600_bytecode_src_toggle_neg(&alu
.src
[1]);
4188 alu
.dst
.sel
= ctx
->temp_reg
;
4194 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4199 /* (1 - src0) * src2 */
4200 for (i
= 0; i
< lasti
+ 1; i
++) {
4201 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
4204 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4205 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
4206 alu
.src
[0].sel
= ctx
->temp_reg
;
4207 alu
.src
[0].chan
= i
;
4208 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
4209 alu
.dst
.sel
= ctx
->temp_reg
;
4215 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4220 /* src0 * src1 + (1 - src0) * src2 */
4221 for (i
= 0; i
< lasti
+ 1; i
++) {
4222 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
4225 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4226 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
4228 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
4229 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
4230 alu
.src
[2].sel
= ctx
->temp_reg
;
4231 alu
.src
[2].chan
= i
;
4233 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4238 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4245 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
4247 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4248 struct r600_bytecode_alu alu
;
4250 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
4252 for (i
= 0; i
< lasti
+ 1; i
++) {
4253 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
4256 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4257 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
4258 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
4259 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
4260 r600_bytecode_src(&alu
.src
[2], &ctx
->src
[1], i
);
4261 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4267 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4274 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
4276 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4277 static const unsigned int src0_swizzle
[] = {2, 0, 1};
4278 static const unsigned int src1_swizzle
[] = {1, 2, 0};
4279 struct r600_bytecode_alu alu
;
4280 uint32_t use_temp
= 0;
4283 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
4286 for (i
= 0; i
< 4; i
++) {
4287 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4288 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
4290 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], src0_swizzle
[i
]);
4291 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], src1_swizzle
[i
]);
4293 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
4294 alu
.src
[0].chan
= i
;
4295 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
4296 alu
.src
[1].chan
= i
;
4299 alu
.dst
.sel
= ctx
->temp_reg
;
4305 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4310 for (i
= 0; i
< 4; i
++) {
4311 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4312 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
4315 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], src1_swizzle
[i
]);
4316 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], src0_swizzle
[i
]);
4318 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
4319 alu
.src
[0].chan
= i
;
4320 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
4321 alu
.src
[1].chan
= i
;
4324 alu
.src
[2].sel
= ctx
->temp_reg
;
4326 alu
.src
[2].chan
= i
;
4329 alu
.dst
.sel
= ctx
->temp_reg
;
4331 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4337 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4342 return tgsi_helper_copy(ctx
, inst
);
4346 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
4348 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4349 struct r600_bytecode_alu alu
;
4353 /* result.x = 2^floor(src); */
4354 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
4355 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4357 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
4358 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4360 alu
.dst
.sel
= ctx
->temp_reg
;
4364 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4368 if (ctx
->bc
->chip_class
== CAYMAN
) {
4369 for (i
= 0; i
< 3; i
++) {
4370 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4371 alu
.src
[0].sel
= ctx
->temp_reg
;
4372 alu
.src
[0].chan
= 0;
4374 alu
.dst
.sel
= ctx
->temp_reg
;
4380 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4385 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4386 alu
.src
[0].sel
= ctx
->temp_reg
;
4387 alu
.src
[0].chan
= 0;
4389 alu
.dst
.sel
= ctx
->temp_reg
;
4393 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4399 /* result.y = tmp - floor(tmp); */
4400 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
4401 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4403 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
4404 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4406 alu
.dst
.sel
= ctx
->temp_reg
;
4408 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4417 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4422 /* result.z = RoughApprox2ToX(tmp);*/
4423 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
4424 if (ctx
->bc
->chip_class
== CAYMAN
) {
4425 for (i
= 0; i
< 3; i
++) {
4426 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4427 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4428 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4430 alu
.dst
.sel
= ctx
->temp_reg
;
4437 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4442 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4443 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4444 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4446 alu
.dst
.sel
= ctx
->temp_reg
;
4452 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4458 /* result.w = 1.0;*/
4459 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
4460 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4462 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
4463 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
4464 alu
.src
[0].chan
= 0;
4466 alu
.dst
.sel
= ctx
->temp_reg
;
4470 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4474 return tgsi_helper_copy(ctx
, inst
);
4477 static int tgsi_log(struct r600_shader_ctx
*ctx
)
4479 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4480 struct r600_bytecode_alu alu
;
4484 /* result.x = floor(log2(|src|)); */
4485 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
4486 if (ctx
->bc
->chip_class
== CAYMAN
) {
4487 for (i
= 0; i
< 3; i
++) {
4488 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4490 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
4491 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4492 r600_bytecode_src_set_abs(&alu
.src
[0]);
4494 alu
.dst
.sel
= ctx
->temp_reg
;
4500 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4506 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4508 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
4509 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4510 r600_bytecode_src_set_abs(&alu
.src
[0]);
4512 alu
.dst
.sel
= ctx
->temp_reg
;
4516 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4521 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
4522 alu
.src
[0].sel
= ctx
->temp_reg
;
4523 alu
.src
[0].chan
= 0;
4525 alu
.dst
.sel
= ctx
->temp_reg
;
4530 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4535 /* result.y = |src.x| / (2 ^ floor(log2(|src.x|))); */
4536 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
4538 if (ctx
->bc
->chip_class
== CAYMAN
) {
4539 for (i
= 0; i
< 3; i
++) {
4540 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4542 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
4543 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4544 r600_bytecode_src_set_abs(&alu
.src
[0]);
4546 alu
.dst
.sel
= ctx
->temp_reg
;
4553 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4558 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4560 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
4561 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4562 r600_bytecode_src_set_abs(&alu
.src
[0]);
4564 alu
.dst
.sel
= ctx
->temp_reg
;
4569 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4574 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4576 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
4577 alu
.src
[0].sel
= ctx
->temp_reg
;
4578 alu
.src
[0].chan
= 1;
4580 alu
.dst
.sel
= ctx
->temp_reg
;
4585 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4589 if (ctx
->bc
->chip_class
== CAYMAN
) {
4590 for (i
= 0; i
< 3; i
++) {
4591 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4592 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4593 alu
.src
[0].sel
= ctx
->temp_reg
;
4594 alu
.src
[0].chan
= 1;
4596 alu
.dst
.sel
= ctx
->temp_reg
;
4603 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4608 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4609 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4610 alu
.src
[0].sel
= ctx
->temp_reg
;
4611 alu
.src
[0].chan
= 1;
4613 alu
.dst
.sel
= ctx
->temp_reg
;
4618 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4623 if (ctx
->bc
->chip_class
== CAYMAN
) {
4624 for (i
= 0; i
< 3; i
++) {
4625 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4626 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
4627 alu
.src
[0].sel
= ctx
->temp_reg
;
4628 alu
.src
[0].chan
= 1;
4630 alu
.dst
.sel
= ctx
->temp_reg
;
4637 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4642 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4643 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
4644 alu
.src
[0].sel
= ctx
->temp_reg
;
4645 alu
.src
[0].chan
= 1;
4647 alu
.dst
.sel
= ctx
->temp_reg
;
4652 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4657 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4659 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
4661 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4662 r600_bytecode_src_set_abs(&alu
.src
[0]);
4664 alu
.src
[1].sel
= ctx
->temp_reg
;
4665 alu
.src
[1].chan
= 1;
4667 alu
.dst
.sel
= ctx
->temp_reg
;
4672 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4677 /* result.z = log2(|src|);*/
4678 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
4679 if (ctx
->bc
->chip_class
== CAYMAN
) {
4680 for (i
= 0; i
< 3; i
++) {
4681 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4683 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
4684 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4685 r600_bytecode_src_set_abs(&alu
.src
[0]);
4687 alu
.dst
.sel
= ctx
->temp_reg
;
4694 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4699 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4701 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
4702 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4703 r600_bytecode_src_set_abs(&alu
.src
[0]);
4705 alu
.dst
.sel
= ctx
->temp_reg
;
4710 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4716 /* result.w = 1.0; */
4717 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
4718 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4720 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
4721 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
4722 alu
.src
[0].chan
= 0;
4724 alu
.dst
.sel
= ctx
->temp_reg
;
4729 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4734 return tgsi_helper_copy(ctx
, inst
);
4737 static int tgsi_eg_arl(struct r600_shader_ctx
*ctx
)
4739 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4740 struct r600_bytecode_alu alu
;
4743 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4745 switch (inst
->Instruction
.Opcode
) {
4746 case TGSI_OPCODE_ARL
:
4747 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR
;
4749 case TGSI_OPCODE_ARR
:
4750 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
4752 case TGSI_OPCODE_UARL
:
4753 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
4760 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4762 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
4764 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4768 ctx
->bc
->ar_loaded
= 0;
4771 static int tgsi_r600_arl(struct r600_shader_ctx
*ctx
)
4773 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4774 struct r600_bytecode_alu alu
;
4777 switch (inst
->Instruction
.Opcode
) {
4778 case TGSI_OPCODE_ARL
:
4779 memset(&alu
, 0, sizeof(alu
));
4780 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
;
4781 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4782 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
4786 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
4789 memset(&alu
, 0, sizeof(alu
));
4790 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
4791 alu
.src
[0].sel
= ctx
->bc
->ar_reg
;
4792 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
4796 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
4799 case TGSI_OPCODE_ARR
:
4800 memset(&alu
, 0, sizeof(alu
));
4801 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
4802 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4803 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
4807 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
4810 case TGSI_OPCODE_UARL
:
4811 memset(&alu
, 0, sizeof(alu
));
4812 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
4813 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4814 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
4818 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
4826 ctx
->bc
->ar_loaded
= 0;
4830 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
4832 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4833 struct r600_bytecode_alu alu
;
4836 for (i
= 0; i
< 4; i
++) {
4837 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4839 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
4840 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4842 if (i
== 0 || i
== 3) {
4843 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
4845 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
4848 if (i
== 0 || i
== 2) {
4849 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
4851 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
4855 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4862 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
4864 struct r600_bytecode_alu alu
;
4867 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4869 alu
.execute_mask
= 1;
4870 alu
.update_pred
= 1;
4872 alu
.dst
.sel
= ctx
->temp_reg
;
4876 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4877 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
4878 alu
.src
[1].chan
= 0;
4882 r
= r600_bytecode_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
4888 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
4890 unsigned force_pop
= ctx
->bc
->force_add_cf
;
4894 if (ctx
->bc
->cf_last
) {
4895 if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
))
4897 else if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
))
4902 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
);
4903 ctx
->bc
->force_add_cf
= 1;
4904 } else if (alu_pop
== 2) {
4905 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
);
4906 ctx
->bc
->force_add_cf
= 1;
4913 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
4914 ctx
->bc
->cf_last
->pop_count
= pops
;
4915 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
4921 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
4925 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
4929 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
4932 /* TOODO : for 16 vp asic should -= 2; */
4933 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
4938 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
4940 if (check_max_only
) {
4953 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
4954 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
4955 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
4956 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
4962 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
4966 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
4969 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
4973 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
4974 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
4975 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
4976 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
4980 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
4982 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
4984 sp
->mid
= realloc((void *)sp
->mid
,
4985 sizeof(struct r600_bytecode_cf
*) * (sp
->num_mid
+ 1));
4986 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
4990 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
4993 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
4994 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
4997 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
4999 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
5011 static int emit_return(struct r600_shader_ctx
*ctx
)
5013 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_RETURN
));
5017 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
5020 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
5021 ctx
->bc
->cf_last
->pop_count
= pops
;
5022 /* XXX work out offset */
5026 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
5031 static void emit_testflag(struct r600_shader_ctx
*ctx
)
5036 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
5039 emit_jump_to_offset(ctx
, 1, 4);
5040 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
5041 pops(ctx
, ifidx
+ 1);
5045 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
5049 r600_bytecode_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
5050 ctx
->bc
->cf_last
->pop_count
= 1;
5052 fc_set_mid(ctx
, fc_sp
);
5058 static int tgsi_if(struct r600_shader_ctx
*ctx
)
5060 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
));
5062 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
5064 fc_pushlevel(ctx
, FC_IF
);
5066 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
5070 static int tgsi_else(struct r600_shader_ctx
*ctx
)
5072 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
5073 ctx
->bc
->cf_last
->pop_count
= 1;
5075 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
5076 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
5080 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
5083 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
5084 R600_ERR("if/endif unbalanced in shader\n");
5088 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
5089 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
5090 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
5092 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
5096 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
5100 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
5102 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
5104 fc_pushlevel(ctx
, FC_LOOP
);
5106 /* check stack depth */
5107 callstack_check_depth(ctx
, FC_LOOP
, 0);
5111 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
5115 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
5117 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
5118 R600_ERR("loop/endloop in shader code are not paired.\n");
5122 /* fixup loop pointers - from r600isa
5123 LOOP END points to CF after LOOP START,
5124 LOOP START point to CF after LOOP END
5125 BRK/CONT point to LOOP END CF
5127 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
5129 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
5131 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
5132 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
5134 /* XXX add LOOPRET support */
5136 callstack_decrease_current(ctx
, FC_LOOP
);
5140 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
5144 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
5146 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
5151 R600_ERR("Break not inside loop/endloop pair\n");
5155 r600_bytecode_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
5157 fc_set_mid(ctx
, fscp
);
5159 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
5163 static int tgsi_umad(struct r600_shader_ctx
*ctx
)
5165 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
5166 struct r600_bytecode_alu alu
;
5168 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
5171 for (i
= 0; i
< lasti
+ 1; i
++) {
5172 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
5175 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
5178 alu
.dst
.sel
= ctx
->temp_reg
;
5181 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
);
5182 for (j
= 0; j
< 2; j
++) {
5183 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
5187 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
5193 for (i
= 0; i
< lasti
+ 1; i
++) {
5194 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
5197 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
5198 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
5200 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
5202 alu
.src
[0].sel
= ctx
->temp_reg
;
5203 alu
.src
[0].chan
= i
;
5205 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
5209 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
5216 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
5217 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
5218 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5219 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
5222 * For state trackers other than OpenGL, we'll want to use
5223 * _RECIP_IEEE instead.
5225 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
5227 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
5228 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
5229 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
5230 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
5231 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5232 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5233 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5234 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
5235 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
5236 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
5237 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
5238 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
5239 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
5240 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5241 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
5242 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5244 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5245 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5247 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5248 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5249 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
5250 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5251 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
5252 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE
, tgsi_op2
},
5253 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
5254 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
5255 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
5256 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
5258 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5259 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5260 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5261 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5262 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
5263 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
5264 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
5265 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
5266 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5267 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5268 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5269 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5270 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5271 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
5272 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5273 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
5274 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
5275 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
5276 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
5277 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5278 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5279 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
5280 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5281 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5282 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5283 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5284 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5285 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5286 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5287 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
5288 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5289 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5290 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5291 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
5292 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
5293 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
5294 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
5295 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5296 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5297 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5298 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
5299 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
5300 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
5302 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5303 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5304 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
5305 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
5307 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5308 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5309 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5310 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5311 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CEIL
, tgsi_op2
},
5312 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
, tgsi_op2_trans
},
5313 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT
, tgsi_op2
},
5314 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
5315 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT
, tgsi_op2_trans
},
5317 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5318 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
, tgsi_op2
},
5319 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT
, tgsi_op2
},
5320 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_imod
},
5321 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
, tgsi_op2
},
5322 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5323 {TGSI_OPCODE_TXF
, 0, SQ_TEX_INST_LD
, tgsi_tex
},
5324 {TGSI_OPCODE_TXQ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
5325 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
5326 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5327 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5328 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
5329 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5330 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
5331 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5332 {TGSI_OPCODE_TXQ_LZ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
5334 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5335 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5336 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5337 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5339 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5340 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5341 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5342 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5343 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5344 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5345 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5346 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5347 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
5348 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
5350 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5351 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
, tgsi_op2_trans
},
5352 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_idiv
},
5353 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT
, tgsi_op2
},
5354 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT
, tgsi_op2
},
5355 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
, tgsi_ineg
},
5356 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT
, tgsi_op2
},
5357 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT
, tgsi_op2_trans
},
5358 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
, tgsi_op2_swap
},
5359 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
, tgsi_op2_trans
},
5360 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
, tgsi_op2_trans
},
5361 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
, tgsi_op2
},
5362 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_udiv
},
5363 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umad
},
5364 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT
, tgsi_op2
},
5365 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT
, tgsi_op2
},
5366 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umod
},
5367 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
, tgsi_op2_trans
},
5368 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT
, tgsi_op2
},
5369 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
, tgsi_op2
},
5370 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
, tgsi_op2_trans
},
5371 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_UINT
, tgsi_op2_swap
},
5372 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT
, tgsi_op2_swap
},
5373 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5374 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5375 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5376 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5377 {TGSI_OPCODE_SAMPLE
, 0, 0, tgsi_unsupported
},
5378 {TGSI_OPCODE_SAMPLE_I
, 0, 0, tgsi_unsupported
},
5379 {TGSI_OPCODE_SAMPLE_I_MS
, 0, 0, tgsi_unsupported
},
5380 {TGSI_OPCODE_SAMPLE_B
, 0, 0, tgsi_unsupported
},
5381 {TGSI_OPCODE_SAMPLE_C
, 0, 0, tgsi_unsupported
},
5382 {TGSI_OPCODE_SAMPLE_C_LZ
, 0, 0, tgsi_unsupported
},
5383 {TGSI_OPCODE_SAMPLE_D
, 0, 0, tgsi_unsupported
},
5384 {TGSI_OPCODE_SAMPLE_L
, 0, 0, tgsi_unsupported
},
5385 {TGSI_OPCODE_GATHER4
, 0, 0, tgsi_unsupported
},
5386 {TGSI_OPCODE_SVIEWINFO
, 0, 0, tgsi_unsupported
},
5387 {TGSI_OPCODE_SAMPLE_POS
, 0, 0, tgsi_unsupported
},
5388 {TGSI_OPCODE_SAMPLE_INFO
, 0, 0, tgsi_unsupported
},
5389 {TGSI_OPCODE_UARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
, tgsi_r600_arl
},
5390 {TGSI_OPCODE_UCMP
, 0, 0, tgsi_unsupported
},
5391 {TGSI_OPCODE_IABS
, 0, 0, tgsi_iabs
},
5392 {TGSI_OPCODE_ISSG
, 0, 0, tgsi_issg
},
5393 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5396 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
5397 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
5398 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5399 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
5400 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
5401 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_rsq
},
5402 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
5403 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
5404 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
5405 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5406 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5407 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5408 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
5409 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
5410 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
5411 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
5412 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
5413 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
5414 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5415 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
5416 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5418 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5419 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5421 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5422 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5423 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
5424 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5425 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
5426 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE
, tgsi_op2
},
5427 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
5428 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
5429 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
5430 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
5432 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5433 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5434 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5435 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5436 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
5437 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
5438 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
5439 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
5440 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5441 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5442 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5443 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5444 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5445 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
5446 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5447 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
5448 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
5449 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
5450 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
5451 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5452 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5453 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
5454 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5455 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5456 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5457 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5458 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5459 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5460 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5461 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
5462 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5463 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5464 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5465 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
5466 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
5467 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
5468 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
5469 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5470 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5471 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5472 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
5473 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
5474 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
5476 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5477 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5478 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
5479 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
5481 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5482 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5483 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5484 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5485 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CEIL
, tgsi_op2
},
5486 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
, tgsi_op2_trans
},
5487 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT
, tgsi_op2
},
5488 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
5489 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT
, tgsi_op2
},
5491 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5492 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
, tgsi_op2
},
5493 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT
, tgsi_op2
},
5494 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_imod
},
5495 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
, tgsi_op2
},
5496 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5497 {TGSI_OPCODE_TXF
, 0, SQ_TEX_INST_LD
, tgsi_tex
},
5498 {TGSI_OPCODE_TXQ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
5499 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
5500 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5501 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5502 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
5503 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5504 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
5505 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5506 {TGSI_OPCODE_TXQ_LZ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
5508 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5509 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5510 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5511 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5513 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5514 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5515 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5516 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5517 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5518 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5519 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5520 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5521 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
5522 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
5524 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5525 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
, tgsi_f2i
},
5526 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_idiv
},
5527 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT
, tgsi_op2
},
5528 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT
, tgsi_op2
},
5529 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
, tgsi_ineg
},
5530 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT
, tgsi_op2
},
5531 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT
, tgsi_op2
},
5532 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
, tgsi_op2_swap
},
5533 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
, tgsi_f2i
},
5534 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
, tgsi_op2_trans
},
5535 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
, tgsi_op2
},
5536 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_udiv
},
5537 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umad
},
5538 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT
, tgsi_op2
},
5539 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT
, tgsi_op2
},
5540 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umod
},
5541 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
, tgsi_op2_trans
},
5542 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT
, tgsi_op2
},
5543 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
, tgsi_op2
},
5544 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
, tgsi_op2
},
5545 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_UINT
, tgsi_op2_swap
},
5546 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT
, tgsi_op2
},
5547 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5548 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5549 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5550 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5551 {TGSI_OPCODE_SAMPLE
, 0, 0, tgsi_unsupported
},
5552 {TGSI_OPCODE_SAMPLE_I
, 0, 0, tgsi_unsupported
},
5553 {TGSI_OPCODE_SAMPLE_I_MS
, 0, 0, tgsi_unsupported
},
5554 {TGSI_OPCODE_SAMPLE_B
, 0, 0, tgsi_unsupported
},
5555 {TGSI_OPCODE_SAMPLE_C
, 0, 0, tgsi_unsupported
},
5556 {TGSI_OPCODE_SAMPLE_C_LZ
, 0, 0, tgsi_unsupported
},
5557 {TGSI_OPCODE_SAMPLE_D
, 0, 0, tgsi_unsupported
},
5558 {TGSI_OPCODE_SAMPLE_L
, 0, 0, tgsi_unsupported
},
5559 {TGSI_OPCODE_GATHER4
, 0, 0, tgsi_unsupported
},
5560 {TGSI_OPCODE_SVIEWINFO
, 0, 0, tgsi_unsupported
},
5561 {TGSI_OPCODE_SAMPLE_POS
, 0, 0, tgsi_unsupported
},
5562 {TGSI_OPCODE_SAMPLE_INFO
, 0, 0, tgsi_unsupported
},
5563 {TGSI_OPCODE_UARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
, tgsi_eg_arl
},
5564 {TGSI_OPCODE_UCMP
, 0, 0, tgsi_unsupported
},
5565 {TGSI_OPCODE_IABS
, 0, 0, tgsi_iabs
},
5566 {TGSI_OPCODE_ISSG
, 0, 0, tgsi_issg
},
5567 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5570 static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction
[] = {
5571 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
5572 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5573 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
5574 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, cayman_emit_float_instr
},
5575 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, cayman_emit_float_instr
},
5576 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
5577 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
5578 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
5579 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5580 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5581 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5582 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
5583 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
5584 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
5585 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
5586 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
5587 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
5588 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5589 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
5590 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5592 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5593 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5595 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5596 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5597 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
5598 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5599 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
5600 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE
, tgsi_op2
},
5601 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, cayman_emit_float_instr
},
5602 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, cayman_emit_float_instr
},
5603 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, cayman_pow
},
5604 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
5606 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5607 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5608 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5609 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5610 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, cayman_trig
},
5611 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
5612 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
5613 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
5614 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5615 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5616 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5617 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5618 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5619 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
5620 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5621 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
5622 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, cayman_trig
},
5623 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
5624 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
5625 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5626 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5627 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
5628 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5629 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5630 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5631 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5632 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5633 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5634 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5635 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
5636 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5637 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5638 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5639 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
5640 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
5641 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
5642 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
5643 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5644 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5645 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5646 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
5647 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
5648 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
5650 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5651 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5652 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
5653 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
5655 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5656 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5657 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5658 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5659 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CEIL
, tgsi_op2
},
5660 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
, tgsi_op2
},
5661 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT
, tgsi_op2
},
5662 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
5663 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT
, tgsi_op2
},
5665 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5666 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
, tgsi_op2
},
5667 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT
, tgsi_op2
},
5668 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_imod
},
5669 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
, tgsi_op2
},
5670 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5671 {TGSI_OPCODE_TXF
, 0, SQ_TEX_INST_LD
, tgsi_tex
},
5672 {TGSI_OPCODE_TXQ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
5673 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
5674 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5675 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5676 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
5677 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5678 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
5679 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5680 {TGSI_OPCODE_TXQ_LZ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
5682 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5683 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5684 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5685 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5687 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5688 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5689 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5690 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5691 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5692 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5693 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5694 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5695 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
5696 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
5698 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5699 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
, tgsi_op2
},
5700 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_idiv
},
5701 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT
, tgsi_op2
},
5702 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT
, tgsi_op2
},
5703 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
, tgsi_ineg
},
5704 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT
, tgsi_op2
},
5705 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT
, tgsi_op2
},
5706 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
, tgsi_op2_swap
},
5707 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
, tgsi_op2
},
5708 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
, tgsi_op2
},
5709 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
, tgsi_op2
},
5710 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_udiv
},
5711 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umad
},
5712 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT
, tgsi_op2
},
5713 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT
, tgsi_op2
},
5714 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umod
},
5715 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_INT
, cayman_mul_int_instr
},
5716 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT
, tgsi_op2
},
5717 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
, tgsi_op2
},
5718 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
, tgsi_op2
},
5719 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_UINT
, tgsi_op2_swap
},
5720 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT
, tgsi_op2
},
5721 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5722 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5723 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5724 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5725 {TGSI_OPCODE_SAMPLE
, 0, 0, tgsi_unsupported
},
5726 {TGSI_OPCODE_SAMPLE_I
, 0, 0, tgsi_unsupported
},
5727 {TGSI_OPCODE_SAMPLE_I_MS
, 0, 0, tgsi_unsupported
},
5728 {TGSI_OPCODE_SAMPLE_B
, 0, 0, tgsi_unsupported
},
5729 {TGSI_OPCODE_SAMPLE_C
, 0, 0, tgsi_unsupported
},
5730 {TGSI_OPCODE_SAMPLE_C_LZ
, 0, 0, tgsi_unsupported
},
5731 {TGSI_OPCODE_SAMPLE_D
, 0, 0, tgsi_unsupported
},
5732 {TGSI_OPCODE_SAMPLE_L
, 0, 0, tgsi_unsupported
},
5733 {TGSI_OPCODE_GATHER4
, 0, 0, tgsi_unsupported
},
5734 {TGSI_OPCODE_SVIEWINFO
, 0, 0, tgsi_unsupported
},
5735 {TGSI_OPCODE_SAMPLE_POS
, 0, 0, tgsi_unsupported
},
5736 {TGSI_OPCODE_SAMPLE_INFO
, 0, 0, tgsi_unsupported
},
5737 {TGSI_OPCODE_UARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
, tgsi_eg_arl
},
5738 {TGSI_OPCODE_UCMP
, 0, 0, tgsi_unsupported
},
5739 {TGSI_OPCODE_IABS
, 0, 0, tgsi_iabs
},
5740 {TGSI_OPCODE_ISSG
, 0, 0, tgsi_issg
},
5741 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},