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"
27 #include "r600_shader.h"
30 #include "pipe/p_shader_tokens.h"
31 #include "tgsi/tgsi_info.h"
32 #include "tgsi/tgsi_parse.h"
33 #include "tgsi/tgsi_scan.h"
34 #include "tgsi/tgsi_dump.h"
35 #include "util/u_memory.h"
41 Why CAYMAN got loops for lots of instructions is explained here.
43 -These 8xx t-slot only ops are implemented in all vector slots.
44 MUL_LIT, FLT_TO_UINT, INT_TO_FLT, UINT_TO_FLT
45 These 8xx t-slot only opcodes become vector ops, with all four
46 slots expecting the arguments on sources a and b. Result is
47 broadcast to all channels.
48 MULLO_INT, MULHI_INT, MULLO_UINT, MULHI_UINT
49 These 8xx t-slot only opcodes become vector ops in the z, y, and
51 EXP_IEEE, LOG_IEEE/CLAMPED, RECIP_IEEE/CLAMPED/FF/INT/UINT/_64/CLAMPED_64
52 RECIPSQRT_IEEE/CLAMPED/FF/_64/CLAMPED_64
55 The w slot may have an independent co-issued operation, or if the
56 result is required to be in the w slot, the opcode above may be
57 issued in the w slot as well.
58 The compiler must issue the source argument to slots z, y, and x
61 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
63 struct r600_context
*rctx
= (struct r600_context
*)ctx
;
64 struct r600_shader
*rshader
= &shader
->shader
;
69 if (shader
->bo
== NULL
) {
70 shader
->bo
= (struct r600_resource
*)
71 pipe_buffer_create(ctx
->screen
, PIPE_BIND_CUSTOM
, PIPE_USAGE_IMMUTABLE
, rshader
->bc
.ndw
* 4);
72 if (shader
->bo
== NULL
) {
75 ptr
= (uint32_t*)rctx
->ws
->buffer_map(shader
->bo
->cs_buf
, rctx
->cs
, PIPE_TRANSFER_WRITE
);
76 if (R600_BIG_ENDIAN
) {
77 for (i
= 0; i
< rshader
->bc
.ndw
; ++i
) {
78 ptr
[i
] = bswap_32(rshader
->bc
.bytecode
[i
]);
81 memcpy(ptr
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* sizeof(*ptr
));
83 rctx
->ws
->buffer_unmap(shader
->bo
->cs_buf
);
86 switch (rshader
->processor_type
) {
87 case TGSI_PROCESSOR_VERTEX
:
88 if (rctx
->chip_class
>= EVERGREEN
) {
89 evergreen_pipe_shader_vs(ctx
, shader
);
91 r600_pipe_shader_vs(ctx
, shader
);
94 case TGSI_PROCESSOR_FRAGMENT
:
95 if (rctx
->chip_class
>= EVERGREEN
) {
96 evergreen_pipe_shader_ps(ctx
, shader
);
98 r600_pipe_shader_ps(ctx
, shader
);
107 static int r600_shader_from_tgsi(struct r600_screen
*rscreen
,
108 struct r600_pipe_shader
*pipeshader
,
109 struct r600_shader_key key
);
111 int r600_pipe_shader_create(struct pipe_context
*ctx
,
112 struct r600_pipe_shader
*shader
,
113 struct r600_shader_key key
)
115 static int dump_shaders
= -1;
116 struct r600_context
*rctx
= (struct r600_context
*)ctx
;
117 struct r600_pipe_shader_selector
*sel
= shader
->selector
;
120 /* Would like some magic "get_bool_option_once" routine.
122 if (dump_shaders
== -1)
123 dump_shaders
= debug_get_bool_option("R600_DUMP_SHADERS", FALSE
);
126 fprintf(stderr
, "--------------------------------------------------------------\n");
127 tgsi_dump(sel
->tokens
, 0);
129 if (sel
->so
.num_outputs
) {
131 fprintf(stderr
, "STREAMOUT\n");
132 for (i
= 0; i
< sel
->so
.num_outputs
; i
++) {
133 unsigned mask
= ((1 << sel
->so
.output
[i
].num_components
) - 1) <<
134 sel
->so
.output
[i
].start_component
;
135 fprintf(stderr
, " %i: MEM_STREAM0_BUF%i OUT[%i].%s%s%s%s\n", i
,
136 sel
->so
.output
[i
].output_buffer
, sel
->so
.output
[i
].register_index
,
137 mask
& 1 ? "x" : "_",
138 (mask
>> 1) & 1 ? "y" : "_",
139 (mask
>> 2) & 1 ? "z" : "_",
140 (mask
>> 3) & 1 ? "w" : "_");
144 r
= r600_shader_from_tgsi(rctx
->screen
, shader
, key
);
146 R600_ERR("translation from TGSI failed !\n");
149 r
= r600_bytecode_build(&shader
->shader
.bc
);
151 R600_ERR("building bytecode failed !\n");
155 r600_bytecode_dump(&shader
->shader
.bc
);
156 fprintf(stderr
, "______________________________________________________________\n");
158 return r600_pipe_shader(ctx
, shader
);
161 void r600_pipe_shader_destroy(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
163 pipe_resource_reference((struct pipe_resource
**)&shader
->bo
, NULL
);
164 r600_bytecode_clear(&shader
->shader
.bc
);
168 * tgsi -> r600 shader
170 struct r600_shader_tgsi_instruction
;
172 struct r600_shader_src
{
181 struct r600_shader_ctx
{
182 struct tgsi_shader_info info
;
183 struct tgsi_parse_context parse
;
184 const struct tgsi_token
*tokens
;
186 unsigned file_offset
[TGSI_FILE_COUNT
];
188 struct r600_shader_tgsi_instruction
*inst_info
;
189 struct r600_bytecode
*bc
;
190 struct r600_shader
*shader
;
191 struct r600_shader_src src
[4];
194 uint32_t max_driver_temp_used
;
196 /* needed for evergreen interpolation */
197 boolean input_centroid
;
198 boolean input_linear
;
199 boolean input_perspective
;
203 boolean clip_vertex_write
;
209 struct r600_shader_tgsi_instruction
{
210 unsigned tgsi_opcode
;
212 unsigned r600_opcode
;
213 int (*process
)(struct r600_shader_ctx
*ctx
);
216 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[], eg_shader_tgsi_instruction
[], cm_shader_tgsi_instruction
[];
217 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
218 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
);
219 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
);
220 static int tgsi_else(struct r600_shader_ctx
*ctx
);
221 static int tgsi_endif(struct r600_shader_ctx
*ctx
);
222 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
);
223 static int tgsi_endloop(struct r600_shader_ctx
*ctx
);
224 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
);
227 * bytestream -> r600 shader
229 * These functions are used to transform the output of the LLVM backend into
230 * struct r600_bytecode.
233 static void r600_bytecode_from_byte_stream(struct r600_shader_ctx
*ctx
,
234 unsigned char * bytes
, unsigned num_bytes
);
237 int r600_compute_shader_create(struct pipe_context
* ctx
,
238 LLVMModuleRef mod
, struct r600_bytecode
* bytecode
)
240 struct r600_context
*r600_ctx
= (struct r600_context
*)ctx
;
241 unsigned char * bytes
;
243 struct r600_shader_ctx shader_ctx
;
246 if (debug_get_bool_option("R600_DUMP_SHADERS", FALSE
)) {
250 r600_llvm_compile(mod
, &bytes
, &byte_count
, r600_ctx
->family
, dump
);
251 shader_ctx
.bc
= bytecode
;
252 r600_bytecode_init(shader_ctx
.bc
, r600_ctx
->chip_class
, r600_ctx
->family
,
253 r600_ctx
->screen
->msaa_texture_support
);
254 shader_ctx
.bc
->type
= TGSI_PROCESSOR_COMPUTE
;
255 r600_bytecode_from_byte_stream(&shader_ctx
, bytes
, byte_count
);
256 if (shader_ctx
.bc
->chip_class
== CAYMAN
) {
257 cm_bytecode_add_cf_end(shader_ctx
.bc
);
259 r600_bytecode_build(shader_ctx
.bc
);
261 r600_bytecode_dump(shader_ctx
.bc
);
267 #endif /* HAVE_OPENCL */
269 static uint32_t i32_from_byte_stream(unsigned char * bytes
,
270 unsigned * bytes_read
)
274 for (i
= 0; i
< 4; i
++) {
275 out
|= bytes
[(*bytes_read
)++] << (8 * i
);
280 static unsigned r600_src_from_byte_stream(unsigned char * bytes
,
281 unsigned bytes_read
, struct r600_bytecode_alu
* alu
, unsigned src_idx
)
285 sel0
= bytes
[bytes_read
++];
286 sel1
= bytes
[bytes_read
++];
287 alu
->src
[src_idx
].sel
= sel0
| (sel1
<< 8);
288 alu
->src
[src_idx
].chan
= bytes
[bytes_read
++];
289 alu
->src
[src_idx
].neg
= bytes
[bytes_read
++];
290 alu
->src
[src_idx
].abs
= bytes
[bytes_read
++];
291 alu
->src
[src_idx
].rel
= bytes
[bytes_read
++];
292 alu
->src
[src_idx
].kc_bank
= bytes
[bytes_read
++];
293 for (i
= 0; i
< 4; i
++) {
294 alu
->src
[src_idx
].value
|= bytes
[bytes_read
++] << (i
* 8);
299 static unsigned r600_alu_from_byte_stream(struct r600_shader_ctx
*ctx
,
300 unsigned char * bytes
, unsigned bytes_read
)
303 struct r600_bytecode_alu alu
;
304 unsigned src_const_reg
[3];
305 uint32_t word0
, word1
;
307 memset(&alu
, 0, sizeof(alu
));
308 for(src_idx
= 0; src_idx
< 3; src_idx
++) {
310 src_const_reg
[src_idx
] = bytes
[bytes_read
++];
311 for (i
= 0; i
< 4; i
++) {
312 alu
.src
[src_idx
].value
|= bytes
[bytes_read
++] << (i
* 8);
316 word0
= i32_from_byte_stream(bytes
, &bytes_read
);
317 word1
= i32_from_byte_stream(bytes
, &bytes_read
);
319 switch(ctx
->bc
->chip_class
) {
321 r600_bytecode_alu_read(&alu
, word0
, word1
);
326 r700_bytecode_alu_read(&alu
, word0
, word1
);
330 for(src_idx
= 0; src_idx
< 3; src_idx
++) {
331 if (src_const_reg
[src_idx
])
332 alu
.src
[src_idx
].sel
+= 512;
335 #if HAVE_LLVM < 0x0302
336 if (alu
.inst
== CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
) ||
337 alu
.inst
== CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE
) ||
338 alu
.inst
== CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_INT
) ||
339 alu
.inst
== CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
)) {
342 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
348 if (alu
.execute_mask
) {
350 r600_bytecode_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
352 r600_bytecode_add_alu(ctx
->bc
, &alu
);
355 /* XXX: Handle other KILL instructions */
356 if (alu
.inst
== CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
)) {
357 ctx
->shader
->uses_kill
= 1;
358 /* XXX: This should be enforced in the LLVM backend. */
359 ctx
->bc
->force_add_cf
= 1;
364 static void llvm_if(struct r600_shader_ctx
*ctx
, struct r600_bytecode_alu
* alu
,
367 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
368 fc_pushlevel(ctx
, FC_IF
);
369 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
372 static void r600_break_from_byte_stream(struct r600_shader_ctx
*ctx
,
373 struct r600_bytecode_alu
*alu
, unsigned compare_opcode
)
375 unsigned opcode
= TGSI_OPCODE_BRK
;
376 if (ctx
->bc
->chip_class
== CAYMAN
)
377 ctx
->inst_info
= &cm_shader_tgsi_instruction
[opcode
];
378 else if (ctx
->bc
->chip_class
>= EVERGREEN
)
379 ctx
->inst_info
= &eg_shader_tgsi_instruction
[opcode
];
381 ctx
->inst_info
= &r600_shader_tgsi_instruction
[opcode
];
382 llvm_if(ctx
, alu
, compare_opcode
);
383 tgsi_loop_brk_cont(ctx
);
387 static unsigned r600_fc_from_byte_stream(struct r600_shader_ctx
*ctx
,
388 unsigned char * bytes
, unsigned bytes_read
)
390 struct r600_bytecode_alu alu
;
392 memset(&alu
, 0, sizeof(alu
));
393 bytes_read
= r600_src_from_byte_stream(bytes
, bytes_read
, &alu
, 0);
394 inst
= bytes
[bytes_read
++];
398 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
400 case 1: /* FC_IF_INT */
402 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
));
404 case 2: /* FC_ELSE */
407 case 3: /* FC_ENDIF */
410 case 4: /* FC_BGNLOOP */
413 case 5: /* FC_ENDLOOP */
416 case 6: /* FC_BREAK */
417 r600_break_from_byte_stream(ctx
, &alu
,
418 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_INT
));
420 case 7: /* FC_BREAK_NZ_INT */
421 r600_break_from_byte_stream(ctx
, &alu
,
422 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
));
424 case 8: /* FC_CONTINUE */
426 unsigned opcode
= TGSI_OPCODE_CONT
;
427 if (ctx
->bc
->chip_class
== CAYMAN
) {
429 &cm_shader_tgsi_instruction
[opcode
];
430 } else if (ctx
->bc
->chip_class
>= EVERGREEN
) {
432 &eg_shader_tgsi_instruction
[opcode
];
435 &r600_shader_tgsi_instruction
[opcode
];
437 tgsi_loop_brk_cont(ctx
);
440 case 9: /* FC_BREAK_Z_INT */
441 r600_break_from_byte_stream(ctx
, &alu
,
442 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_INT
));
444 case 10: /* FC_BREAK_NZ */
445 r600_break_from_byte_stream(ctx
, &alu
,
446 CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
453 static unsigned r600_tex_from_byte_stream(struct r600_shader_ctx
*ctx
,
454 unsigned char * bytes
, unsigned bytes_read
)
456 struct r600_bytecode_tex tex
;
458 tex
.inst
= bytes
[bytes_read
++];
459 tex
.resource_id
= bytes
[bytes_read
++];
460 tex
.src_gpr
= bytes
[bytes_read
++];
461 tex
.src_rel
= bytes
[bytes_read
++];
462 tex
.dst_gpr
= bytes
[bytes_read
++];
463 tex
.dst_rel
= bytes
[bytes_read
++];
464 tex
.dst_sel_x
= bytes
[bytes_read
++];
465 tex
.dst_sel_y
= bytes
[bytes_read
++];
466 tex
.dst_sel_z
= bytes
[bytes_read
++];
467 tex
.dst_sel_w
= bytes
[bytes_read
++];
468 tex
.lod_bias
= bytes
[bytes_read
++];
469 tex
.coord_type_x
= bytes
[bytes_read
++];
470 tex
.coord_type_y
= bytes
[bytes_read
++];
471 tex
.coord_type_z
= bytes
[bytes_read
++];
472 tex
.coord_type_w
= bytes
[bytes_read
++];
473 tex
.offset_x
= bytes
[bytes_read
++];
474 tex
.offset_y
= bytes
[bytes_read
++];
475 tex
.offset_z
= bytes
[bytes_read
++];
476 tex
.sampler_id
= bytes
[bytes_read
++];
477 tex
.src_sel_x
= bytes
[bytes_read
++];
478 tex
.src_sel_y
= bytes
[bytes_read
++];
479 tex
.src_sel_z
= bytes
[bytes_read
++];
480 tex
.src_sel_w
= bytes
[bytes_read
++];
482 r600_bytecode_add_tex(ctx
->bc
, &tex
);
487 static int r600_vtx_from_byte_stream(struct r600_shader_ctx
*ctx
,
488 unsigned char * bytes
, unsigned bytes_read
)
490 struct r600_bytecode_vtx vtx
;
492 uint32_t word0
= i32_from_byte_stream(bytes
, &bytes_read
);
493 uint32_t word1
= i32_from_byte_stream(bytes
, &bytes_read
);
494 uint32_t word2
= i32_from_byte_stream(bytes
, &bytes_read
);
496 memset(&vtx
, 0, sizeof(vtx
));
499 vtx
.inst
= G_SQ_VTX_WORD0_VTX_INST(word0
);
500 vtx
.fetch_type
= G_SQ_VTX_WORD0_FETCH_TYPE(word0
);
501 vtx
.buffer_id
= G_SQ_VTX_WORD0_BUFFER_ID(word0
);
502 vtx
.src_gpr
= G_SQ_VTX_WORD0_SRC_GPR(word0
);
503 vtx
.src_sel_x
= G_SQ_VTX_WORD0_SRC_SEL_X(word0
);
504 vtx
.mega_fetch_count
= G_SQ_VTX_WORD0_MEGA_FETCH_COUNT(word0
);
507 vtx
.dst_gpr
= G_SQ_VTX_WORD1_GPR_DST_GPR(word1
);
508 vtx
.dst_sel_x
= G_SQ_VTX_WORD1_DST_SEL_X(word1
);
509 vtx
.dst_sel_y
= G_SQ_VTX_WORD1_DST_SEL_Y(word1
);
510 vtx
.dst_sel_z
= G_SQ_VTX_WORD1_DST_SEL_Z(word1
);
511 vtx
.dst_sel_w
= G_SQ_VTX_WORD1_DST_SEL_W(word1
);
512 vtx
.use_const_fields
= G_SQ_VTX_WORD1_USE_CONST_FIELDS(word1
);
513 vtx
.data_format
= G_SQ_VTX_WORD1_DATA_FORMAT(word1
);
514 vtx
.num_format_all
= G_SQ_VTX_WORD1_NUM_FORMAT_ALL(word1
);
515 vtx
.format_comp_all
= G_SQ_VTX_WORD1_FORMAT_COMP_ALL(word1
);
516 vtx
.srf_mode_all
= G_SQ_VTX_WORD1_SRF_MODE_ALL(word1
);
519 vtx
.offset
= G_SQ_VTX_WORD2_OFFSET(word2
);
520 vtx
.endian
= G_SQ_VTX_WORD2_ENDIAN_SWAP(word2
);
522 if (r600_bytecode_add_vtx(ctx
->bc
, &vtx
)) {
523 fprintf(stderr
, "Error adding vtx\n");
525 /* Use the Texture Cache */
526 ctx
->bc
->cf_last
->inst
= EG_V_SQ_CF_WORD1_SQ_CF_INST_TEX
;
530 static int r600_export_from_byte_stream(struct r600_shader_ctx
*ctx
,
531 unsigned char * bytes
, unsigned bytes_read
)
533 struct r600_bytecode_output output
;
534 memset(&output
, 0, sizeof(struct r600_bytecode_output
));
535 uint32_t word0
= i32_from_byte_stream(bytes
, &bytes_read
);
536 uint32_t word1
= i32_from_byte_stream(bytes
, &bytes_read
);
537 if (ctx
->bc
->chip_class
>= EVERGREEN
)
538 eg_bytecode_export_read(&output
, word0
,word1
);
540 r600_bytecode_export_read(&output
, word0
,word1
);
541 r600_bytecode_add_output(ctx
->bc
, &output
);
545 static void r600_bytecode_from_byte_stream(struct r600_shader_ctx
*ctx
,
546 unsigned char * bytes
, unsigned num_bytes
)
548 unsigned bytes_read
= 0;
550 while (bytes_read
< num_bytes
) {
551 char inst_type
= bytes
[bytes_read
++];
554 bytes_read
= r600_alu_from_byte_stream(ctx
, bytes
,
558 bytes_read
= r600_tex_from_byte_stream(ctx
, bytes
,
562 bytes_read
= r600_fc_from_byte_stream(ctx
, bytes
,
566 r600_bytecode_add_cfinst(ctx
->bc
, CF_NATIVE
);
567 for (i
= 0; i
< 2; i
++) {
568 for (byte
= 0 ; byte
< 4; byte
++) {
569 ctx
->bc
->cf_last
->isa
[i
] |=
570 (bytes
[bytes_read
++] << (byte
* 8));
576 bytes_read
= r600_vtx_from_byte_stream(ctx
, bytes
,
580 bytes_read
= r600_export_from_byte_stream(ctx
, bytes
,
584 /* XXX: Error here */
590 /* End bytestream -> r600 shader functions*/
592 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
594 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
597 if (i
->Instruction
.NumDstRegs
> 1) {
598 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
601 if (i
->Instruction
.Predicate
) {
602 R600_ERR("predicate unsupported\n");
606 if (i
->Instruction
.Label
) {
607 R600_ERR("label unsupported\n");
611 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
612 if (i
->Src
[j
].Register
.Dimension
) {
613 R600_ERR("unsupported src %d (dimension %d)\n", j
,
614 i
->Src
[j
].Register
.Dimension
);
618 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
619 if (i
->Dst
[j
].Register
.Dimension
) {
620 R600_ERR("unsupported dst (dimension)\n");
627 static int evergreen_interp_alu(struct r600_shader_ctx
*ctx
, int input
)
630 struct r600_bytecode_alu alu
;
631 int gpr
= 0, base_chan
= 0;
634 if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_PERSPECTIVE
) {
636 if (ctx
->shader
->input
[input
].centroid
)
638 } else if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_LINEAR
) {
640 /* if we have perspective add one */
641 if (ctx
->input_perspective
) {
643 /* if we have perspective centroid */
644 if (ctx
->input_centroid
)
647 if (ctx
->shader
->input
[input
].centroid
)
651 /* work out gpr and base_chan from index */
653 base_chan
= (2 * (ij_index
% 2)) + 1;
655 for (i
= 0; i
< 8; i
++) {
656 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
659 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INTERP_ZW
;
661 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INTERP_XY
;
663 if ((i
> 1) && (i
< 6)) {
664 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
668 alu
.dst
.chan
= i
% 4;
670 alu
.src
[0].sel
= gpr
;
671 alu
.src
[0].chan
= (base_chan
- (i
% 2));
673 alu
.src
[1].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
675 alu
.bank_swizzle_force
= SQ_ALU_VEC_210
;
678 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
685 static int evergreen_interp_flat(struct r600_shader_ctx
*ctx
, int input
)
688 struct r600_bytecode_alu alu
;
690 for (i
= 0; i
< 4; i
++) {
691 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
693 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INTERP_LOAD_P0
;
695 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
700 alu
.src
[0].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
705 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
713 * Special export handling in shaders
715 * shader export ARRAY_BASE for EXPORT_POS:
718 * 62, 63 are clip distance vectors
720 * The use of the values exported in 61-63 are controlled by PA_CL_VS_OUT_CNTL:
721 * VS_OUT_MISC_VEC_ENA - enables the use of all fields in export 61
722 * USE_VTX_POINT_SIZE - point size in the X channel of export 61
723 * USE_VTX_EDGE_FLAG - edge flag in the Y channel of export 61
724 * USE_VTX_RENDER_TARGET_INDX - render target index in the Z channel of export 61
725 * USE_VTX_VIEWPORT_INDX - viewport index in the W channel of export 61
726 * USE_VTX_KILL_FLAG - kill flag in the Z channel of export 61 (mutually
727 * exclusive from render target index)
728 * VS_OUT_CCDIST0_VEC_ENA/VS_OUT_CCDIST1_VEC_ENA - enable clip distance vectors
731 * shader export ARRAY_BASE for EXPORT_PIXEL:
733 * 61 computed Z vector
735 * The use of the values exported in the computed Z vector are controlled
736 * by DB_SHADER_CONTROL:
737 * Z_EXPORT_ENABLE - Z as a float in RED
738 * STENCIL_REF_EXPORT_ENABLE - stencil ref as int in GREEN
739 * COVERAGE_TO_MASK_ENABLE - alpha to mask in ALPHA
740 * MASK_EXPORT_ENABLE - pixel sample mask in BLUE
741 * DB_SOURCE_FORMAT - export control restrictions
746 /* Map name/sid pair from tgsi to the 8-bit semantic index for SPI setup */
747 static int r600_spi_sid(struct r600_shader_io
* io
)
749 int index
, name
= io
->name
;
751 /* These params are handled differently, they don't need
752 * semantic indices, so we'll use 0 for them.
754 if (name
== TGSI_SEMANTIC_POSITION
||
755 name
== TGSI_SEMANTIC_PSIZE
||
756 name
== TGSI_SEMANTIC_FACE
)
759 if (name
== TGSI_SEMANTIC_GENERIC
) {
760 /* For generic params simply use sid from tgsi */
763 /* For non-generic params - pack name and sid into 8 bits */
764 index
= 0x80 | (name
<<3) | (io
->sid
);
767 /* Make sure that all really used indices have nonzero value, so
768 * we can just compare it to 0 later instead of comparing the name
769 * with different values to detect special cases. */
776 /* turn input into interpolate on EG */
777 static int evergreen_interp_input(struct r600_shader_ctx
*ctx
, int index
)
781 if (ctx
->shader
->input
[index
].spi_sid
) {
782 ctx
->shader
->input
[index
].lds_pos
= ctx
->shader
->nlds
++;
783 if (!ctx
->use_llvm
) {
784 if (ctx
->shader
->input
[index
].interpolate
> 0) {
785 r
= evergreen_interp_alu(ctx
, index
);
787 r
= evergreen_interp_flat(ctx
, index
);
794 static int select_twoside_color(struct r600_shader_ctx
*ctx
, int front
, int back
)
796 struct r600_bytecode_alu alu
;
798 int gpr_front
= ctx
->shader
->input
[front
].gpr
;
799 int gpr_back
= ctx
->shader
->input
[back
].gpr
;
801 for (i
= 0; i
< 4; i
++) {
802 memset(&alu
, 0, sizeof(alu
));
803 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
806 alu
.dst
.sel
= gpr_front
;
807 alu
.src
[0].sel
= ctx
->face_gpr
;
808 alu
.src
[1].sel
= gpr_front
;
809 alu
.src
[2].sel
= gpr_back
;
816 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
823 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
825 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
829 switch (d
->Declaration
.File
) {
830 case TGSI_FILE_INPUT
:
831 i
= ctx
->shader
->ninput
++;
832 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
833 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
834 ctx
->shader
->input
[i
].spi_sid
= r600_spi_sid(&ctx
->shader
->input
[i
]);
835 ctx
->shader
->input
[i
].interpolate
= d
->Interp
.Interpolate
;
836 ctx
->shader
->input
[i
].centroid
= d
->Interp
.Centroid
;
837 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + d
->Range
.First
;
838 if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
) {
839 switch (ctx
->shader
->input
[i
].name
) {
840 case TGSI_SEMANTIC_FACE
:
841 ctx
->face_gpr
= ctx
->shader
->input
[i
].gpr
;
843 case TGSI_SEMANTIC_COLOR
:
846 case TGSI_SEMANTIC_POSITION
:
847 ctx
->fragcoord_input
= i
;
850 if (ctx
->bc
->chip_class
>= EVERGREEN
) {
851 if ((r
= evergreen_interp_input(ctx
, i
)))
856 case TGSI_FILE_OUTPUT
:
857 i
= ctx
->shader
->noutput
++;
858 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
859 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
860 ctx
->shader
->output
[i
].spi_sid
= r600_spi_sid(&ctx
->shader
->output
[i
]);
861 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + d
->Range
.First
;
862 ctx
->shader
->output
[i
].interpolate
= d
->Interp
.Interpolate
;
863 ctx
->shader
->output
[i
].write_mask
= d
->Declaration
.UsageMask
;
864 if (ctx
->type
== TGSI_PROCESSOR_VERTEX
) {
865 switch (d
->Semantic
.Name
) {
866 case TGSI_SEMANTIC_CLIPDIST
:
867 ctx
->shader
->clip_dist_write
|= d
->Declaration
.UsageMask
<< (d
->Semantic
.Index
<< 2);
869 case TGSI_SEMANTIC_PSIZE
:
870 ctx
->shader
->vs_out_misc_write
= 1;
871 ctx
->shader
->vs_out_point_size
= 1;
873 case TGSI_SEMANTIC_CLIPVERTEX
:
874 ctx
->clip_vertex_write
= TRUE
;
878 } else if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
) {
879 switch (d
->Semantic
.Name
) {
880 case TGSI_SEMANTIC_COLOR
:
881 ctx
->shader
->nr_ps_max_color_exports
++;
886 case TGSI_FILE_CONSTANT
:
887 case TGSI_FILE_TEMPORARY
:
888 case TGSI_FILE_SAMPLER
:
889 case TGSI_FILE_ADDRESS
:
892 case TGSI_FILE_SYSTEM_VALUE
:
893 if (d
->Semantic
.Name
== TGSI_SEMANTIC_INSTANCEID
) {
894 if (!ctx
->native_integers
) {
895 struct r600_bytecode_alu alu
;
896 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
898 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
);
907 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
911 } else if (d
->Semantic
.Name
== TGSI_SEMANTIC_VERTEXID
)
914 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
920 static int r600_get_temp(struct r600_shader_ctx
*ctx
)
922 return ctx
->temp_reg
+ ctx
->max_driver_temp_used
++;
926 * for evergreen we need to scan the shader to find the number of GPRs we need to
927 * reserve for interpolation.
929 * we need to know if we are going to emit
930 * any centroid inputs
931 * if perspective and linear are required
933 static int evergreen_gpr_count(struct r600_shader_ctx
*ctx
)
938 ctx
->input_linear
= FALSE
;
939 ctx
->input_perspective
= FALSE
;
940 ctx
->input_centroid
= FALSE
;
941 ctx
->num_interp_gpr
= 1;
943 /* any centroid inputs */
944 for (i
= 0; i
< ctx
->info
.num_inputs
; i
++) {
945 /* skip position/face */
946 if (ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_POSITION
||
947 ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_FACE
)
949 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_LINEAR
)
950 ctx
->input_linear
= TRUE
;
951 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_PERSPECTIVE
)
952 ctx
->input_perspective
= TRUE
;
953 if (ctx
->info
.input_centroid
[i
])
954 ctx
->input_centroid
= TRUE
;
958 /* ignoring sample for now */
959 if (ctx
->input_perspective
)
961 if (ctx
->input_linear
)
963 if (ctx
->input_centroid
)
966 ctx
->num_interp_gpr
+= (num_baryc
+ 1) >> 1;
968 /* XXX PULL MODEL and LINE STIPPLE, FIXED PT POS */
969 return ctx
->num_interp_gpr
;
972 static void tgsi_src(struct r600_shader_ctx
*ctx
,
973 const struct tgsi_full_src_register
*tgsi_src
,
974 struct r600_shader_src
*r600_src
)
976 memset(r600_src
, 0, sizeof(*r600_src
));
977 r600_src
->swizzle
[0] = tgsi_src
->Register
.SwizzleX
;
978 r600_src
->swizzle
[1] = tgsi_src
->Register
.SwizzleY
;
979 r600_src
->swizzle
[2] = tgsi_src
->Register
.SwizzleZ
;
980 r600_src
->swizzle
[3] = tgsi_src
->Register
.SwizzleW
;
981 r600_src
->neg
= tgsi_src
->Register
.Negate
;
982 r600_src
->abs
= tgsi_src
->Register
.Absolute
;
984 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
986 if ((tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleY
) &&
987 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleZ
) &&
988 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleW
)) {
990 index
= tgsi_src
->Register
.Index
* 4 + tgsi_src
->Register
.SwizzleX
;
991 r600_bytecode_special_constants(ctx
->literals
[index
], &r600_src
->sel
, &r600_src
->neg
);
992 if (r600_src
->sel
!= V_SQ_ALU_SRC_LITERAL
)
995 index
= tgsi_src
->Register
.Index
;
996 r600_src
->sel
= V_SQ_ALU_SRC_LITERAL
;
997 memcpy(r600_src
->value
, ctx
->literals
+ index
* 4, sizeof(r600_src
->value
));
998 } else if (tgsi_src
->Register
.File
== TGSI_FILE_SYSTEM_VALUE
) {
999 if (ctx
->info
.system_value_semantic_name
[tgsi_src
->Register
.Index
] == TGSI_SEMANTIC_INSTANCEID
) {
1000 r600_src
->swizzle
[0] = 3;
1001 r600_src
->swizzle
[1] = 3;
1002 r600_src
->swizzle
[2] = 3;
1003 r600_src
->swizzle
[3] = 3;
1005 } else if (ctx
->info
.system_value_semantic_name
[tgsi_src
->Register
.Index
] == TGSI_SEMANTIC_VERTEXID
) {
1006 r600_src
->swizzle
[0] = 0;
1007 r600_src
->swizzle
[1] = 0;
1008 r600_src
->swizzle
[2] = 0;
1009 r600_src
->swizzle
[3] = 0;
1013 if (tgsi_src
->Register
.Indirect
)
1014 r600_src
->rel
= V_SQ_REL_RELATIVE
;
1015 r600_src
->sel
= tgsi_src
->Register
.Index
;
1016 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
1020 static int tgsi_fetch_rel_const(struct r600_shader_ctx
*ctx
, unsigned int offset
, unsigned int dst_reg
)
1022 struct r600_bytecode_vtx vtx
;
1023 unsigned int ar_reg
;
1027 struct r600_bytecode_alu alu
;
1029 memset(&alu
, 0, sizeof(alu
));
1031 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
1032 alu
.src
[0].sel
= ctx
->bc
->ar_reg
;
1034 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1035 alu
.src
[1].value
= offset
;
1037 alu
.dst
.sel
= dst_reg
;
1041 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
1046 ar_reg
= ctx
->bc
->ar_reg
;
1049 memset(&vtx
, 0, sizeof(vtx
));
1050 vtx
.fetch_type
= 2; /* VTX_FETCH_NO_INDEX_OFFSET */
1051 vtx
.src_gpr
= ar_reg
;
1052 vtx
.mega_fetch_count
= 16;
1053 vtx
.dst_gpr
= dst_reg
;
1054 vtx
.dst_sel_x
= 0; /* SEL_X */
1055 vtx
.dst_sel_y
= 1; /* SEL_Y */
1056 vtx
.dst_sel_z
= 2; /* SEL_Z */
1057 vtx
.dst_sel_w
= 3; /* SEL_W */
1058 vtx
.data_format
= FMT_32_32_32_32_FLOAT
;
1059 vtx
.num_format_all
= 2; /* NUM_FORMAT_SCALED */
1060 vtx
.format_comp_all
= 1; /* FORMAT_COMP_SIGNED */
1061 vtx
.srf_mode_all
= 1; /* SRF_MODE_NO_ZERO */
1062 vtx
.endian
= r600_endian_swap(32);
1064 if ((r
= r600_bytecode_add_vtx(ctx
->bc
, &vtx
)))
1070 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
)
1072 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1073 struct r600_bytecode_alu alu
;
1074 int i
, j
, k
, nconst
, r
;
1076 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1077 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
1080 tgsi_src(ctx
, &inst
->Src
[i
], &ctx
->src
[i
]);
1082 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1083 if (inst
->Src
[i
].Register
.File
!= TGSI_FILE_CONSTANT
) {
1087 if (ctx
->src
[i
].rel
) {
1088 int treg
= r600_get_temp(ctx
);
1089 if ((r
= tgsi_fetch_rel_const(ctx
, ctx
->src
[i
].sel
- 512, treg
)))
1092 ctx
->src
[i
].sel
= treg
;
1093 ctx
->src
[i
].rel
= 0;
1096 int treg
= r600_get_temp(ctx
);
1097 for (k
= 0; k
< 4; k
++) {
1098 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1099 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1100 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
1101 alu
.src
[0].chan
= k
;
1102 alu
.src
[0].rel
= ctx
->src
[i
].rel
;
1108 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1112 ctx
->src
[i
].sel
= treg
;
1120 /* need to move any immediate into a temp - for trig functions which use literal for PI stuff */
1121 static int tgsi_split_literal_constant(struct r600_shader_ctx
*ctx
)
1123 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1124 struct r600_bytecode_alu alu
;
1125 int i
, j
, k
, nliteral
, r
;
1127 for (i
= 0, nliteral
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1128 if (ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
1132 for (i
= 0, j
= nliteral
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1133 if (j
> 0 && ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
1134 int treg
= r600_get_temp(ctx
);
1135 for (k
= 0; k
< 4; k
++) {
1136 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1137 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1138 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
1139 alu
.src
[0].chan
= k
;
1140 alu
.src
[0].value
= ctx
->src
[i
].value
[k
];
1146 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1150 ctx
->src
[i
].sel
= treg
;
1157 static int process_twoside_color_inputs(struct r600_shader_ctx
*ctx
)
1159 int i
, r
, count
= ctx
->shader
->ninput
;
1161 for (i
= 0; i
< count
; i
++) {
1162 if (ctx
->shader
->input
[i
].name
== TGSI_SEMANTIC_COLOR
) {
1163 unsigned back_facing_reg
= ctx
->shader
->input
[i
].potential_back_facing_reg
;
1164 if (ctx
->bc
->chip_class
>= EVERGREEN
) {
1165 if ((r
= evergreen_interp_input(ctx
, back_facing_reg
)))
1169 if (!ctx
->use_llvm
) {
1170 r
= select_twoside_color(ctx
, i
, back_facing_reg
);
1179 static int r600_shader_from_tgsi(struct r600_screen
*rscreen
,
1180 struct r600_pipe_shader
*pipeshader
,
1181 struct r600_shader_key key
)
1183 struct r600_shader
*shader
= &pipeshader
->shader
;
1184 struct tgsi_token
*tokens
= pipeshader
->selector
->tokens
;
1185 struct pipe_stream_output_info so
= pipeshader
->selector
->so
;
1186 struct tgsi_full_immediate
*immediate
;
1187 struct tgsi_full_property
*property
;
1188 struct r600_shader_ctx ctx
;
1189 struct r600_bytecode_output output
[32];
1190 unsigned output_done
, noutput
;
1193 int next_pixel_base
= 0, next_pos_base
= 60, next_param_base
= 0;
1194 /* Declarations used by llvm code */
1195 bool use_llvm
= false;
1196 unsigned char * inst_bytes
= NULL
;
1197 unsigned inst_byte_count
= 0;
1199 #ifdef R600_USE_LLVM
1200 use_llvm
= debug_get_bool_option("R600_LLVM", TRUE
);
1202 ctx
.bc
= &shader
->bc
;
1203 ctx
.shader
= shader
;
1204 ctx
.native_integers
= true;
1206 r600_bytecode_init(ctx
.bc
, rscreen
->chip_class
, rscreen
->family
,
1207 rscreen
->msaa_texture_support
);
1208 ctx
.tokens
= tokens
;
1209 tgsi_scan_shader(tokens
, &ctx
.info
);
1210 tgsi_parse_init(&ctx
.parse
, tokens
);
1211 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
1212 shader
->processor_type
= ctx
.type
;
1213 ctx
.bc
->type
= shader
->processor_type
;
1216 ctx
.fragcoord_input
= -1;
1217 ctx
.colors_used
= 0;
1218 ctx
.clip_vertex_write
= 0;
1220 shader
->nr_ps_color_exports
= 0;
1221 shader
->nr_ps_max_color_exports
= 0;
1223 shader
->two_side
= key
.color_two_side
;
1225 /* register allocations */
1226 /* Values [0,127] correspond to GPR[0..127].
1227 * Values [128,159] correspond to constant buffer bank 0
1228 * Values [160,191] correspond to constant buffer bank 1
1229 * Values [256,511] correspond to cfile constants c[0..255]. (Gone on EG)
1230 * Values [256,287] correspond to constant buffer bank 2 (EG)
1231 * Values [288,319] correspond to constant buffer bank 3 (EG)
1232 * Other special values are shown in the list below.
1233 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
1234 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
1235 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
1236 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
1237 * 248 SQ_ALU_SRC_0: special constant 0.0.
1238 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
1239 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
1240 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
1241 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
1242 * 253 SQ_ALU_SRC_LITERAL: literal constant.
1243 * 254 SQ_ALU_SRC_PV: previous vector result.
1244 * 255 SQ_ALU_SRC_PS: previous scalar result.
1246 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
1247 ctx
.file_offset
[i
] = 0;
1249 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
1250 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
1251 if (ctx
.bc
->chip_class
>= EVERGREEN
) {
1252 r600_bytecode_add_cfinst(ctx
.bc
, EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
1254 r600_bytecode_add_cfinst(ctx
.bc
, V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
1257 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
.bc
->chip_class
>= EVERGREEN
) {
1258 ctx
.file_offset
[TGSI_FILE_INPUT
] = evergreen_gpr_count(&ctx
);
1261 #ifdef R600_USE_LLVM
1262 if (use_llvm
&& ctx
.info
.indirect_files
) {
1263 fprintf(stderr
, "Warning: R600 LLVM backend does not support "
1264 "indirect adressing. Falling back to TGSI "
1269 ctx
.use_llvm
= use_llvm
;
1272 ctx
.file_offset
[TGSI_FILE_OUTPUT
] =
1273 ctx
.file_offset
[TGSI_FILE_INPUT
];
1275 ctx
.file_offset
[TGSI_FILE_OUTPUT
] =
1276 ctx
.file_offset
[TGSI_FILE_INPUT
] +
1277 ctx
.info
.file_max
[TGSI_FILE_INPUT
] + 1;
1279 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
1280 ctx
.info
.file_max
[TGSI_FILE_OUTPUT
] + 1;
1282 /* Outside the GPR range. This will be translated to one of the
1283 * kcache banks later. */
1284 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 512;
1286 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = V_SQ_ALU_SRC_LITERAL
;
1287 ctx
.bc
->ar_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
1288 ctx
.info
.file_max
[TGSI_FILE_TEMPORARY
] + 1;
1289 ctx
.temp_reg
= ctx
.bc
->ar_reg
+ 1;
1292 ctx
.literals
= NULL
;
1293 shader
->fs_write_all
= FALSE
;
1294 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
1295 tgsi_parse_token(&ctx
.parse
);
1296 switch (ctx
.parse
.FullToken
.Token
.Type
) {
1297 case TGSI_TOKEN_TYPE_IMMEDIATE
:
1298 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
1299 ctx
.literals
= realloc(ctx
.literals
, (ctx
.nliterals
+ 1) * 16);
1300 if(ctx
.literals
== NULL
) {
1304 ctx
.literals
[ctx
.nliterals
* 4 + 0] = immediate
->u
[0].Uint
;
1305 ctx
.literals
[ctx
.nliterals
* 4 + 1] = immediate
->u
[1].Uint
;
1306 ctx
.literals
[ctx
.nliterals
* 4 + 2] = immediate
->u
[2].Uint
;
1307 ctx
.literals
[ctx
.nliterals
* 4 + 3] = immediate
->u
[3].Uint
;
1310 case TGSI_TOKEN_TYPE_DECLARATION
:
1311 r
= tgsi_declaration(&ctx
);
1315 case TGSI_TOKEN_TYPE_INSTRUCTION
:
1317 case TGSI_TOKEN_TYPE_PROPERTY
:
1318 property
= &ctx
.parse
.FullToken
.FullProperty
;
1319 switch (property
->Property
.PropertyName
) {
1320 case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS
:
1321 if (property
->u
[0].Data
== 1)
1322 shader
->fs_write_all
= TRUE
;
1324 case TGSI_PROPERTY_VS_PROHIBIT_UCPS
:
1325 /* we don't need this one */
1330 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
1336 /* Process two side if needed */
1337 if (shader
->two_side
&& ctx
.colors_used
) {
1338 int i
, count
= ctx
.shader
->ninput
;
1339 unsigned next_lds_loc
= ctx
.shader
->nlds
;
1341 /* additional inputs will be allocated right after the existing inputs,
1342 * we won't need them after the color selection, so we don't need to
1343 * reserve these gprs for the rest of the shader code and to adjust
1344 * output offsets etc. */
1345 int gpr
= ctx
.file_offset
[TGSI_FILE_INPUT
] +
1346 ctx
.info
.file_max
[TGSI_FILE_INPUT
] + 1;
1348 if (ctx
.face_gpr
== -1) {
1349 i
= ctx
.shader
->ninput
++;
1350 ctx
.shader
->input
[i
].name
= TGSI_SEMANTIC_FACE
;
1351 ctx
.shader
->input
[i
].spi_sid
= 0;
1352 ctx
.shader
->input
[i
].gpr
= gpr
++;
1353 ctx
.face_gpr
= ctx
.shader
->input
[i
].gpr
;
1356 for (i
= 0; i
< count
; i
++) {
1357 if (ctx
.shader
->input
[i
].name
== TGSI_SEMANTIC_COLOR
) {
1358 int ni
= ctx
.shader
->ninput
++;
1359 memcpy(&ctx
.shader
->input
[ni
],&ctx
.shader
->input
[i
], sizeof(struct r600_shader_io
));
1360 ctx
.shader
->input
[ni
].name
= TGSI_SEMANTIC_BCOLOR
;
1361 ctx
.shader
->input
[ni
].spi_sid
= r600_spi_sid(&ctx
.shader
->input
[ni
]);
1362 ctx
.shader
->input
[ni
].gpr
= gpr
++;
1363 // TGSI to LLVM needs to know the lds position of inputs.
1364 // Non LLVM path computes it later (in process_twoside_color)
1365 ctx
.shader
->input
[ni
].lds_pos
= next_lds_loc
++;
1366 ctx
.shader
->input
[i
].potential_back_facing_reg
= ni
;
1371 /* LLVM backend setup */
1372 #ifdef R600_USE_LLVM
1374 struct radeon_llvm_context radeon_llvm_ctx
;
1377 memset(&radeon_llvm_ctx
, 0, sizeof(radeon_llvm_ctx
));
1378 radeon_llvm_ctx
.reserved_reg_count
= ctx
.file_offset
[TGSI_FILE_INPUT
];
1379 radeon_llvm_ctx
.type
= ctx
.type
;
1380 radeon_llvm_ctx
.two_side
= shader
->two_side
;
1381 radeon_llvm_ctx
.face_input
= ctx
.face_gpr
;
1382 radeon_llvm_ctx
.r600_inputs
= ctx
.shader
->input
;
1383 radeon_llvm_ctx
.r600_outputs
= ctx
.shader
->output
;
1384 radeon_llvm_ctx
.color_buffer_count
= MAX2(key
.nr_cbufs
, 1);
1385 radeon_llvm_ctx
.chip_class
= ctx
.bc
->chip_class
;
1386 radeon_llvm_ctx
.fs_color_all
= shader
->fs_write_all
&& (rscreen
->chip_class
>= EVERGREEN
);
1387 mod
= r600_tgsi_llvm(&radeon_llvm_ctx
, tokens
);
1388 if (debug_get_bool_option("R600_DUMP_SHADERS", FALSE
)) {
1391 if (r600_llvm_compile(mod
, &inst_bytes
, &inst_byte_count
,
1392 rscreen
->family
, dump
)) {
1394 radeon_llvm_dispose(&radeon_llvm_ctx
);
1396 fprintf(stderr
, "R600 LLVM backend failed to compile "
1397 "shader. Falling back to TGSI\n");
1399 ctx
.file_offset
[TGSI_FILE_OUTPUT
] =
1400 ctx
.file_offset
[TGSI_FILE_INPUT
];
1402 radeon_llvm_dispose(&radeon_llvm_ctx
);
1405 /* End of LLVM backend setup */
1407 if (shader
->fs_write_all
&& rscreen
->chip_class
>= EVERGREEN
)
1408 shader
->nr_ps_max_color_exports
= 8;
1410 if (ctx
.fragcoord_input
>= 0 && !use_llvm
) {
1411 if (ctx
.bc
->chip_class
== CAYMAN
) {
1412 for (j
= 0 ; j
< 4; j
++) {
1413 struct r600_bytecode_alu alu
;
1414 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1415 alu
.inst
= BC_INST(ctx
.bc
, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1416 alu
.src
[0].sel
= shader
->input
[ctx
.fragcoord_input
].gpr
;
1417 alu
.src
[0].chan
= 3;
1419 alu
.dst
.sel
= shader
->input
[ctx
.fragcoord_input
].gpr
;
1421 alu
.dst
.write
= (j
== 3);
1423 if ((r
= r600_bytecode_add_alu(ctx
.bc
, &alu
)))
1427 struct r600_bytecode_alu alu
;
1428 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1429 alu
.inst
= BC_INST(ctx
.bc
, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1430 alu
.src
[0].sel
= shader
->input
[ctx
.fragcoord_input
].gpr
;
1431 alu
.src
[0].chan
= 3;
1433 alu
.dst
.sel
= shader
->input
[ctx
.fragcoord_input
].gpr
;
1437 if ((r
= r600_bytecode_add_alu(ctx
.bc
, &alu
)))
1442 if (shader
->two_side
&& ctx
.colors_used
) {
1443 if ((r
= process_twoside_color_inputs(&ctx
)))
1447 tgsi_parse_init(&ctx
.parse
, tokens
);
1448 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
1449 tgsi_parse_token(&ctx
.parse
);
1450 switch (ctx
.parse
.FullToken
.Token
.Type
) {
1451 case TGSI_TOKEN_TYPE_INSTRUCTION
:
1455 r
= tgsi_is_supported(&ctx
);
1458 ctx
.max_driver_temp_used
= 0;
1459 /* reserve first tmp for everyone */
1460 r600_get_temp(&ctx
);
1462 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
1463 if ((r
= tgsi_split_constant(&ctx
)))
1465 if ((r
= tgsi_split_literal_constant(&ctx
)))
1467 if (ctx
.bc
->chip_class
== CAYMAN
)
1468 ctx
.inst_info
= &cm_shader_tgsi_instruction
[opcode
];
1469 else if (ctx
.bc
->chip_class
>= EVERGREEN
)
1470 ctx
.inst_info
= &eg_shader_tgsi_instruction
[opcode
];
1472 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
1473 r
= ctx
.inst_info
->process(&ctx
);
1482 /* Get instructions if we are using the LLVM backend. */
1484 r600_bytecode_from_byte_stream(&ctx
, inst_bytes
, inst_byte_count
);
1488 noutput
= shader
->noutput
;
1490 if (ctx
.clip_vertex_write
) {
1491 /* need to convert a clipvertex write into clipdistance writes and not export
1492 the clip vertex anymore */
1494 memset(&shader
->output
[noutput
], 0, 2*sizeof(struct r600_shader_io
));
1495 shader
->output
[noutput
].name
= TGSI_SEMANTIC_CLIPDIST
;
1496 shader
->output
[noutput
].gpr
= ctx
.temp_reg
;
1498 shader
->output
[noutput
].name
= TGSI_SEMANTIC_CLIPDIST
;
1499 shader
->output
[noutput
].gpr
= ctx
.temp_reg
+1;
1502 /* reset spi_sid for clipvertex output to avoid confusing spi */
1503 shader
->output
[ctx
.cv_output
].spi_sid
= 0;
1505 shader
->clip_dist_write
= 0xFF;
1507 for (i
= 0; i
< 8; i
++) {
1511 for (j
= 0; j
< 4; j
++) {
1512 struct r600_bytecode_alu alu
;
1513 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1514 alu
.inst
= BC_INST(ctx
.bc
, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
);
1515 alu
.src
[0].sel
= shader
->output
[ctx
.cv_output
].gpr
;
1516 alu
.src
[0].chan
= j
;
1518 alu
.src
[1].sel
= 512 + i
;
1519 alu
.src
[1].kc_bank
= R600_UCP_CONST_BUFFER
;
1520 alu
.src
[1].chan
= j
;
1522 alu
.dst
.sel
= ctx
.temp_reg
+ oreg
;
1524 alu
.dst
.write
= (j
== ochan
);
1527 r
= r600_bytecode_add_alu(ctx
.bc
, &alu
);
1534 /* Add stream outputs. */
1535 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
&& so
.num_outputs
) {
1536 for (i
= 0; i
< so
.num_outputs
; i
++) {
1537 struct r600_bytecode_output output
;
1539 if (so
.output
[i
].output_buffer
>= 4) {
1540 R600_ERR("exceeded the max number of stream output buffers, got: %d\n",
1541 so
.output
[i
].output_buffer
);
1545 if (so
.output
[i
].dst_offset
< so
.output
[i
].start_component
) {
1546 R600_ERR("stream_output - dst_offset cannot be less than start_component\n");
1551 memset(&output
, 0, sizeof(struct r600_bytecode_output
));
1552 output
.gpr
= shader
->output
[so
.output
[i
].register_index
].gpr
;
1553 output
.elem_size
= 0;
1554 output
.array_base
= so
.output
[i
].dst_offset
- so
.output
[i
].start_component
;
1555 output
.type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_WRITE
;
1556 output
.burst_count
= 1;
1558 /* array_size is an upper limit for the burst_count
1559 * with MEM_STREAM instructions */
1560 output
.array_size
= 0xFFF;
1561 output
.comp_mask
= ((1 << so
.output
[i
].num_components
) - 1) << so
.output
[i
].start_component
;
1562 if (ctx
.bc
->chip_class
>= EVERGREEN
) {
1563 switch (so
.output
[i
].output_buffer
) {
1565 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF0
;
1568 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF1
;
1571 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF2
;
1574 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF3
;
1578 switch (so
.output
[i
].output_buffer
) {
1580 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0
;
1583 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1
;
1586 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2
;
1589 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3
;
1593 r
= r600_bytecode_add_output(ctx
.bc
, &output
);
1600 for (i
= 0, j
= 0; i
< noutput
; i
++, j
++) {
1601 memset(&output
[j
], 0, sizeof(struct r600_bytecode_output
));
1602 output
[j
].gpr
= shader
->output
[i
].gpr
;
1603 output
[j
].elem_size
= 3;
1604 output
[j
].swizzle_x
= 0;
1605 output
[j
].swizzle_y
= 1;
1606 output
[j
].swizzle_z
= 2;
1607 output
[j
].swizzle_w
= 3;
1608 output
[j
].burst_count
= 1;
1609 output
[j
].barrier
= 1;
1610 output
[j
].type
= -1;
1611 output
[j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1613 case TGSI_PROCESSOR_VERTEX
:
1614 switch (shader
->output
[i
].name
) {
1615 case TGSI_SEMANTIC_POSITION
:
1616 output
[j
].array_base
= next_pos_base
++;
1617 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
1620 case TGSI_SEMANTIC_PSIZE
:
1621 output
[j
].array_base
= next_pos_base
++;
1622 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
1624 case TGSI_SEMANTIC_CLIPVERTEX
:
1627 case TGSI_SEMANTIC_CLIPDIST
:
1628 output
[j
].array_base
= next_pos_base
++;
1629 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
1630 /* spi_sid is 0 for clipdistance outputs that were generated
1631 * for clipvertex - we don't need to pass them to PS */
1632 if (shader
->output
[i
].spi_sid
) {
1634 /* duplicate it as PARAM to pass to the pixel shader */
1635 memcpy(&output
[j
], &output
[j
-1], sizeof(struct r600_bytecode_output
));
1636 output
[j
].array_base
= next_param_base
++;
1637 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
1640 case TGSI_SEMANTIC_FOG
:
1641 output
[j
].swizzle_y
= 4; /* 0 */
1642 output
[j
].swizzle_z
= 4; /* 0 */
1643 output
[j
].swizzle_w
= 5; /* 1 */
1647 case TGSI_PROCESSOR_FRAGMENT
:
1648 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
1649 /* never export more colors than the number of CBs */
1650 if (next_pixel_base
&& next_pixel_base
>= key
.nr_cbufs
) {
1655 output
[j
].swizzle_w
= key
.alpha_to_one
? 5 : 3;
1656 output
[j
].array_base
= next_pixel_base
++;
1657 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1658 shader
->nr_ps_color_exports
++;
1659 if (shader
->fs_write_all
&& (rscreen
->chip_class
>= EVERGREEN
)) {
1660 for (k
= 1; k
< key
.nr_cbufs
; k
++) {
1662 memset(&output
[j
], 0, sizeof(struct r600_bytecode_output
));
1663 output
[j
].gpr
= shader
->output
[i
].gpr
;
1664 output
[j
].elem_size
= 3;
1665 output
[j
].swizzle_x
= 0;
1666 output
[j
].swizzle_y
= 1;
1667 output
[j
].swizzle_z
= 2;
1668 output
[j
].swizzle_w
= key
.alpha_to_one
? 5 : 3;
1669 output
[j
].burst_count
= 1;
1670 output
[j
].barrier
= 1;
1671 output
[j
].array_base
= next_pixel_base
++;
1672 output
[j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1673 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1674 shader
->nr_ps_color_exports
++;
1677 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
1678 output
[j
].array_base
= 61;
1679 output
[j
].swizzle_x
= 2;
1680 output
[j
].swizzle_y
= 7;
1681 output
[j
].swizzle_z
= output
[j
].swizzle_w
= 7;
1682 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1683 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
) {
1684 output
[j
].array_base
= 61;
1685 output
[j
].swizzle_x
= 7;
1686 output
[j
].swizzle_y
= 1;
1687 output
[j
].swizzle_z
= output
[j
].swizzle_w
= 7;
1688 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1690 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
1696 R600_ERR("unsupported processor type %d\n", ctx
.type
);
1701 if (output
[j
].type
==-1) {
1702 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
1703 output
[j
].array_base
= next_param_base
++;
1707 /* add fake param output for vertex shader if no param is exported */
1708 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
&& next_param_base
== 0) {
1709 memset(&output
[j
], 0, sizeof(struct r600_bytecode_output
));
1711 output
[j
].elem_size
= 3;
1712 output
[j
].swizzle_x
= 7;
1713 output
[j
].swizzle_y
= 7;
1714 output
[j
].swizzle_z
= 7;
1715 output
[j
].swizzle_w
= 7;
1716 output
[j
].burst_count
= 1;
1717 output
[j
].barrier
= 1;
1718 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
1719 output
[j
].array_base
= 0;
1720 output
[j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1724 /* add fake pixel export */
1725 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& next_pixel_base
== 0) {
1726 memset(&output
[j
], 0, sizeof(struct r600_bytecode_output
));
1728 output
[j
].elem_size
= 3;
1729 output
[j
].swizzle_x
= 7;
1730 output
[j
].swizzle_y
= 7;
1731 output
[j
].swizzle_z
= 7;
1732 output
[j
].swizzle_w
= 7;
1733 output
[j
].burst_count
= 1;
1734 output
[j
].barrier
= 1;
1735 output
[j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1736 output
[j
].array_base
= 0;
1737 output
[j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1743 /* set export done on last export of each type */
1744 for (i
= noutput
- 1, output_done
= 0; i
>= 0; i
--) {
1745 if (ctx
.bc
->chip_class
< CAYMAN
) {
1746 if (i
== (noutput
- 1)) {
1747 output
[i
].end_of_program
= 1;
1750 if (!(output_done
& (1 << output
[i
].type
))) {
1751 output_done
|= (1 << output
[i
].type
);
1752 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
);
1755 /* add output to bytecode */
1756 if (!use_llvm
|| ctx
.type
!= TGSI_PROCESSOR_FRAGMENT
) {
1757 for (i
= 0; i
< noutput
; i
++) {
1758 r
= r600_bytecode_add_output(ctx
.bc
, &output
[i
]);
1763 /* add program end */
1764 if (ctx
.bc
->chip_class
== CAYMAN
)
1765 cm_bytecode_add_cf_end(ctx
.bc
);
1767 /* check GPR limit - we have 124 = 128 - 4
1768 * (4 are reserved as alu clause temporary registers) */
1769 if (ctx
.bc
->ngpr
> 124) {
1770 R600_ERR("GPR limit exceeded - shader requires %d registers\n", ctx
.bc
->ngpr
);
1776 tgsi_parse_free(&ctx
.parse
);
1780 tgsi_parse_free(&ctx
.parse
);
1784 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
1786 R600_ERR("%s tgsi opcode unsupported\n",
1787 tgsi_get_opcode_name(ctx
->inst_info
->tgsi_opcode
));
1791 static int tgsi_end(struct r600_shader_ctx
*ctx
)
1796 static void r600_bytecode_src(struct r600_bytecode_alu_src
*bc_src
,
1797 const struct r600_shader_src
*shader_src
,
1800 bc_src
->sel
= shader_src
->sel
;
1801 bc_src
->chan
= shader_src
->swizzle
[chan
];
1802 bc_src
->neg
= shader_src
->neg
;
1803 bc_src
->abs
= shader_src
->abs
;
1804 bc_src
->rel
= shader_src
->rel
;
1805 bc_src
->value
= shader_src
->value
[bc_src
->chan
];
1808 static void r600_bytecode_src_set_abs(struct r600_bytecode_alu_src
*bc_src
)
1814 static void r600_bytecode_src_toggle_neg(struct r600_bytecode_alu_src
*bc_src
)
1816 bc_src
->neg
= !bc_src
->neg
;
1819 static void tgsi_dst(struct r600_shader_ctx
*ctx
,
1820 const struct tgsi_full_dst_register
*tgsi_dst
,
1822 struct r600_bytecode_alu_dst
*r600_dst
)
1824 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1826 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
1827 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
1828 r600_dst
->chan
= swizzle
;
1829 r600_dst
->write
= 1;
1830 if (tgsi_dst
->Register
.Indirect
)
1831 r600_dst
->rel
= V_SQ_REL_RELATIVE
;
1832 if (inst
->Instruction
.Saturate
) {
1833 r600_dst
->clamp
= 1;
1837 static int tgsi_last_instruction(unsigned writemask
)
1841 for (i
= 0; i
< 4; i
++) {
1842 if (writemask
& (1 << i
)) {
1849 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
, int trans_only
)
1851 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1852 struct r600_bytecode_alu alu
;
1854 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1856 for (i
= 0; i
< lasti
+ 1; i
++) {
1857 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1860 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1861 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1863 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1865 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1866 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
1869 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
1870 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
1872 /* handle some special cases */
1873 switch (ctx
->inst_info
->tgsi_opcode
) {
1874 case TGSI_OPCODE_SUB
:
1875 r600_bytecode_src_toggle_neg(&alu
.src
[1]);
1877 case TGSI_OPCODE_ABS
:
1878 r600_bytecode_src_set_abs(&alu
.src
[0]);
1883 if (i
== lasti
|| trans_only
) {
1886 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1893 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
1895 return tgsi_op2_s(ctx
, 0, 0);
1898 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
1900 return tgsi_op2_s(ctx
, 1, 0);
1903 static int tgsi_op2_trans(struct r600_shader_ctx
*ctx
)
1905 return tgsi_op2_s(ctx
, 0, 1);
1908 static int tgsi_ineg(struct r600_shader_ctx
*ctx
)
1910 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1911 struct r600_bytecode_alu alu
;
1913 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1915 for (i
= 0; i
< lasti
+ 1; i
++) {
1917 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1919 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1920 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1922 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1924 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
1926 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1931 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1939 static int cayman_emit_float_instr(struct r600_shader_ctx
*ctx
)
1941 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1943 struct r600_bytecode_alu alu
;
1944 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
1946 for (i
= 0 ; i
< last_slot
; i
++) {
1947 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1948 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1949 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1950 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], 0);
1952 /* RSQ should take the absolute value of src */
1953 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_RSQ
) {
1954 r600_bytecode_src_set_abs(&alu
.src
[j
]);
1957 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1958 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1960 if (i
== last_slot
- 1)
1962 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1969 static int cayman_mul_int_instr(struct r600_shader_ctx
*ctx
)
1971 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1973 struct r600_bytecode_alu alu
;
1974 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
1975 for (k
= 0; k
< last_slot
; k
++) {
1976 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << k
)))
1979 for (i
= 0 ; i
< 4; i
++) {
1980 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1981 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1982 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1983 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], k
);
1985 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1986 alu
.dst
.write
= (i
== k
);
1989 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1998 * r600 - trunc to -PI..PI range
1999 * r700 - normalize by dividing by 2PI
2002 static int tgsi_setup_trig(struct r600_shader_ctx
*ctx
)
2004 static float half_inv_pi
= 1.0 /(3.1415926535 * 2);
2005 static float double_pi
= 3.1415926535 * 2;
2006 static float neg_pi
= -3.1415926535;
2009 struct r600_bytecode_alu alu
;
2011 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2012 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2016 alu
.dst
.sel
= ctx
->temp_reg
;
2019 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
2021 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
2022 alu
.src
[1].chan
= 0;
2023 alu
.src
[1].value
= *(uint32_t *)&half_inv_pi
;
2024 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
2025 alu
.src
[2].chan
= 0;
2027 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2031 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2032 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
2035 alu
.dst
.sel
= ctx
->temp_reg
;
2038 alu
.src
[0].sel
= ctx
->temp_reg
;
2039 alu
.src
[0].chan
= 0;
2041 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2045 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2046 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2050 alu
.dst
.sel
= ctx
->temp_reg
;
2053 alu
.src
[0].sel
= ctx
->temp_reg
;
2054 alu
.src
[0].chan
= 0;
2056 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
2057 alu
.src
[1].chan
= 0;
2058 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
2059 alu
.src
[2].chan
= 0;
2061 if (ctx
->bc
->chip_class
== R600
) {
2062 alu
.src
[1].value
= *(uint32_t *)&double_pi
;
2063 alu
.src
[2].value
= *(uint32_t *)&neg_pi
;
2065 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2066 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
2071 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2077 static int cayman_trig(struct r600_shader_ctx
*ctx
)
2079 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2080 struct r600_bytecode_alu alu
;
2081 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
2084 r
= tgsi_setup_trig(ctx
);
2089 for (i
= 0; i
< last_slot
; i
++) {
2090 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2091 alu
.inst
= ctx
->inst_info
->r600_opcode
;
2094 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2095 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
2097 alu
.src
[0].sel
= ctx
->temp_reg
;
2098 alu
.src
[0].chan
= 0;
2099 if (i
== last_slot
- 1)
2101 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2108 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
2110 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2111 struct r600_bytecode_alu alu
;
2113 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
2115 r
= tgsi_setup_trig(ctx
);
2119 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2120 alu
.inst
= ctx
->inst_info
->r600_opcode
;
2122 alu
.dst
.sel
= ctx
->temp_reg
;
2125 alu
.src
[0].sel
= ctx
->temp_reg
;
2126 alu
.src
[0].chan
= 0;
2128 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2132 /* replicate result */
2133 for (i
= 0; i
< lasti
+ 1; i
++) {
2134 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
2137 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2138 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2140 alu
.src
[0].sel
= ctx
->temp_reg
;
2141 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2144 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2151 static int tgsi_scs(struct r600_shader_ctx
*ctx
)
2153 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2154 struct r600_bytecode_alu alu
;
2157 /* We'll only need the trig stuff if we are going to write to the
2158 * X or Y components of the destination vector.
2160 if (likely(inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_XY
)) {
2161 r
= tgsi_setup_trig(ctx
);
2167 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_X
) {
2168 if (ctx
->bc
->chip_class
== CAYMAN
) {
2169 for (i
= 0 ; i
< 3; i
++) {
2170 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2171 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
2172 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2178 alu
.src
[0].sel
= ctx
->temp_reg
;
2179 alu
.src
[0].chan
= 0;
2182 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2187 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2188 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
2189 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
2191 alu
.src
[0].sel
= ctx
->temp_reg
;
2192 alu
.src
[0].chan
= 0;
2194 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2201 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Y
) {
2202 if (ctx
->bc
->chip_class
== CAYMAN
) {
2203 for (i
= 0 ; i
< 3; i
++) {
2204 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2205 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
2206 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2211 alu
.src
[0].sel
= ctx
->temp_reg
;
2212 alu
.src
[0].chan
= 0;
2215 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2220 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2221 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
2222 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
2224 alu
.src
[0].sel
= ctx
->temp_reg
;
2225 alu
.src
[0].chan
= 0;
2227 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2234 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Z
) {
2235 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2237 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2239 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
2241 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2242 alu
.src
[0].chan
= 0;
2246 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2252 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
2253 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2255 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2257 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
2259 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2260 alu
.src
[0].chan
= 0;
2264 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2272 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
2274 struct r600_bytecode_alu alu
;
2277 for (i
= 0; i
< 4; i
++) {
2278 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2279 alu
.inst
= ctx
->inst_info
->r600_opcode
;
2283 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2285 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
2286 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2289 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
2294 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2299 /* kill must be last in ALU */
2300 ctx
->bc
->force_add_cf
= 1;
2301 ctx
->shader
->uses_kill
= TRUE
;
2305 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
2307 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2308 struct r600_bytecode_alu alu
;
2311 /* tmp.x = max(src.y, 0.0) */
2312 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2313 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
2314 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 1);
2315 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
2316 alu
.src
[1].chan
= 1;
2318 alu
.dst
.sel
= ctx
->temp_reg
;
2323 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2327 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
2333 if (ctx
->bc
->chip_class
== CAYMAN
) {
2334 for (i
= 0; i
< 3; i
++) {
2335 /* tmp.z = log(tmp.x) */
2336 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2337 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
2338 alu
.src
[0].sel
= ctx
->temp_reg
;
2339 alu
.src
[0].chan
= 0;
2340 alu
.dst
.sel
= ctx
->temp_reg
;
2348 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2353 /* tmp.z = log(tmp.x) */
2354 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2355 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
2356 alu
.src
[0].sel
= ctx
->temp_reg
;
2357 alu
.src
[0].chan
= 0;
2358 alu
.dst
.sel
= ctx
->temp_reg
;
2362 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2367 chan
= alu
.dst
.chan
;
2370 /* tmp.x = amd MUL_LIT(tmp.z, src.w, src.x ) */
2371 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2372 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
2373 alu
.src
[0].sel
= sel
;
2374 alu
.src
[0].chan
= chan
;
2375 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], 3);
2376 r600_bytecode_src(&alu
.src
[2], &ctx
->src
[0], 0);
2377 alu
.dst
.sel
= ctx
->temp_reg
;
2382 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2386 if (ctx
->bc
->chip_class
== CAYMAN
) {
2387 for (i
= 0; i
< 3; i
++) {
2388 /* dst.z = exp(tmp.x) */
2389 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2390 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2391 alu
.src
[0].sel
= ctx
->temp_reg
;
2392 alu
.src
[0].chan
= 0;
2393 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2399 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2404 /* dst.z = exp(tmp.x) */
2405 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2406 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2407 alu
.src
[0].sel
= ctx
->temp_reg
;
2408 alu
.src
[0].chan
= 0;
2409 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
2411 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2418 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2419 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2420 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
2421 alu
.src
[0].chan
= 0;
2422 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
2423 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
2424 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2428 /* dst.y = max(src.x, 0.0) */
2429 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2430 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
2431 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
2432 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
2433 alu
.src
[1].chan
= 0;
2434 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
2435 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
2436 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2441 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2442 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2443 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2444 alu
.src
[0].chan
= 0;
2445 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
2446 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
2448 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2455 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
2457 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2458 struct r600_bytecode_alu alu
;
2461 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2464 * For state trackers other than OpenGL, we'll want to use
2465 * _RECIPSQRT_IEEE instead.
2467 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
2469 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
2470 r600_bytecode_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
2471 r600_bytecode_src_set_abs(&alu
.src
[i
]);
2473 alu
.dst
.sel
= ctx
->temp_reg
;
2476 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2479 /* replicate result */
2480 return tgsi_helper_tempx_replicate(ctx
);
2483 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
2485 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2486 struct r600_bytecode_alu alu
;
2489 for (i
= 0; i
< 4; i
++) {
2490 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2491 alu
.src
[0].sel
= ctx
->temp_reg
;
2492 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2494 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2495 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
2498 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2505 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
2507 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2508 struct r600_bytecode_alu alu
;
2511 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2512 alu
.inst
= ctx
->inst_info
->r600_opcode
;
2513 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
2514 r600_bytecode_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
2516 alu
.dst
.sel
= ctx
->temp_reg
;
2519 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2522 /* replicate result */
2523 return tgsi_helper_tempx_replicate(ctx
);
2526 static int cayman_pow(struct r600_shader_ctx
*ctx
)
2528 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2530 struct r600_bytecode_alu alu
;
2531 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
2533 for (i
= 0; i
< 3; i
++) {
2534 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2535 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2536 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
2537 alu
.dst
.sel
= ctx
->temp_reg
;
2542 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2548 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2549 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2550 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], 0);
2551 alu
.src
[1].sel
= ctx
->temp_reg
;
2552 alu
.dst
.sel
= ctx
->temp_reg
;
2555 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2559 for (i
= 0; i
< last_slot
; i
++) {
2560 /* POW(a,b) = EXP2(b * LOG2(a))*/
2561 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2562 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2563 alu
.src
[0].sel
= ctx
->temp_reg
;
2565 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2566 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
2567 if (i
== last_slot
- 1)
2569 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2576 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
2578 struct r600_bytecode_alu alu
;
2582 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2583 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2584 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
2585 alu
.dst
.sel
= ctx
->temp_reg
;
2588 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2592 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2593 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2594 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], 0);
2595 alu
.src
[1].sel
= ctx
->temp_reg
;
2596 alu
.dst
.sel
= ctx
->temp_reg
;
2599 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2602 /* POW(a,b) = EXP2(b * LOG2(a))*/
2603 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2604 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2605 alu
.src
[0].sel
= ctx
->temp_reg
;
2606 alu
.dst
.sel
= ctx
->temp_reg
;
2609 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2612 return tgsi_helper_tempx_replicate(ctx
);
2615 static int tgsi_divmod(struct r600_shader_ctx
*ctx
, int mod
, int signed_op
)
2617 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2618 struct r600_bytecode_alu alu
;
2620 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
2621 int tmp0
= ctx
->temp_reg
;
2622 int tmp1
= r600_get_temp(ctx
);
2623 int tmp2
= r600_get_temp(ctx
);
2624 int tmp3
= r600_get_temp(ctx
);
2627 * we need to represent src1 as src2*q + r, where q - quotient, r - remainder
2629 * 1. tmp0.x = rcp (src2) = 2^32/src2 + e, where e is rounding error
2630 * 2. tmp0.z = lo (tmp0.x * src2)
2631 * 3. tmp0.w = -tmp0.z
2632 * 4. tmp0.y = hi (tmp0.x * src2)
2633 * 5. tmp0.z = (tmp0.y == 0 ? tmp0.w : tmp0.z) = abs(lo(rcp*src2))
2634 * 6. tmp0.w = hi (tmp0.z * tmp0.x) = e, rounding error
2635 * 7. tmp1.x = tmp0.x - tmp0.w
2636 * 8. tmp1.y = tmp0.x + tmp0.w
2637 * 9. tmp0.x = (tmp0.y == 0 ? tmp1.y : tmp1.x)
2638 * 10. tmp0.z = hi(tmp0.x * src1) = q
2639 * 11. tmp0.y = lo (tmp0.z * src2) = src2*q = src1 - r
2641 * 12. tmp0.w = src1 - tmp0.y = r
2642 * 13. tmp1.x = tmp0.w >= src2 = r >= src2 (uint comparison)
2643 * 14. tmp1.y = src1 >= tmp0.y = r >= 0 (uint comparison)
2647 * 15. tmp1.z = tmp0.z + 1 = q + 1
2648 * 16. tmp1.w = tmp0.z - 1 = q - 1
2652 * 15. tmp1.z = tmp0.w - src2 = r - src2
2653 * 16. tmp1.w = tmp0.w + src2 = r + src2
2657 * 17. tmp1.x = tmp1.x & tmp1.y
2659 * DIV: 18. tmp0.z = tmp1.x==0 ? tmp0.z : tmp1.z
2660 * MOD: 18. tmp0.z = tmp1.x==0 ? tmp0.w : tmp1.z
2662 * 19. tmp0.z = tmp1.y==0 ? tmp1.w : tmp0.z
2663 * 20. dst = src2==0 ? MAX_UINT : tmp0.z
2667 * Same as unsigned, using abs values of the operands,
2668 * and fixing the sign of the result in the end.
2671 for (i
= 0; i
< 4; i
++) {
2672 if (!(write_mask
& (1<<i
)))
2677 /* tmp2.x = -src0 */
2678 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2679 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
2685 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2687 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
2690 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2693 /* tmp2.y = -src1 */
2694 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2695 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
2701 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2703 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2706 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2709 /* tmp2.z sign bit is set if src0 and src2 signs are different */
2710 /* it will be a sign of the quotient */
2713 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2714 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
);
2720 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
2721 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2724 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2728 /* tmp2.x = |src0| */
2729 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2730 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
2737 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
2738 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
2739 alu
.src
[2].sel
= tmp2
;
2740 alu
.src
[2].chan
= 0;
2743 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2746 /* tmp2.y = |src1| */
2747 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2748 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
2755 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
2756 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2757 alu
.src
[2].sel
= tmp2
;
2758 alu
.src
[2].chan
= 1;
2761 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2766 /* 1. tmp0.x = rcp_u (src2) = 2^32/src2 + e, where e is rounding error */
2767 if (ctx
->bc
->chip_class
== CAYMAN
) {
2768 /* tmp3.x = u2f(src2) */
2769 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2770 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
);
2777 alu
.src
[0].sel
= tmp2
;
2778 alu
.src
[0].chan
= 1;
2780 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
2784 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2787 /* tmp0.x = recip(tmp3.x) */
2788 for (j
= 0 ; j
< 3; j
++) {
2789 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2790 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
;
2794 alu
.dst
.write
= (j
== 0);
2796 alu
.src
[0].sel
= tmp3
;
2797 alu
.src
[0].chan
= 0;
2801 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2805 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2806 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2808 alu
.src
[0].sel
= tmp0
;
2809 alu
.src
[0].chan
= 0;
2811 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
2812 alu
.src
[1].value
= 0x4f800000;
2817 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2821 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2822 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
);
2828 alu
.src
[0].sel
= tmp3
;
2829 alu
.src
[0].chan
= 0;
2832 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2836 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2837 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_UINT
);
2844 alu
.src
[0].sel
= tmp2
;
2845 alu
.src
[0].chan
= 1;
2847 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
2851 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2855 /* 2. tmp0.z = lo (tmp0.x * src2) */
2856 if (ctx
->bc
->chip_class
== CAYMAN
) {
2857 for (j
= 0 ; j
< 4; j
++) {
2858 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2859 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
);
2863 alu
.dst
.write
= (j
== 2);
2865 alu
.src
[0].sel
= tmp0
;
2866 alu
.src
[0].chan
= 0;
2868 alu
.src
[1].sel
= tmp2
;
2869 alu
.src
[1].chan
= 1;
2871 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2874 alu
.last
= (j
== 3);
2875 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2879 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2880 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
);
2886 alu
.src
[0].sel
= tmp0
;
2887 alu
.src
[0].chan
= 0;
2889 alu
.src
[1].sel
= tmp2
;
2890 alu
.src
[1].chan
= 1;
2892 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2896 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2900 /* 3. tmp0.w = -tmp0.z */
2901 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2902 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
2908 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2909 alu
.src
[1].sel
= tmp0
;
2910 alu
.src
[1].chan
= 2;
2913 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2916 /* 4. tmp0.y = hi (tmp0.x * src2) */
2917 if (ctx
->bc
->chip_class
== CAYMAN
) {
2918 for (j
= 0 ; j
< 4; j
++) {
2919 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2920 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
2924 alu
.dst
.write
= (j
== 1);
2926 alu
.src
[0].sel
= tmp0
;
2927 alu
.src
[0].chan
= 0;
2930 alu
.src
[1].sel
= tmp2
;
2931 alu
.src
[1].chan
= 1;
2933 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2935 alu
.last
= (j
== 3);
2936 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2940 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2941 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
2947 alu
.src
[0].sel
= tmp0
;
2948 alu
.src
[0].chan
= 0;
2951 alu
.src
[1].sel
= tmp2
;
2952 alu
.src
[1].chan
= 1;
2954 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
2958 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2962 /* 5. tmp0.z = (tmp0.y == 0 ? tmp0.w : tmp0.z) = abs(lo(rcp*src)) */
2963 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2964 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDE_INT
);
2971 alu
.src
[0].sel
= tmp0
;
2972 alu
.src
[0].chan
= 1;
2973 alu
.src
[1].sel
= tmp0
;
2974 alu
.src
[1].chan
= 3;
2975 alu
.src
[2].sel
= tmp0
;
2976 alu
.src
[2].chan
= 2;
2979 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
2982 /* 6. tmp0.w = hi (tmp0.z * tmp0.x) = e, rounding error */
2983 if (ctx
->bc
->chip_class
== CAYMAN
) {
2984 for (j
= 0 ; j
< 4; j
++) {
2985 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2986 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
2990 alu
.dst
.write
= (j
== 3);
2992 alu
.src
[0].sel
= tmp0
;
2993 alu
.src
[0].chan
= 2;
2995 alu
.src
[1].sel
= tmp0
;
2996 alu
.src
[1].chan
= 0;
2998 alu
.last
= (j
== 3);
2999 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3003 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3004 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
3010 alu
.src
[0].sel
= tmp0
;
3011 alu
.src
[0].chan
= 2;
3013 alu
.src
[1].sel
= tmp0
;
3014 alu
.src
[1].chan
= 0;
3017 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3021 /* 7. tmp1.x = tmp0.x - tmp0.w */
3022 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3023 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
3029 alu
.src
[0].sel
= tmp0
;
3030 alu
.src
[0].chan
= 0;
3031 alu
.src
[1].sel
= tmp0
;
3032 alu
.src
[1].chan
= 3;
3035 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3038 /* 8. tmp1.y = tmp0.x + tmp0.w */
3039 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3040 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
3046 alu
.src
[0].sel
= tmp0
;
3047 alu
.src
[0].chan
= 0;
3048 alu
.src
[1].sel
= tmp0
;
3049 alu
.src
[1].chan
= 3;
3052 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3055 /* 9. tmp0.x = (tmp0.y == 0 ? tmp1.y : tmp1.x) */
3056 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3057 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDE_INT
);
3064 alu
.src
[0].sel
= tmp0
;
3065 alu
.src
[0].chan
= 1;
3066 alu
.src
[1].sel
= tmp1
;
3067 alu
.src
[1].chan
= 1;
3068 alu
.src
[2].sel
= tmp1
;
3069 alu
.src
[2].chan
= 0;
3072 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3075 /* 10. tmp0.z = hi(tmp0.x * src1) = q */
3076 if (ctx
->bc
->chip_class
== CAYMAN
) {
3077 for (j
= 0 ; j
< 4; j
++) {
3078 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3079 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
3083 alu
.dst
.write
= (j
== 2);
3085 alu
.src
[0].sel
= tmp0
;
3086 alu
.src
[0].chan
= 0;
3089 alu
.src
[1].sel
= tmp2
;
3090 alu
.src
[1].chan
= 0;
3092 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3095 alu
.last
= (j
== 3);
3096 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3100 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3101 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULHI_UINT
);
3107 alu
.src
[0].sel
= tmp0
;
3108 alu
.src
[0].chan
= 0;
3111 alu
.src
[1].sel
= tmp2
;
3112 alu
.src
[1].chan
= 0;
3114 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3118 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3122 /* 11. tmp0.y = lo (src2 * tmp0.z) = src2*q = src1 - r */
3123 if (ctx
->bc
->chip_class
== CAYMAN
) {
3124 for (j
= 0 ; j
< 4; j
++) {
3125 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3126 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
);
3130 alu
.dst
.write
= (j
== 1);
3133 alu
.src
[0].sel
= tmp2
;
3134 alu
.src
[0].chan
= 1;
3136 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
3139 alu
.src
[1].sel
= tmp0
;
3140 alu
.src
[1].chan
= 2;
3142 alu
.last
= (j
== 3);
3143 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3147 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3148 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
);
3155 alu
.src
[0].sel
= tmp2
;
3156 alu
.src
[0].chan
= 1;
3158 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
3161 alu
.src
[1].sel
= tmp0
;
3162 alu
.src
[1].chan
= 2;
3165 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3169 /* 12. tmp0.w = src1 - tmp0.y = r */
3170 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3171 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
3178 alu
.src
[0].sel
= tmp2
;
3179 alu
.src
[0].chan
= 0;
3181 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3184 alu
.src
[1].sel
= tmp0
;
3185 alu
.src
[1].chan
= 1;
3188 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3191 /* 13. tmp1.x = tmp0.w >= src2 = r >= src2 */
3192 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3193 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
);
3199 alu
.src
[0].sel
= tmp0
;
3200 alu
.src
[0].chan
= 3;
3202 alu
.src
[1].sel
= tmp2
;
3203 alu
.src
[1].chan
= 1;
3205 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
3209 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3212 /* 14. tmp1.y = src1 >= tmp0.y = r >= 0 */
3213 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3214 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
);
3221 alu
.src
[0].sel
= tmp2
;
3222 alu
.src
[0].chan
= 0;
3224 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3227 alu
.src
[1].sel
= tmp0
;
3228 alu
.src
[1].chan
= 1;
3231 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3234 if (mod
) { /* UMOD */
3236 /* 15. tmp1.z = tmp0.w - src2 = r - src2 */
3237 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3238 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
3244 alu
.src
[0].sel
= tmp0
;
3245 alu
.src
[0].chan
= 3;
3248 alu
.src
[1].sel
= tmp2
;
3249 alu
.src
[1].chan
= 1;
3251 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
3255 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3258 /* 16. tmp1.w = tmp0.w + src2 = r + src2 */
3259 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3260 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
3266 alu
.src
[0].sel
= tmp0
;
3267 alu
.src
[0].chan
= 3;
3269 alu
.src
[1].sel
= tmp2
;
3270 alu
.src
[1].chan
= 1;
3272 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
3276 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3281 /* 15. tmp1.z = tmp0.z + 1 = q + 1 DIV */
3282 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3283 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
3289 alu
.src
[0].sel
= tmp0
;
3290 alu
.src
[0].chan
= 2;
3291 alu
.src
[1].sel
= V_SQ_ALU_SRC_1_INT
;
3294 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3297 /* 16. tmp1.w = tmp0.z - 1 = q - 1 */
3298 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3299 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
3305 alu
.src
[0].sel
= tmp0
;
3306 alu
.src
[0].chan
= 2;
3307 alu
.src
[1].sel
= V_SQ_ALU_SRC_M_1_INT
;
3310 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3315 /* 17. tmp1.x = tmp1.x & tmp1.y */
3316 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3317 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
);
3323 alu
.src
[0].sel
= tmp1
;
3324 alu
.src
[0].chan
= 0;
3325 alu
.src
[1].sel
= tmp1
;
3326 alu
.src
[1].chan
= 1;
3329 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3332 /* 18. tmp0.z = tmp1.x==0 ? tmp0.z : tmp1.z DIV */
3333 /* 18. tmp0.z = tmp1.x==0 ? tmp0.w : tmp1.z MOD */
3334 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3335 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDE_INT
);
3342 alu
.src
[0].sel
= tmp1
;
3343 alu
.src
[0].chan
= 0;
3344 alu
.src
[1].sel
= tmp0
;
3345 alu
.src
[1].chan
= mod
? 3 : 2;
3346 alu
.src
[2].sel
= tmp1
;
3347 alu
.src
[2].chan
= 2;
3350 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3353 /* 19. tmp0.z = tmp1.y==0 ? tmp1.w : tmp0.z */
3354 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3355 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDE_INT
);
3363 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3366 alu
.src
[0].sel
= tmp1
;
3367 alu
.src
[0].chan
= 1;
3368 alu
.src
[1].sel
= tmp1
;
3369 alu
.src
[1].chan
= 3;
3370 alu
.src
[2].sel
= tmp0
;
3371 alu
.src
[2].chan
= 2;
3374 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3379 /* fix the sign of the result */
3383 /* tmp0.x = -tmp0.z */
3384 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3385 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
3391 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
3392 alu
.src
[1].sel
= tmp0
;
3393 alu
.src
[1].chan
= 2;
3396 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3399 /* sign of the remainder is the same as the sign of src0 */
3400 /* tmp0.x = src0>=0 ? tmp0.z : tmp0.x */
3401 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3402 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
3405 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3407 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3408 alu
.src
[1].sel
= tmp0
;
3409 alu
.src
[1].chan
= 2;
3410 alu
.src
[2].sel
= tmp0
;
3411 alu
.src
[2].chan
= 0;
3414 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3419 /* tmp0.x = -tmp0.z */
3420 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3421 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
3427 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
3428 alu
.src
[1].sel
= tmp0
;
3429 alu
.src
[1].chan
= 2;
3432 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3435 /* fix the quotient sign (same as the sign of src0*src1) */
3436 /* tmp0.x = tmp2.z>=0 ? tmp0.z : tmp0.x */
3437 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3438 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
3441 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3443 alu
.src
[0].sel
= tmp2
;
3444 alu
.src
[0].chan
= 2;
3445 alu
.src
[1].sel
= tmp0
;
3446 alu
.src
[1].chan
= 2;
3447 alu
.src
[2].sel
= tmp0
;
3448 alu
.src
[2].chan
= 0;
3451 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3459 static int tgsi_udiv(struct r600_shader_ctx
*ctx
)
3461 return tgsi_divmod(ctx
, 0, 0);
3464 static int tgsi_umod(struct r600_shader_ctx
*ctx
)
3466 return tgsi_divmod(ctx
, 1, 0);
3469 static int tgsi_idiv(struct r600_shader_ctx
*ctx
)
3471 return tgsi_divmod(ctx
, 0, 1);
3474 static int tgsi_imod(struct r600_shader_ctx
*ctx
)
3476 return tgsi_divmod(ctx
, 1, 1);
3480 static int tgsi_f2i(struct r600_shader_ctx
*ctx
)
3482 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3483 struct r600_bytecode_alu alu
;
3485 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
3486 int last_inst
= tgsi_last_instruction(write_mask
);
3488 for (i
= 0; i
< 4; i
++) {
3489 if (!(write_mask
& (1<<i
)))
3492 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3493 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
);
3495 alu
.dst
.sel
= ctx
->temp_reg
;
3499 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3502 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3507 for (i
= 0; i
< 4; i
++) {
3508 if (!(write_mask
& (1<<i
)))
3511 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3512 alu
.inst
= ctx
->inst_info
->r600_opcode
;
3514 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3516 alu
.src
[0].sel
= ctx
->temp_reg
;
3517 alu
.src
[0].chan
= i
;
3519 if (i
== last_inst
|| alu
.inst
== EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
)
3521 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3529 static int tgsi_iabs(struct r600_shader_ctx
*ctx
)
3531 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3532 struct r600_bytecode_alu alu
;
3534 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
3535 int last_inst
= tgsi_last_instruction(write_mask
);
3538 for (i
= 0; i
< 4; i
++) {
3539 if (!(write_mask
& (1<<i
)))
3542 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3543 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
3545 alu
.dst
.sel
= ctx
->temp_reg
;
3549 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3550 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
3554 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3559 /* dst = (src >= 0 ? src : tmp) */
3560 for (i
= 0; i
< 4; i
++) {
3561 if (!(write_mask
& (1<<i
)))
3564 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3565 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
3569 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3571 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3572 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3573 alu
.src
[2].sel
= ctx
->temp_reg
;
3574 alu
.src
[2].chan
= i
;
3578 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3585 static int tgsi_issg(struct r600_shader_ctx
*ctx
)
3587 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3588 struct r600_bytecode_alu alu
;
3590 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
3591 int last_inst
= tgsi_last_instruction(write_mask
);
3593 /* tmp = (src >= 0 ? src : -1) */
3594 for (i
= 0; i
< 4; i
++) {
3595 if (!(write_mask
& (1<<i
)))
3598 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3599 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
3602 alu
.dst
.sel
= ctx
->temp_reg
;
3606 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3607 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3608 alu
.src
[2].sel
= V_SQ_ALU_SRC_M_1_INT
;
3612 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3617 /* dst = (tmp > 0 ? 1 : tmp) */
3618 for (i
= 0; i
< 4; i
++) {
3619 if (!(write_mask
& (1<<i
)))
3622 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3623 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT_INT
);
3627 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3629 alu
.src
[0].sel
= ctx
->temp_reg
;
3630 alu
.src
[0].chan
= i
;
3632 alu
.src
[1].sel
= V_SQ_ALU_SRC_1_INT
;
3634 alu
.src
[2].sel
= ctx
->temp_reg
;
3635 alu
.src
[2].chan
= i
;
3639 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3648 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
3650 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3651 struct r600_bytecode_alu alu
;
3654 /* tmp = (src > 0 ? 1 : src) */
3655 for (i
= 0; i
< 4; i
++) {
3656 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3657 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
3660 alu
.dst
.sel
= ctx
->temp_reg
;
3663 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3664 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
3665 r600_bytecode_src(&alu
.src
[2], &ctx
->src
[0], i
);
3669 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3674 /* dst = (-tmp > 0 ? -1 : tmp) */
3675 for (i
= 0; i
< 4; i
++) {
3676 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3677 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
3679 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3681 alu
.src
[0].sel
= ctx
->temp_reg
;
3682 alu
.src
[0].chan
= i
;
3685 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
3688 alu
.src
[2].sel
= ctx
->temp_reg
;
3689 alu
.src
[2].chan
= i
;
3693 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3700 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
3702 struct r600_bytecode_alu alu
;
3705 for (i
= 0; i
< 4; i
++) {
3706 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3707 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
3708 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
3711 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
3712 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3713 alu
.src
[0].sel
= ctx
->temp_reg
;
3714 alu
.src
[0].chan
= i
;
3719 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3726 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
3728 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3729 struct r600_bytecode_alu alu
;
3731 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
3733 for (i
= 0; i
< lasti
+ 1; i
++) {
3734 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
3737 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3738 alu
.inst
= ctx
->inst_info
->r600_opcode
;
3739 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
3740 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
3743 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3750 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3757 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
3759 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3760 struct r600_bytecode_alu alu
;
3763 for (i
= 0; i
< 4; i
++) {
3764 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3765 alu
.inst
= ctx
->inst_info
->r600_opcode
;
3766 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
3767 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
3770 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3772 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
3773 /* handle some special cases */
3774 switch (ctx
->inst_info
->tgsi_opcode
) {
3775 case TGSI_OPCODE_DP2
:
3777 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
3778 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
3781 case TGSI_OPCODE_DP3
:
3783 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
3784 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
3787 case TGSI_OPCODE_DPH
:
3789 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
3790 alu
.src
[0].chan
= 0;
3800 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3807 static inline boolean
tgsi_tex_src_requires_loading(struct r600_shader_ctx
*ctx
,
3810 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3811 return (inst
->Src
[index
].Register
.File
!= TGSI_FILE_TEMPORARY
&&
3812 inst
->Src
[index
].Register
.File
!= TGSI_FILE_INPUT
&&
3813 inst
->Src
[index
].Register
.File
!= TGSI_FILE_OUTPUT
) ||
3814 ctx
->src
[index
].neg
|| ctx
->src
[index
].abs
;
3817 static inline unsigned tgsi_tex_get_src_gpr(struct r600_shader_ctx
*ctx
,
3820 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3821 return ctx
->file_offset
[inst
->Src
[index
].Register
.File
] + inst
->Src
[index
].Register
.Index
;
3824 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
3826 static float one_point_five
= 1.5f
;
3827 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3828 struct r600_bytecode_tex tex
;
3829 struct r600_bytecode_alu alu
;
3833 bool read_compressed_msaa
= ctx
->bc
->msaa_texture_mode
== MSAA_TEXTURE_COMPRESSED
&&
3834 inst
->Instruction
.Opcode
== TGSI_OPCODE_TXF
&&
3835 (inst
->Texture
.Texture
== TGSI_TEXTURE_2D_MSAA
||
3836 inst
->Texture
.Texture
== TGSI_TEXTURE_2D_ARRAY_MSAA
);
3837 /* Texture fetch instructions can only use gprs as source.
3838 * Also they cannot negate the source or take the absolute value */
3839 const boolean src_requires_loading
= (inst
->Instruction
.Opcode
!= TGSI_OPCODE_TXQ_LZ
&&
3840 tgsi_tex_src_requires_loading(ctx
, 0)) ||
3841 read_compressed_msaa
;
3842 boolean src_loaded
= FALSE
;
3843 unsigned sampler_src_reg
= inst
->Instruction
.Opcode
== TGSI_OPCODE_TXQ_LZ
? 0 : 1;
3844 uint8_t offset_x
= 0, offset_y
= 0, offset_z
= 0;
3845 boolean has_txq_cube_array_z
= false;
3847 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXQ
&&
3848 ((inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE_ARRAY
||
3849 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE_ARRAY
)))
3850 if (inst
->Dst
[0].Register
.WriteMask
& 4) {
3851 ctx
->shader
->has_txq_cube_array_z_comp
= true;
3852 has_txq_cube_array_z
= true;
3855 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TEX2
||
3856 inst
->Instruction
.Opcode
== TGSI_OPCODE_TXB2
||
3857 inst
->Instruction
.Opcode
== TGSI_OPCODE_TXL2
)
3858 sampler_src_reg
= 2;
3860 src_gpr
= tgsi_tex_get_src_gpr(ctx
, 0);
3862 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXF
) {
3863 /* get offset values */
3864 if (inst
->Texture
.NumOffsets
) {
3865 assert(inst
->Texture
.NumOffsets
== 1);
3867 offset_x
= ctx
->literals
[inst
->TexOffsets
[0].Index
+ inst
->TexOffsets
[0].SwizzleX
] << 1;
3868 offset_y
= ctx
->literals
[inst
->TexOffsets
[0].Index
+ inst
->TexOffsets
[0].SwizzleY
] << 1;
3869 offset_z
= ctx
->literals
[inst
->TexOffsets
[0].Index
+ inst
->TexOffsets
[0].SwizzleZ
] << 1;
3871 } else if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXD
) {
3872 /* TGSI moves the sampler to src reg 3 for TXD */
3873 sampler_src_reg
= 3;
3875 for (i
= 1; i
< 3; i
++) {
3876 /* set gradients h/v */
3877 memset(&tex
, 0, sizeof(struct r600_bytecode_tex
));
3878 tex
.inst
= (i
== 1) ? SQ_TEX_INST_SET_GRADIENTS_H
:
3879 SQ_TEX_INST_SET_GRADIENTS_V
;
3880 tex
.sampler_id
= tgsi_tex_get_src_gpr(ctx
, sampler_src_reg
);
3881 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
3883 if (tgsi_tex_src_requires_loading(ctx
, i
)) {
3884 tex
.src_gpr
= r600_get_temp(ctx
);
3890 for (j
= 0; j
< 4; j
++) {
3891 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3892 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
3893 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[i
], j
);
3894 alu
.dst
.sel
= tex
.src_gpr
;
3899 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3905 tex
.src_gpr
= tgsi_tex_get_src_gpr(ctx
, i
);
3906 tex
.src_sel_x
= ctx
->src
[i
].swizzle
[0];
3907 tex
.src_sel_y
= ctx
->src
[i
].swizzle
[1];
3908 tex
.src_sel_z
= ctx
->src
[i
].swizzle
[2];
3909 tex
.src_sel_w
= ctx
->src
[i
].swizzle
[3];
3910 tex
.src_rel
= ctx
->src
[i
].rel
;
3912 tex
.dst_gpr
= ctx
->temp_reg
; /* just to avoid confusing the asm scheduler */
3913 tex
.dst_sel_x
= tex
.dst_sel_y
= tex
.dst_sel_z
= tex
.dst_sel_w
= 7;
3914 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
3915 tex
.coord_type_x
= 1;
3916 tex
.coord_type_y
= 1;
3917 tex
.coord_type_z
= 1;
3918 tex
.coord_type_w
= 1;
3920 r
= r600_bytecode_add_tex(ctx
->bc
, &tex
);
3924 } else if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
3926 /* Add perspective divide */
3927 if (ctx
->bc
->chip_class
== CAYMAN
) {
3929 for (i
= 0; i
< 3; i
++) {
3930 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3931 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
3932 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 3);
3934 alu
.dst
.sel
= ctx
->temp_reg
;
3940 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3947 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3948 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
3949 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 3);
3951 alu
.dst
.sel
= ctx
->temp_reg
;
3952 alu
.dst
.chan
= out_chan
;
3955 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3960 for (i
= 0; i
< 3; i
++) {
3961 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3962 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
3963 alu
.src
[0].sel
= ctx
->temp_reg
;
3964 alu
.src
[0].chan
= out_chan
;
3965 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
3966 alu
.dst
.sel
= ctx
->temp_reg
;
3969 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3973 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3974 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
3975 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
3976 alu
.src
[0].chan
= 0;
3977 alu
.dst
.sel
= ctx
->temp_reg
;
3981 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3985 src_gpr
= ctx
->temp_reg
;
3988 if ((inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
||
3989 inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE_ARRAY
||
3990 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE
||
3991 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE_ARRAY
) &&
3992 inst
->Instruction
.Opcode
!= TGSI_OPCODE_TXQ
&&
3993 inst
->Instruction
.Opcode
!= TGSI_OPCODE_TXQ_LZ
) {
3995 static const unsigned src0_swizzle
[] = {2, 2, 0, 1};
3996 static const unsigned src1_swizzle
[] = {1, 0, 2, 2};
3998 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
3999 for (i
= 0; i
< 4; i
++) {
4000 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4001 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
4002 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], src0_swizzle
[i
]);
4003 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], src1_swizzle
[i
]);
4004 alu
.dst
.sel
= ctx
->temp_reg
;
4009 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4014 /* tmp1.z = RCP_e(|tmp1.z|) */
4015 if (ctx
->bc
->chip_class
== CAYMAN
) {
4016 for (i
= 0; i
< 3; i
++) {
4017 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4018 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
4019 alu
.src
[0].sel
= ctx
->temp_reg
;
4020 alu
.src
[0].chan
= 2;
4022 alu
.dst
.sel
= ctx
->temp_reg
;
4028 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4033 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4034 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
4035 alu
.src
[0].sel
= ctx
->temp_reg
;
4036 alu
.src
[0].chan
= 2;
4038 alu
.dst
.sel
= ctx
->temp_reg
;
4042 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4047 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
4048 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
4049 * muladd has no writemask, have to use another temp
4051 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4052 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
4055 alu
.src
[0].sel
= ctx
->temp_reg
;
4056 alu
.src
[0].chan
= 0;
4057 alu
.src
[1].sel
= ctx
->temp_reg
;
4058 alu
.src
[1].chan
= 2;
4060 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
4061 alu
.src
[2].chan
= 0;
4062 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
4064 alu
.dst
.sel
= ctx
->temp_reg
;
4068 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4072 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4073 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
4076 alu
.src
[0].sel
= ctx
->temp_reg
;
4077 alu
.src
[0].chan
= 1;
4078 alu
.src
[1].sel
= ctx
->temp_reg
;
4079 alu
.src
[1].chan
= 2;
4081 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
4082 alu
.src
[2].chan
= 0;
4083 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
4085 alu
.dst
.sel
= ctx
->temp_reg
;
4090 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4093 /* write initial compare value into Z component
4094 - W src 0 for shadow cube
4095 - X src 1 for shadow cube array */
4096 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE
||
4097 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE_ARRAY
) {
4098 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4099 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
4100 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE_ARRAY
)
4101 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], 0);
4103 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 3);
4104 alu
.dst
.sel
= ctx
->temp_reg
;
4108 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4113 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE_ARRAY
||
4114 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE_ARRAY
) {
4115 if (ctx
->bc
->chip_class
>= EVERGREEN
) {
4116 int mytmp
= r600_get_temp(ctx
);
4117 static const float eight
= 8.0f
;
4118 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4119 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
4120 alu
.src
[0].sel
= ctx
->temp_reg
;
4121 alu
.src
[0].chan
= 3;
4122 alu
.dst
.sel
= mytmp
;
4126 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4130 /* have to multiply original layer by 8 and add to face id (temp.w) in Z */
4131 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4132 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
4134 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 3);
4135 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
4136 alu
.src
[1].chan
= 0;
4137 alu
.src
[1].value
= *(uint32_t *)&eight
;
4138 alu
.src
[2].sel
= mytmp
;
4139 alu
.src
[2].chan
= 0;
4140 alu
.dst
.sel
= ctx
->temp_reg
;
4144 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4147 } else if (ctx
->bc
->chip_class
< EVERGREEN
) {
4148 memset(&tex
, 0, sizeof(struct r600_bytecode_tex
));
4149 tex
.inst
= SQ_TEX_INST_SET_CUBEMAP_INDEX
;
4150 tex
.sampler_id
= tgsi_tex_get_src_gpr(ctx
, sampler_src_reg
);
4151 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
4152 tex
.src_gpr
= r600_get_temp(ctx
);
4157 tex
.dst_sel_x
= tex
.dst_sel_y
= tex
.dst_sel_z
= tex
.dst_sel_w
= 7;
4158 tex
.coord_type_x
= 1;
4159 tex
.coord_type_y
= 1;
4160 tex
.coord_type_z
= 1;
4161 tex
.coord_type_w
= 1;
4162 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4163 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
4164 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 3);
4165 alu
.dst
.sel
= tex
.src_gpr
;
4169 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4173 r
= r600_bytecode_add_tex(ctx
->bc
, &tex
);
4180 /* for cube forms of lod and bias we need to route things */
4181 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXB
||
4182 inst
->Instruction
.Opcode
== TGSI_OPCODE_TXL
||
4183 inst
->Instruction
.Opcode
== TGSI_OPCODE_TXB2
||
4184 inst
->Instruction
.Opcode
== TGSI_OPCODE_TXL2
) {
4185 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4186 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
4187 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXB2
||
4188 inst
->Instruction
.Opcode
== TGSI_OPCODE_TXL2
)
4189 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], 0);
4191 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 3);
4192 alu
.dst
.sel
= ctx
->temp_reg
;
4196 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4202 src_gpr
= ctx
->temp_reg
;
4205 if (src_requires_loading
&& !src_loaded
) {
4206 for (i
= 0; i
< 4; i
++) {
4207 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4208 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
4209 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
4210 alu
.dst
.sel
= ctx
->temp_reg
;
4215 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4220 src_gpr
= ctx
->temp_reg
;
4223 /* Obtain the sample index for reading a compressed MSAA color texture.
4224 * To read the FMASK, we use the ldfptr instruction, which tells us
4225 * where the samples are stored.
4226 * For uncompressed 8x MSAA surfaces, ldfptr should return 0x76543210,
4227 * which is the identity mapping. Each nibble says which physical sample
4228 * should be fetched to get that sample.
4230 * Assume src.z contains the sample index. It should be modified like this:
4231 * src.z = (ldfptr() >> (src.z * 4)) & 0xF;
4232 * Then fetch the texel with src.
4234 if (read_compressed_msaa
) {
4235 unsigned sample_chan
= inst
->Texture
.Texture
== TGSI_TEXTURE_2D_MSAA
? 3 : 4;
4236 unsigned temp
= r600_get_temp(ctx
);
4239 /* temp.w = ldfptr() */
4240 memset(&tex
, 0, sizeof(struct r600_bytecode_tex
));
4241 tex
.inst
= SQ_TEX_INST_LD
;
4242 tex
.inst_mod
= 1; /* to indicate this is ldfptr */
4243 tex
.sampler_id
= tgsi_tex_get_src_gpr(ctx
, sampler_src_reg
);
4244 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
4245 tex
.src_gpr
= src_gpr
;
4247 tex
.dst_sel_x
= 7; /* mask out these components */
4250 tex
.dst_sel_w
= 0; /* store X */
4255 tex
.offset_x
= offset_x
;
4256 tex
.offset_y
= offset_y
;
4257 tex
.offset_z
= offset_z
;
4258 r
= r600_bytecode_add_tex(ctx
->bc
, &tex
);
4262 /* temp.x = sample_index*4 */
4263 if (ctx
->bc
->chip_class
== CAYMAN
) {
4264 for (i
= 0 ; i
< 4; i
++) {
4265 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4266 alu
.inst
= ctx
->inst_info
->r600_opcode
;
4267 alu
.src
[0].sel
= src_gpr
;
4268 alu
.src
[0].chan
= sample_chan
;
4269 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
4270 alu
.src
[1].value
= 4;
4273 alu
.dst
.write
= i
== 0;
4276 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4281 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4282 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_INT
);
4283 alu
.src
[0].sel
= src_gpr
;
4284 alu
.src
[0].chan
= sample_chan
;
4285 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
4286 alu
.src
[1].value
= 4;
4291 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4296 /* sample_index = temp.w >> temp.x */
4297 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4298 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
);
4299 alu
.src
[0].sel
= temp
;
4300 alu
.src
[0].chan
= 3;
4301 alu
.src
[1].sel
= temp
;
4302 alu
.src
[1].chan
= 0;
4303 alu
.dst
.sel
= src_gpr
;
4304 alu
.dst
.chan
= sample_chan
;
4307 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4311 /* sample_index & 0xF */
4312 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4313 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
);
4314 alu
.src
[0].sel
= src_gpr
;
4315 alu
.src
[0].chan
= sample_chan
;
4316 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
4317 alu
.src
[1].value
= 0xF;
4318 alu
.dst
.sel
= src_gpr
;
4319 alu
.dst
.chan
= sample_chan
;
4322 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4326 /* visualize the FMASK */
4327 for (i
= 0; i
< 4; i
++) {
4328 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4329 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
);
4330 alu
.src
[0].sel
= src_gpr
;
4331 alu
.src
[0].chan
= sample_chan
;
4332 alu
.dst
.sel
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
4336 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4344 /* does this shader want a num layers from TXQ for a cube array? */
4345 if (has_txq_cube_array_z
) {
4346 int id
= tgsi_tex_get_src_gpr(ctx
, sampler_src_reg
);
4348 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4349 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
4351 alu
.src
[0].sel
= 512 + (id
/ 4);
4352 alu
.src
[0].kc_bank
= R600_TXQ_CONST_BUFFER
;
4353 alu
.src
[0].chan
= id
% 4;
4354 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
4356 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4359 /* disable writemask from texture instruction */
4360 inst
->Dst
[0].Register
.WriteMask
&= ~4;
4363 opcode
= ctx
->inst_info
->r600_opcode
;
4364 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
||
4365 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
||
4366 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWRECT
||
4367 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE
||
4368 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D_ARRAY
||
4369 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D_ARRAY
||
4370 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE_ARRAY
) {
4372 case SQ_TEX_INST_SAMPLE
:
4373 opcode
= SQ_TEX_INST_SAMPLE_C
;
4375 case SQ_TEX_INST_SAMPLE_L
:
4376 opcode
= SQ_TEX_INST_SAMPLE_C_L
;
4378 case SQ_TEX_INST_SAMPLE_LB
:
4379 opcode
= SQ_TEX_INST_SAMPLE_C_LB
;
4381 case SQ_TEX_INST_SAMPLE_G
:
4382 opcode
= SQ_TEX_INST_SAMPLE_C_G
;
4387 memset(&tex
, 0, sizeof(struct r600_bytecode_tex
));
4390 tex
.sampler_id
= tgsi_tex_get_src_gpr(ctx
, sampler_src_reg
);
4391 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
4392 tex
.src_gpr
= src_gpr
;
4393 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
4394 tex
.dst_sel_x
= (inst
->Dst
[0].Register
.WriteMask
& 1) ? 0 : 7;
4395 tex
.dst_sel_y
= (inst
->Dst
[0].Register
.WriteMask
& 2) ? 1 : 7;
4396 tex
.dst_sel_z
= (inst
->Dst
[0].Register
.WriteMask
& 4) ? 2 : 7;
4397 tex
.dst_sel_w
= (inst
->Dst
[0].Register
.WriteMask
& 8) ? 3 : 7;
4399 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXQ_LZ
) {
4404 } else if (src_loaded
) {
4410 tex
.src_sel_x
= ctx
->src
[0].swizzle
[0];
4411 tex
.src_sel_y
= ctx
->src
[0].swizzle
[1];
4412 tex
.src_sel_z
= ctx
->src
[0].swizzle
[2];
4413 tex
.src_sel_w
= ctx
->src
[0].swizzle
[3];
4414 tex
.src_rel
= ctx
->src
[0].rel
;
4417 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
||
4418 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE
||
4419 inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE_ARRAY
||
4420 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE_ARRAY
) {
4424 tex
.src_sel_w
= 2; /* route Z compare or Lod value into W */
4427 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
&&
4428 inst
->Texture
.Texture
!= TGSI_TEXTURE_SHADOWRECT
) {
4429 tex
.coord_type_x
= 1;
4430 tex
.coord_type_y
= 1;
4432 tex
.coord_type_z
= 1;
4433 tex
.coord_type_w
= 1;
4435 tex
.offset_x
= offset_x
;
4436 tex
.offset_y
= offset_y
;
4437 tex
.offset_z
= offset_z
;
4439 /* Put the depth for comparison in W.
4440 * TGSI_TEXTURE_SHADOW2D_ARRAY already has the depth in W.
4441 * Some instructions expect the depth in Z. */
4442 if ((inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
||
4443 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
||
4444 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWRECT
||
4445 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D_ARRAY
) &&
4446 opcode
!= SQ_TEX_INST_SAMPLE_C_L
&&
4447 opcode
!= SQ_TEX_INST_SAMPLE_C_LB
) {
4448 tex
.src_sel_w
= tex
.src_sel_z
;
4451 if (inst
->Texture
.Texture
== TGSI_TEXTURE_1D_ARRAY
||
4452 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D_ARRAY
) {
4453 if (opcode
== SQ_TEX_INST_SAMPLE_C_L
||
4454 opcode
== SQ_TEX_INST_SAMPLE_C_LB
) {
4455 /* the array index is read from Y */
4456 tex
.coord_type_y
= 0;
4458 /* the array index is read from Z */
4459 tex
.coord_type_z
= 0;
4460 tex
.src_sel_z
= tex
.src_sel_y
;
4462 } else if (inst
->Texture
.Texture
== TGSI_TEXTURE_2D_ARRAY
||
4463 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D_ARRAY
||
4464 ((inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE_ARRAY
||
4465 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWCUBE_ARRAY
) &&
4466 (ctx
->bc
->chip_class
>= EVERGREEN
)))
4467 /* the array index is read from Z */
4468 tex
.coord_type_z
= 0;
4470 r
= r600_bytecode_add_tex(ctx
->bc
, &tex
);
4474 /* add shadow ambient support - gallium doesn't do it yet */
4478 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
4480 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4481 struct r600_bytecode_alu alu
;
4482 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
4486 /* optimize if it's just an equal balance */
4487 if (ctx
->src
[0].sel
== V_SQ_ALU_SRC_0_5
) {
4488 for (i
= 0; i
< lasti
+ 1; i
++) {
4489 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
4492 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4493 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
4494 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
4495 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
4497 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4502 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4510 for (i
= 0; i
< lasti
+ 1; i
++) {
4511 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
4514 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4515 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
4516 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
4517 alu
.src
[0].chan
= 0;
4518 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
4519 r600_bytecode_src_toggle_neg(&alu
.src
[1]);
4520 alu
.dst
.sel
= ctx
->temp_reg
;
4526 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4531 /* (1 - src0) * src2 */
4532 for (i
= 0; i
< lasti
+ 1; i
++) {
4533 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
4536 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4537 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
4538 alu
.src
[0].sel
= ctx
->temp_reg
;
4539 alu
.src
[0].chan
= i
;
4540 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
4541 alu
.dst
.sel
= ctx
->temp_reg
;
4547 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4552 /* src0 * src1 + (1 - src0) * src2 */
4553 for (i
= 0; i
< lasti
+ 1; i
++) {
4554 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
4557 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4558 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
4560 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
4561 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
4562 alu
.src
[2].sel
= ctx
->temp_reg
;
4563 alu
.src
[2].chan
= i
;
4565 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4570 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4577 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
4579 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4580 struct r600_bytecode_alu alu
;
4582 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
4584 for (i
= 0; i
< lasti
+ 1; i
++) {
4585 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
4588 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4589 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
4590 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
4591 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
4592 r600_bytecode_src(&alu
.src
[2], &ctx
->src
[1], i
);
4593 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4599 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4606 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
4608 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4609 static const unsigned int src0_swizzle
[] = {2, 0, 1};
4610 static const unsigned int src1_swizzle
[] = {1, 2, 0};
4611 struct r600_bytecode_alu alu
;
4612 uint32_t use_temp
= 0;
4615 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
4618 for (i
= 0; i
< 4; i
++) {
4619 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4620 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
4622 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], src0_swizzle
[i
]);
4623 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], src1_swizzle
[i
]);
4625 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
4626 alu
.src
[0].chan
= i
;
4627 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
4628 alu
.src
[1].chan
= i
;
4631 alu
.dst
.sel
= ctx
->temp_reg
;
4637 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4642 for (i
= 0; i
< 4; i
++) {
4643 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4644 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
4647 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], src1_swizzle
[i
]);
4648 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], src0_swizzle
[i
]);
4650 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
4651 alu
.src
[0].chan
= i
;
4652 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
4653 alu
.src
[1].chan
= i
;
4656 alu
.src
[2].sel
= ctx
->temp_reg
;
4658 alu
.src
[2].chan
= i
;
4661 alu
.dst
.sel
= ctx
->temp_reg
;
4663 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4669 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4674 return tgsi_helper_copy(ctx
, inst
);
4678 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
4680 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4681 struct r600_bytecode_alu alu
;
4685 /* result.x = 2^floor(src); */
4686 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
4687 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4689 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
4690 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4692 alu
.dst
.sel
= ctx
->temp_reg
;
4696 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4700 if (ctx
->bc
->chip_class
== CAYMAN
) {
4701 for (i
= 0; i
< 3; i
++) {
4702 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4703 alu
.src
[0].sel
= ctx
->temp_reg
;
4704 alu
.src
[0].chan
= 0;
4706 alu
.dst
.sel
= ctx
->temp_reg
;
4708 alu
.dst
.write
= i
== 0;
4710 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4715 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4716 alu
.src
[0].sel
= ctx
->temp_reg
;
4717 alu
.src
[0].chan
= 0;
4719 alu
.dst
.sel
= ctx
->temp_reg
;
4723 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4729 /* result.y = tmp - floor(tmp); */
4730 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
4731 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4733 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
4734 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4736 alu
.dst
.sel
= ctx
->temp_reg
;
4738 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4747 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4752 /* result.z = RoughApprox2ToX(tmp);*/
4753 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
4754 if (ctx
->bc
->chip_class
== CAYMAN
) {
4755 for (i
= 0; i
< 3; i
++) {
4756 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4757 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4758 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4760 alu
.dst
.sel
= ctx
->temp_reg
;
4767 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4772 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4773 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4774 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4776 alu
.dst
.sel
= ctx
->temp_reg
;
4782 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4788 /* result.w = 1.0;*/
4789 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
4790 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4792 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
4793 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
4794 alu
.src
[0].chan
= 0;
4796 alu
.dst
.sel
= ctx
->temp_reg
;
4800 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4804 return tgsi_helper_copy(ctx
, inst
);
4807 static int tgsi_log(struct r600_shader_ctx
*ctx
)
4809 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
4810 struct r600_bytecode_alu alu
;
4814 /* result.x = floor(log2(|src|)); */
4815 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
4816 if (ctx
->bc
->chip_class
== CAYMAN
) {
4817 for (i
= 0; i
< 3; i
++) {
4818 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4820 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
4821 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4822 r600_bytecode_src_set_abs(&alu
.src
[0]);
4824 alu
.dst
.sel
= ctx
->temp_reg
;
4830 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4836 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4838 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
4839 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4840 r600_bytecode_src_set_abs(&alu
.src
[0]);
4842 alu
.dst
.sel
= ctx
->temp_reg
;
4846 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4851 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
4852 alu
.src
[0].sel
= ctx
->temp_reg
;
4853 alu
.src
[0].chan
= 0;
4855 alu
.dst
.sel
= ctx
->temp_reg
;
4860 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4865 /* result.y = |src.x| / (2 ^ floor(log2(|src.x|))); */
4866 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
4868 if (ctx
->bc
->chip_class
== CAYMAN
) {
4869 for (i
= 0; i
< 3; i
++) {
4870 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4872 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
4873 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4874 r600_bytecode_src_set_abs(&alu
.src
[0]);
4876 alu
.dst
.sel
= ctx
->temp_reg
;
4883 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4888 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4890 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
4891 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4892 r600_bytecode_src_set_abs(&alu
.src
[0]);
4894 alu
.dst
.sel
= ctx
->temp_reg
;
4899 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4904 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4906 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
4907 alu
.src
[0].sel
= ctx
->temp_reg
;
4908 alu
.src
[0].chan
= 1;
4910 alu
.dst
.sel
= ctx
->temp_reg
;
4915 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4919 if (ctx
->bc
->chip_class
== CAYMAN
) {
4920 for (i
= 0; i
< 3; i
++) {
4921 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4922 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4923 alu
.src
[0].sel
= ctx
->temp_reg
;
4924 alu
.src
[0].chan
= 1;
4926 alu
.dst
.sel
= ctx
->temp_reg
;
4933 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4938 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4939 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
4940 alu
.src
[0].sel
= ctx
->temp_reg
;
4941 alu
.src
[0].chan
= 1;
4943 alu
.dst
.sel
= ctx
->temp_reg
;
4948 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4953 if (ctx
->bc
->chip_class
== CAYMAN
) {
4954 for (i
= 0; i
< 3; i
++) {
4955 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4956 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
4957 alu
.src
[0].sel
= ctx
->temp_reg
;
4958 alu
.src
[0].chan
= 1;
4960 alu
.dst
.sel
= ctx
->temp_reg
;
4967 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4972 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4973 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
4974 alu
.src
[0].sel
= ctx
->temp_reg
;
4975 alu
.src
[0].chan
= 1;
4977 alu
.dst
.sel
= ctx
->temp_reg
;
4982 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4987 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4989 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
4991 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
4992 r600_bytecode_src_set_abs(&alu
.src
[0]);
4994 alu
.src
[1].sel
= ctx
->temp_reg
;
4995 alu
.src
[1].chan
= 1;
4997 alu
.dst
.sel
= ctx
->temp_reg
;
5002 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
5007 /* result.z = log2(|src|);*/
5008 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
5009 if (ctx
->bc
->chip_class
== CAYMAN
) {
5010 for (i
= 0; i
< 3; i
++) {
5011 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
5013 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
5014 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
5015 r600_bytecode_src_set_abs(&alu
.src
[0]);
5017 alu
.dst
.sel
= ctx
->temp_reg
;
5024 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
5029 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
5031 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
5032 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
5033 r600_bytecode_src_set_abs(&alu
.src
[0]);
5035 alu
.dst
.sel
= ctx
->temp_reg
;
5040 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
5046 /* result.w = 1.0; */
5047 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
5048 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
5050 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
5051 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
5052 alu
.src
[0].chan
= 0;
5054 alu
.dst
.sel
= ctx
->temp_reg
;
5059 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
5064 return tgsi_helper_copy(ctx
, inst
);
5067 static int tgsi_eg_arl(struct r600_shader_ctx
*ctx
)
5069 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
5070 struct r600_bytecode_alu alu
;
5073 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
5075 switch (inst
->Instruction
.Opcode
) {
5076 case TGSI_OPCODE_ARL
:
5077 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR
;
5079 case TGSI_OPCODE_ARR
:
5080 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
5082 case TGSI_OPCODE_UARL
:
5083 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
5090 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
5092 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
5094 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
5098 ctx
->bc
->ar_loaded
= 0;
5101 static int tgsi_r600_arl(struct r600_shader_ctx
*ctx
)
5103 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
5104 struct r600_bytecode_alu alu
;
5107 switch (inst
->Instruction
.Opcode
) {
5108 case TGSI_OPCODE_ARL
:
5109 memset(&alu
, 0, sizeof(alu
));
5110 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
;
5111 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
5112 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
5116 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
5119 memset(&alu
, 0, sizeof(alu
));
5120 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
5121 alu
.src
[0].sel
= ctx
->bc
->ar_reg
;
5122 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
5126 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
5129 case TGSI_OPCODE_ARR
:
5130 memset(&alu
, 0, sizeof(alu
));
5131 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
5132 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
5133 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
5137 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
5140 case TGSI_OPCODE_UARL
:
5141 memset(&alu
, 0, sizeof(alu
));
5142 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
5143 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
5144 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
5148 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
5156 ctx
->bc
->ar_loaded
= 0;
5160 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
5162 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
5163 struct r600_bytecode_alu alu
;
5166 for (i
= 0; i
< 4; i
++) {
5167 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
5169 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
5170 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
5172 if (i
== 0 || i
== 3) {
5173 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
5175 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
5178 if (i
== 0 || i
== 2) {
5179 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
5181 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
5185 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
5192 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
5194 struct r600_bytecode_alu alu
;
5197 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
5199 alu
.execute_mask
= 1;
5200 alu
.update_pred
= 1;
5202 alu
.dst
.sel
= ctx
->temp_reg
;
5206 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
5207 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
5208 alu
.src
[1].chan
= 0;
5212 r
= r600_bytecode_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
5218 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
5220 unsigned force_pop
= ctx
->bc
->force_add_cf
;
5224 if (ctx
->bc
->cf_last
) {
5225 if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
))
5227 else if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
))
5232 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
);
5233 ctx
->bc
->force_add_cf
= 1;
5234 } else if (alu_pop
== 2) {
5235 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
);
5236 ctx
->bc
->force_add_cf
= 1;
5243 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
5244 ctx
->bc
->cf_last
->pop_count
= pops
;
5245 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
5251 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
5255 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
5259 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
5262 /* TOODO : for 16 vp asic should -= 2; */
5263 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
5268 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
5270 if (check_max_only
) {
5283 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
5284 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
5285 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
5286 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
5292 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
5296 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
5299 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
5303 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
5304 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
5305 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
5306 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
5310 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
5312 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
5314 sp
->mid
= realloc((void *)sp
->mid
,
5315 sizeof(struct r600_bytecode_cf
*) * (sp
->num_mid
+ 1));
5316 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
5320 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
5323 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
5324 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
5327 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
5329 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
5339 static int emit_return(struct r600_shader_ctx
*ctx
)
5341 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_RETURN
));
5345 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
5348 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
5349 ctx
->bc
->cf_last
->pop_count
= pops
;
5350 /* XXX work out offset */
5354 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
5359 static void emit_testflag(struct r600_shader_ctx
*ctx
)
5364 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
5367 emit_jump_to_offset(ctx
, 1, 4);
5368 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
5369 pops(ctx
, ifidx
+ 1);
5373 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
5377 r600_bytecode_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
5378 ctx
->bc
->cf_last
->pop_count
= 1;
5380 fc_set_mid(ctx
, fc_sp
);
5386 static int tgsi_if(struct r600_shader_ctx
*ctx
)
5388 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
));
5390 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
5392 fc_pushlevel(ctx
, FC_IF
);
5394 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
5398 static int tgsi_else(struct r600_shader_ctx
*ctx
)
5400 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
5401 ctx
->bc
->cf_last
->pop_count
= 1;
5403 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
5404 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
5408 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
5411 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
5412 R600_ERR("if/endif unbalanced in shader\n");
5416 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
5417 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
5418 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
5420 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
5424 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
5428 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
5430 /* LOOP_START_DX10 ignores the LOOP_CONFIG* registers, so it is not
5431 * limited to 4096 iterations, like the other LOOP_* instructions. */
5432 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_DX10
));
5434 fc_pushlevel(ctx
, FC_LOOP
);
5436 /* check stack depth */
5437 callstack_check_depth(ctx
, FC_LOOP
, 0);
5441 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
5445 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
5447 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
5448 R600_ERR("loop/endloop in shader code are not paired.\n");
5452 /* fixup loop pointers - from r600isa
5453 LOOP END points to CF after LOOP START,
5454 LOOP START point to CF after LOOP END
5455 BRK/CONT point to LOOP END CF
5457 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
5459 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
5461 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
5462 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
5464 /* XXX add LOOPRET support */
5466 callstack_decrease_current(ctx
, FC_LOOP
);
5470 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
5474 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
5476 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
5481 R600_ERR("Break not inside loop/endloop pair\n");
5485 r600_bytecode_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
5487 fc_set_mid(ctx
, fscp
);
5489 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
5493 static int tgsi_umad(struct r600_shader_ctx
*ctx
)
5495 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
5496 struct r600_bytecode_alu alu
;
5498 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
5501 for (i
= 0; i
< lasti
+ 1; i
++) {
5502 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
5505 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
5508 alu
.dst
.sel
= ctx
->temp_reg
;
5511 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
);
5512 for (j
= 0; j
< 2; j
++) {
5513 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
5517 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
5523 for (i
= 0; i
< lasti
+ 1; i
++) {
5524 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
5527 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
5528 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
5530 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
5532 alu
.src
[0].sel
= ctx
->temp_reg
;
5533 alu
.src
[0].chan
= i
;
5535 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
5539 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
5546 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
5547 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
5548 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5549 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
5552 * For state trackers other than OpenGL, we'll want to use
5553 * _RECIP_IEEE instead.
5555 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
5557 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
5558 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
5559 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
5560 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
5561 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5562 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5563 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5564 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
5565 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
5566 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
5567 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
5568 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
5569 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
5570 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5571 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
5572 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5574 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5575 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5577 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5578 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5579 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
5580 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5581 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
5582 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE
, tgsi_op2
},
5583 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
5584 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
5585 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
5586 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
5588 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5589 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5590 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5591 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5592 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
5593 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
5594 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
5595 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
5596 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5597 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5598 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5599 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5600 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5601 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
5602 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5603 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
5604 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
5605 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
5606 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
5607 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5608 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5609 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
5610 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5611 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5612 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5613 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5614 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5615 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5616 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5617 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
5618 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5619 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5620 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5621 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
5622 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
5623 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
5624 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
5625 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5626 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5627 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5628 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
5629 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
5630 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
5632 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5633 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5634 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
5635 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
5637 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5638 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5639 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5640 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5641 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CEIL
, tgsi_op2
},
5642 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
, tgsi_op2_trans
},
5643 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT
, tgsi_op2
},
5644 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
5645 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT
, tgsi_op2_trans
},
5647 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5648 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
, tgsi_op2
},
5649 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT
, tgsi_op2
},
5650 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_imod
},
5651 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
, tgsi_op2
},
5652 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5653 {TGSI_OPCODE_TXF
, 0, SQ_TEX_INST_LD
, tgsi_tex
},
5654 {TGSI_OPCODE_TXQ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
5655 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
5656 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5657 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5658 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
5659 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5660 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
5661 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5662 {TGSI_OPCODE_TXQ_LZ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
5664 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5665 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5666 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5667 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5669 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5670 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5671 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5672 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5673 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5674 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5675 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5676 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5677 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
5678 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
5680 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5681 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
, tgsi_op2_trans
},
5682 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_idiv
},
5683 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT
, tgsi_op2
},
5684 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT
, tgsi_op2
},
5685 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
, tgsi_ineg
},
5686 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT
, tgsi_op2
},
5687 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT
, tgsi_op2_trans
},
5688 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
, tgsi_op2_swap
},
5689 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
, tgsi_op2_trans
},
5690 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
, tgsi_op2_trans
},
5691 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
, tgsi_op2
},
5692 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_udiv
},
5693 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umad
},
5694 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT
, tgsi_op2
},
5695 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT
, tgsi_op2
},
5696 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umod
},
5697 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
, tgsi_op2_trans
},
5698 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT
, tgsi_op2
},
5699 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
, tgsi_op2
},
5700 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
, tgsi_op2_trans
},
5701 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_UINT
, tgsi_op2_swap
},
5702 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT
, tgsi_op2_swap
},
5703 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5704 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5705 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5706 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5707 {TGSI_OPCODE_SAMPLE
, 0, 0, tgsi_unsupported
},
5708 {TGSI_OPCODE_SAMPLE_I
, 0, 0, tgsi_unsupported
},
5709 {TGSI_OPCODE_SAMPLE_I_MS
, 0, 0, tgsi_unsupported
},
5710 {TGSI_OPCODE_SAMPLE_B
, 0, 0, tgsi_unsupported
},
5711 {TGSI_OPCODE_SAMPLE_C
, 0, 0, tgsi_unsupported
},
5712 {TGSI_OPCODE_SAMPLE_C_LZ
, 0, 0, tgsi_unsupported
},
5713 {TGSI_OPCODE_SAMPLE_D
, 0, 0, tgsi_unsupported
},
5714 {TGSI_OPCODE_SAMPLE_L
, 0, 0, tgsi_unsupported
},
5715 {TGSI_OPCODE_GATHER4
, 0, 0, tgsi_unsupported
},
5716 {TGSI_OPCODE_SVIEWINFO
, 0, 0, tgsi_unsupported
},
5717 {TGSI_OPCODE_SAMPLE_POS
, 0, 0, tgsi_unsupported
},
5718 {TGSI_OPCODE_SAMPLE_INFO
, 0, 0, tgsi_unsupported
},
5719 {TGSI_OPCODE_UARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
, tgsi_r600_arl
},
5720 {TGSI_OPCODE_UCMP
, 0, 0, tgsi_unsupported
},
5721 {TGSI_OPCODE_IABS
, 0, 0, tgsi_iabs
},
5722 {TGSI_OPCODE_ISSG
, 0, 0, tgsi_issg
},
5723 {TGSI_OPCODE_LOAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5724 {TGSI_OPCODE_STORE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5725 {TGSI_OPCODE_MFENCE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5726 {TGSI_OPCODE_LFENCE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5727 {TGSI_OPCODE_SFENCE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5728 {TGSI_OPCODE_BARRIER
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5729 {TGSI_OPCODE_ATOMUADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5730 {TGSI_OPCODE_ATOMXCHG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5731 {TGSI_OPCODE_ATOMCAS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5732 {TGSI_OPCODE_ATOMAND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5733 {TGSI_OPCODE_ATOMOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5734 {TGSI_OPCODE_ATOMXOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5735 {TGSI_OPCODE_ATOMUMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5736 {TGSI_OPCODE_ATOMUMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5737 {TGSI_OPCODE_ATOMIMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5738 {TGSI_OPCODE_ATOMIMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5739 {TGSI_OPCODE_TEX2
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5740 {TGSI_OPCODE_TXB2
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
5741 {TGSI_OPCODE_TXL2
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
5742 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5745 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
5746 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
5747 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5748 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
5749 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
5750 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_rsq
},
5751 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
5752 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
5753 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
5754 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5755 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5756 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5757 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
5758 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
5759 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
5760 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
5761 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
5762 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
5763 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5764 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
5765 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5767 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5768 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5770 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5771 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5772 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
5773 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5774 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
5775 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE
, tgsi_op2
},
5776 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
5777 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
5778 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
5779 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
5781 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5782 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5783 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5784 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5785 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
5786 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
5787 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
5788 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
5789 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5790 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5791 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5792 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5793 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5794 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
5795 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5796 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
5797 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
5798 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
5799 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
5800 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5801 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5802 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
5803 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5804 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5805 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5806 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5807 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5808 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5809 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5810 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
5811 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5812 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5813 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5814 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
5815 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
5816 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
5817 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
5818 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5819 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5820 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5821 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
5822 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
5823 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
5825 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5826 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5827 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
5828 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
5830 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5831 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5832 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5833 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5834 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CEIL
, tgsi_op2
},
5835 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
, tgsi_op2_trans
},
5836 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT
, tgsi_op2
},
5837 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
5838 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT
, tgsi_op2
},
5840 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5841 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
, tgsi_op2
},
5842 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT
, tgsi_op2
},
5843 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_imod
},
5844 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
, tgsi_op2
},
5845 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5846 {TGSI_OPCODE_TXF
, 0, SQ_TEX_INST_LD
, tgsi_tex
},
5847 {TGSI_OPCODE_TXQ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
5848 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
5849 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5850 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5851 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
5852 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5853 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
5854 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5855 {TGSI_OPCODE_TXQ_LZ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
5857 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5858 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5859 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5860 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5862 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5863 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5864 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5865 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5866 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5867 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5868 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5869 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5870 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
5871 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
5873 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5874 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
, tgsi_f2i
},
5875 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_idiv
},
5876 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT
, tgsi_op2
},
5877 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT
, tgsi_op2
},
5878 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
, tgsi_ineg
},
5879 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT
, tgsi_op2
},
5880 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT
, tgsi_op2
},
5881 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
, tgsi_op2_swap
},
5882 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
, tgsi_f2i
},
5883 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
, tgsi_op2_trans
},
5884 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
, tgsi_op2
},
5885 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_udiv
},
5886 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umad
},
5887 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT
, tgsi_op2
},
5888 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT
, tgsi_op2
},
5889 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umod
},
5890 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
, tgsi_op2_trans
},
5891 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT
, tgsi_op2
},
5892 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
, tgsi_op2
},
5893 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
, tgsi_op2
},
5894 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_UINT
, tgsi_op2_swap
},
5895 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT
, tgsi_op2
},
5896 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5897 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5898 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5899 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5900 {TGSI_OPCODE_SAMPLE
, 0, 0, tgsi_unsupported
},
5901 {TGSI_OPCODE_SAMPLE_I
, 0, 0, tgsi_unsupported
},
5902 {TGSI_OPCODE_SAMPLE_I_MS
, 0, 0, tgsi_unsupported
},
5903 {TGSI_OPCODE_SAMPLE_B
, 0, 0, tgsi_unsupported
},
5904 {TGSI_OPCODE_SAMPLE_C
, 0, 0, tgsi_unsupported
},
5905 {TGSI_OPCODE_SAMPLE_C_LZ
, 0, 0, tgsi_unsupported
},
5906 {TGSI_OPCODE_SAMPLE_D
, 0, 0, tgsi_unsupported
},
5907 {TGSI_OPCODE_SAMPLE_L
, 0, 0, tgsi_unsupported
},
5908 {TGSI_OPCODE_GATHER4
, 0, 0, tgsi_unsupported
},
5909 {TGSI_OPCODE_SVIEWINFO
, 0, 0, tgsi_unsupported
},
5910 {TGSI_OPCODE_SAMPLE_POS
, 0, 0, tgsi_unsupported
},
5911 {TGSI_OPCODE_SAMPLE_INFO
, 0, 0, tgsi_unsupported
},
5912 {TGSI_OPCODE_UARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
, tgsi_eg_arl
},
5913 {TGSI_OPCODE_UCMP
, 0, 0, tgsi_unsupported
},
5914 {TGSI_OPCODE_IABS
, 0, 0, tgsi_iabs
},
5915 {TGSI_OPCODE_ISSG
, 0, 0, tgsi_issg
},
5916 {TGSI_OPCODE_LOAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5917 {TGSI_OPCODE_STORE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5918 {TGSI_OPCODE_MFENCE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5919 {TGSI_OPCODE_LFENCE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5920 {TGSI_OPCODE_SFENCE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5921 {TGSI_OPCODE_BARRIER
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5922 {TGSI_OPCODE_ATOMUADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5923 {TGSI_OPCODE_ATOMXCHG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5924 {TGSI_OPCODE_ATOMCAS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5925 {TGSI_OPCODE_ATOMAND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5926 {TGSI_OPCODE_ATOMOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5927 {TGSI_OPCODE_ATOMXOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5928 {TGSI_OPCODE_ATOMUMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5929 {TGSI_OPCODE_ATOMUMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5930 {TGSI_OPCODE_ATOMIMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5931 {TGSI_OPCODE_ATOMIMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5932 {TGSI_OPCODE_TEX2
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5933 {TGSI_OPCODE_TXB2
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
5934 {TGSI_OPCODE_TXL2
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
5935 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5938 static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction
[] = {
5939 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
5940 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5941 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
5942 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, cayman_emit_float_instr
},
5943 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, cayman_emit_float_instr
},
5944 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
5945 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
5946 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
5947 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5948 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5949 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5950 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
5951 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
5952 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
5953 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
5954 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
5955 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
5956 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
5957 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
5958 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5960 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5961 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5963 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5964 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5965 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
5966 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5967 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
5968 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE
, tgsi_op2
},
5969 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, cayman_emit_float_instr
},
5970 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, cayman_emit_float_instr
},
5971 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, cayman_pow
},
5972 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
5974 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5975 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
5976 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5977 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
5978 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, cayman_trig
},
5979 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
5980 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
5981 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
5982 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5983 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5984 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5985 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5986 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5987 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
5988 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5989 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
5990 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, cayman_trig
},
5991 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
5992 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
5993 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5994 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5995 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
5996 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
5997 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5998 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
5999 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6000 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6001 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6002 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6003 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
6004 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6005 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6006 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6007 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
6008 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
6009 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
6010 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
6011 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6012 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6013 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
6014 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
6015 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
6016 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
6018 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6019 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6020 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
6021 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
6023 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6024 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6025 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6026 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6027 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CEIL
, tgsi_op2
},
6028 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
, tgsi_op2
},
6029 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT
, tgsi_op2
},
6030 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
6031 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT
, tgsi_op2
},
6033 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6034 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
, tgsi_op2
},
6035 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT
, tgsi_op2
},
6036 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_imod
},
6037 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
, tgsi_op2
},
6038 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6039 {TGSI_OPCODE_TXF
, 0, SQ_TEX_INST_LD
, tgsi_tex
},
6040 {TGSI_OPCODE_TXQ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
6041 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
6042 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6043 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6044 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
6045 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6046 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
6047 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6048 {TGSI_OPCODE_TXQ_LZ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
6050 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6051 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6052 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6053 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6055 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6056 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6057 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6058 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6059 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6060 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6061 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6062 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6063 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
6064 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
6066 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6067 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
, tgsi_op2
},
6068 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_idiv
},
6069 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT
, tgsi_op2
},
6070 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT
, tgsi_op2
},
6071 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
, tgsi_ineg
},
6072 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT
, tgsi_op2
},
6073 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT
, tgsi_op2
},
6074 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
, tgsi_op2_swap
},
6075 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
, tgsi_op2
},
6076 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
, tgsi_op2
},
6077 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
, tgsi_op2
},
6078 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_udiv
},
6079 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umad
},
6080 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT
, tgsi_op2
},
6081 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT
, tgsi_op2
},
6082 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umod
},
6083 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_INT
, cayman_mul_int_instr
},
6084 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT
, tgsi_op2
},
6085 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
, tgsi_op2
},
6086 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
, tgsi_op2
},
6087 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_UINT
, tgsi_op2_swap
},
6088 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT
, tgsi_op2
},
6089 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6090 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6091 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6092 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6093 {TGSI_OPCODE_SAMPLE
, 0, 0, tgsi_unsupported
},
6094 {TGSI_OPCODE_SAMPLE_I
, 0, 0, tgsi_unsupported
},
6095 {TGSI_OPCODE_SAMPLE_I_MS
, 0, 0, tgsi_unsupported
},
6096 {TGSI_OPCODE_SAMPLE_B
, 0, 0, tgsi_unsupported
},
6097 {TGSI_OPCODE_SAMPLE_C
, 0, 0, tgsi_unsupported
},
6098 {TGSI_OPCODE_SAMPLE_C_LZ
, 0, 0, tgsi_unsupported
},
6099 {TGSI_OPCODE_SAMPLE_D
, 0, 0, tgsi_unsupported
},
6100 {TGSI_OPCODE_SAMPLE_L
, 0, 0, tgsi_unsupported
},
6101 {TGSI_OPCODE_GATHER4
, 0, 0, tgsi_unsupported
},
6102 {TGSI_OPCODE_SVIEWINFO
, 0, 0, tgsi_unsupported
},
6103 {TGSI_OPCODE_SAMPLE_POS
, 0, 0, tgsi_unsupported
},
6104 {TGSI_OPCODE_SAMPLE_INFO
, 0, 0, tgsi_unsupported
},
6105 {TGSI_OPCODE_UARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
, tgsi_eg_arl
},
6106 {TGSI_OPCODE_UCMP
, 0, 0, tgsi_unsupported
},
6107 {TGSI_OPCODE_IABS
, 0, 0, tgsi_iabs
},
6108 {TGSI_OPCODE_ISSG
, 0, 0, tgsi_issg
},
6109 {TGSI_OPCODE_LOAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6110 {TGSI_OPCODE_STORE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6111 {TGSI_OPCODE_MFENCE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6112 {TGSI_OPCODE_LFENCE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6113 {TGSI_OPCODE_SFENCE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6114 {TGSI_OPCODE_BARRIER
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6115 {TGSI_OPCODE_ATOMUADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6116 {TGSI_OPCODE_ATOMXCHG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6117 {TGSI_OPCODE_ATOMCAS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6118 {TGSI_OPCODE_ATOMAND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6119 {TGSI_OPCODE_ATOMOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6120 {TGSI_OPCODE_ATOMXOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6121 {TGSI_OPCODE_ATOMUMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6122 {TGSI_OPCODE_ATOMUMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6123 {TGSI_OPCODE_ATOMIMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6124 {TGSI_OPCODE_ATOMIMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
6125 {TGSI_OPCODE_TEX2
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
6126 {TGSI_OPCODE_TXB2
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
6127 {TGSI_OPCODE_TXL2
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
6128 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},