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.
23 #include "pipe/p_shader_tokens.h"
24 #include "tgsi/tgsi_parse.h"
25 #include "tgsi/tgsi_scan.h"
26 #include "tgsi/tgsi_dump.h"
27 #include "util/u_format.h"
28 #include "r600_screen.h"
29 #include "r600_context.h"
30 #include "r600_shader.h"
33 #include "r600_opcodes.h"
39 struct r600_shader_tgsi_instruction
;
41 struct r600_shader_ctx
{
42 struct tgsi_shader_info info
;
43 struct tgsi_parse_context parse
;
44 const struct tgsi_token
*tokens
;
46 unsigned file_offset
[TGSI_FILE_COUNT
];
48 struct r600_shader_tgsi_instruction
*inst_info
;
50 struct r600_shader
*shader
;
54 u32 max_driver_temp_used
;
57 struct r600_shader_tgsi_instruction
{
61 int (*process
)(struct r600_shader_ctx
*ctx
);
64 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[], eg_shader_tgsi_instruction
[];
65 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
67 static int r600_shader_update(struct pipe_context
*ctx
, struct r600_shader
*shader
)
69 struct r600_context
*rctx
= r600_context(ctx
);
70 const struct util_format_description
*desc
;
71 enum pipe_format resource_format
[160];
72 unsigned i
, nresources
= 0;
73 struct r600_bc
*bc
= &shader
->bc
;
74 struct r600_bc_cf
*cf
;
75 struct r600_bc_vtx
*vtx
;
77 if (shader
->processor_type
!= TGSI_PROCESSOR_VERTEX
)
79 for (i
= 0; i
< rctx
->vertex_elements
->count
; i
++) {
80 resource_format
[nresources
++] = rctx
->vertex_elements
->elements
[i
].src_format
;
82 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
84 case V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
85 case V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC
:
86 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
87 desc
= util_format_description(resource_format
[vtx
->buffer_id
]);
89 R600_ERR("unknown format %d\n", resource_format
[vtx
->buffer_id
]);
92 vtx
->dst_sel_x
= desc
->swizzle
[0];
93 vtx
->dst_sel_y
= desc
->swizzle
[1];
94 vtx
->dst_sel_z
= desc
->swizzle
[2];
95 vtx
->dst_sel_w
= desc
->swizzle
[3];
102 return r600_bc_build(&shader
->bc
);
105 int r600_pipe_shader_create(struct pipe_context
*ctx
,
106 struct r600_context_state
*rpshader
,
107 const struct tgsi_token
*tokens
)
109 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
112 //fprintf(stderr, "--------------------------------------------------------------\n");
113 //tgsi_dump(tokens, 0);
114 if (rpshader
== NULL
)
116 rpshader
->shader
.family
= radeon_get_family(rscreen
->rw
);
117 rpshader
->shader
.use_mem_constant
= rscreen
->use_mem_constant
;
118 r
= r600_shader_from_tgsi(tokens
, &rpshader
->shader
);
120 R600_ERR("translation from TGSI failed !\n");
123 r
= r600_bc_build(&rpshader
->shader
.bc
);
125 R600_ERR("building bytecode failed !\n");
128 //fprintf(stderr, "______________________________________________________________\n");
132 static int r600_pipe_shader_vs(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
134 struct r600_context
*rctx
= r600_context(ctx
);
135 struct radeon_state
*state
;
137 state
= &rpshader
->rstate
[0];
138 radeon_state_fini(&rpshader
->rstate
[0]);
140 return rctx
->vtbl
->vs_shader(rctx
, rpshader
, state
);
143 static int r600_pipe_shader_ps(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
145 struct r600_context
*rctx
= r600_context(ctx
);
146 struct radeon_state
*state
;
148 state
= &rpshader
->rstate
[0];
149 radeon_state_fini(state
);
151 return rctx
->vtbl
->ps_shader(rctx
, rpshader
, state
);
154 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
156 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
157 struct r600_context
*rctx
= r600_context(ctx
);
158 struct r600_shader
*rshader
= &rpshader
->shader
;
162 /* copy new shader */
163 radeon_ws_bo_reference(rscreen
->rw
, &rpshader
->bo
, NULL
);
165 rpshader
->bo
= radeon_ws_bo(rscreen
->rw
, rshader
->bc
.ndw
* 4,
167 if (rpshader
->bo
== NULL
) {
170 data
= radeon_ws_bo_map(rscreen
->rw
, rpshader
->bo
, 0, ctx
);
171 memcpy(data
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* 4);
172 radeon_ws_bo_unmap(rscreen
->rw
, rpshader
->bo
);
174 rshader
->flat_shade
= rctx
->flat_shade
;
175 switch (rshader
->processor_type
) {
176 case TGSI_PROCESSOR_VERTEX
:
177 r
= r600_pipe_shader_vs(ctx
, rpshader
);
179 case TGSI_PROCESSOR_FRAGMENT
:
180 r
= r600_pipe_shader_ps(ctx
, rpshader
);
189 int r600_pipe_shader_update(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
191 struct r600_context
*rctx
= r600_context(ctx
);
194 if (rpshader
== NULL
)
196 /* there should be enough input */
197 if (rctx
->vertex_elements
->count
< rpshader
->shader
.bc
.nresource
) {
198 R600_ERR("%d resources provided, expecting %d\n",
199 rctx
->vertex_elements
->count
, rpshader
->shader
.bc
.nresource
);
202 r
= r600_shader_update(ctx
, &rpshader
->shader
);
205 return r600_pipe_shader(ctx
, rpshader
);
208 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
210 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
213 if (i
->Instruction
.NumDstRegs
> 1) {
214 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
217 if (i
->Instruction
.Predicate
) {
218 R600_ERR("predicate unsupported\n");
222 if (i
->Instruction
.Label
) {
223 R600_ERR("label unsupported\n");
227 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
228 if (i
->Src
[j
].Register
.Dimension
||
229 i
->Src
[j
].Register
.Absolute
) {
230 R600_ERR("unsupported src %d (dimension %d|absolute %d)\n", j
,
231 i
->Src
[j
].Register
.Dimension
,
232 i
->Src
[j
].Register
.Absolute
);
236 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
237 if (i
->Dst
[j
].Register
.Dimension
) {
238 R600_ERR("unsupported dst (dimension)\n");
245 static int evergreen_interp_alu(struct r600_shader_ctx
*ctx
, int gpr
)
248 struct r600_bc_alu alu
;
250 for (i
= 0; i
< 8; i
++) {
251 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
254 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW
;
256 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_XY
;
258 if ((i
> 1) && (i
< 6)) {
259 alu
.dst
.sel
= ctx
->shader
->input
[gpr
].gpr
;
263 alu
.dst
.chan
= i
% 4;
264 alu
.src
[0].chan
= (1 - (i
% 2));
265 alu
.src
[1].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ gpr
;
267 alu
.bank_swizzle_force
= SQ_ALU_VEC_210
;
270 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
278 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
280 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
281 struct r600_bc_vtx vtx
;
285 switch (d
->Declaration
.File
) {
286 case TGSI_FILE_INPUT
:
287 i
= ctx
->shader
->ninput
++;
288 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
289 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
290 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
291 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + i
;
292 if (ctx
->type
== TGSI_PROCESSOR_VERTEX
) {
293 /* turn input into fetch */
294 memset(&vtx
, 0, sizeof(struct r600_bc_vtx
));
298 /* register containing the index into the buffer */
301 vtx
.mega_fetch_count
= 0x1F;
302 vtx
.dst_gpr
= ctx
->shader
->input
[i
].gpr
;
307 r
= r600_bc_add_vtx(ctx
->bc
, &vtx
);
311 if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
->bc
->chiprev
== 2) {
312 /* turn input into interpolate on EG */
313 evergreen_interp_alu(ctx
, i
);
316 case TGSI_FILE_OUTPUT
:
317 i
= ctx
->shader
->noutput
++;
318 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
319 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
320 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + i
;
321 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
323 case TGSI_FILE_CONSTANT
:
324 case TGSI_FILE_TEMPORARY
:
325 case TGSI_FILE_SAMPLER
:
326 case TGSI_FILE_ADDRESS
:
329 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
335 static int r600_get_temp(struct r600_shader_ctx
*ctx
)
337 return ctx
->temp_reg
+ ctx
->max_driver_temp_used
++;
340 int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
)
342 struct tgsi_full_immediate
*immediate
;
343 struct r600_shader_ctx ctx
;
344 struct r600_bc_output output
[32];
345 unsigned output_done
, noutput
;
349 ctx
.bc
= &shader
->bc
;
351 r
= r600_bc_init(ctx
.bc
, shader
->family
);
354 ctx
.bc
->use_mem_constant
= shader
->use_mem_constant
;
356 tgsi_scan_shader(tokens
, &ctx
.info
);
357 tgsi_parse_init(&ctx
.parse
, tokens
);
358 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
359 shader
->processor_type
= ctx
.type
;
361 /* register allocations */
362 /* Values [0,127] correspond to GPR[0..127].
363 * Values [128,159] correspond to constant buffer bank 0
364 * Values [160,191] correspond to constant buffer bank 1
365 * Values [256,511] correspond to cfile constants c[0..255].
366 * Other special values are shown in the list below.
367 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
368 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
369 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
370 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
371 * 248 SQ_ALU_SRC_0: special constant 0.0.
372 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
373 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
374 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
375 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
376 * 253 SQ_ALU_SRC_LITERAL: literal constant.
377 * 254 SQ_ALU_SRC_PV: previous vector result.
378 * 255 SQ_ALU_SRC_PS: previous scalar result.
380 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
381 ctx
.file_offset
[i
] = 0;
383 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
384 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
386 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
387 ctx
.info
.file_count
[TGSI_FILE_INPUT
];
388 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
389 ctx
.info
.file_count
[TGSI_FILE_OUTPUT
];
390 if (ctx
.shader
->use_mem_constant
)
391 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 128;
393 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 256;
395 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = 253;
396 ctx
.temp_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
397 ctx
.info
.file_count
[TGSI_FILE_TEMPORARY
];
402 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
403 tgsi_parse_token(&ctx
.parse
);
404 switch (ctx
.parse
.FullToken
.Token
.Type
) {
405 case TGSI_TOKEN_TYPE_IMMEDIATE
:
406 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
407 ctx
.literals
= realloc(ctx
.literals
, (ctx
.nliterals
+ 1) * 16);
408 if(ctx
.literals
== NULL
) {
412 ctx
.literals
[ctx
.nliterals
* 4 + 0] = immediate
->u
[0].Uint
;
413 ctx
.literals
[ctx
.nliterals
* 4 + 1] = immediate
->u
[1].Uint
;
414 ctx
.literals
[ctx
.nliterals
* 4 + 2] = immediate
->u
[2].Uint
;
415 ctx
.literals
[ctx
.nliterals
* 4 + 3] = immediate
->u
[3].Uint
;
418 case TGSI_TOKEN_TYPE_DECLARATION
:
419 r
= tgsi_declaration(&ctx
);
423 case TGSI_TOKEN_TYPE_INSTRUCTION
:
424 r
= tgsi_is_supported(&ctx
);
427 ctx
.max_driver_temp_used
= 0;
428 /* reserve first tmp for everyone */
430 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
431 if (ctx
.bc
->chiprev
== 2)
432 ctx
.inst_info
= &eg_shader_tgsi_instruction
[opcode
];
434 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
435 r
= ctx
.inst_info
->process(&ctx
);
438 r
= r600_bc_add_literal(ctx
.bc
, ctx
.value
);
443 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
449 noutput
= shader
->noutput
;
450 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
451 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
452 output
[i
].gpr
= shader
->output
[i
].gpr
;
453 output
[i
].elem_size
= 3;
454 output
[i
].swizzle_x
= 0;
455 output
[i
].swizzle_y
= 1;
456 output
[i
].swizzle_z
= 2;
457 output
[i
].swizzle_w
= 3;
458 output
[i
].barrier
= 1;
459 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
460 output
[i
].array_base
= i
- pos0
;
461 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
463 case TGSI_PROCESSOR_VERTEX
:
464 if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
465 output
[i
].array_base
= 60;
466 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
467 /* position doesn't count in array_base */
470 if (shader
->output
[i
].name
== TGSI_SEMANTIC_PSIZE
) {
471 output
[i
].array_base
= 61;
472 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
473 /* position doesn't count in array_base */
477 case TGSI_PROCESSOR_FRAGMENT
:
478 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
479 output
[i
].array_base
= shader
->output
[i
].sid
;
480 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
481 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
482 output
[i
].array_base
= 61;
483 output
[i
].swizzle_x
= 2;
484 output
[i
].swizzle_y
= output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
485 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
487 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
493 R600_ERR("unsupported processor type %d\n", ctx
.type
);
498 /* add fake param output for vertex shader if no param is exported */
499 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
500 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
501 if (output
[i
].type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
) {
507 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
509 output
[i
].elem_size
= 3;
510 output
[i
].swizzle_x
= 0;
511 output
[i
].swizzle_y
= 1;
512 output
[i
].swizzle_z
= 2;
513 output
[i
].swizzle_w
= 3;
514 output
[i
].barrier
= 1;
515 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
516 output
[i
].array_base
= 0;
517 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
521 /* add fake pixel export */
522 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& !noutput
) {
523 memset(&output
[0], 0, sizeof(struct r600_bc_output
));
525 output
[0].elem_size
= 3;
526 output
[0].swizzle_x
= 7;
527 output
[0].swizzle_y
= 7;
528 output
[0].swizzle_z
= 7;
529 output
[0].swizzle_w
= 7;
530 output
[0].barrier
= 1;
531 output
[0].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
532 output
[0].array_base
= 0;
533 output
[0].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
536 /* set export done on last export of each type */
537 for (i
= noutput
- 1, output_done
= 0; i
>= 0; i
--) {
538 if (i
== (noutput
- 1)) {
539 output
[i
].end_of_program
= 1;
541 if (!(output_done
& (1 << output
[i
].type
))) {
542 output_done
|= (1 << output
[i
].type
);
543 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
);
546 /* add output to bytecode */
547 for (i
= 0; i
< noutput
; i
++) {
548 r
= r600_bc_add_output(ctx
.bc
, &output
[i
]);
553 tgsi_parse_free(&ctx
.parse
);
557 tgsi_parse_free(&ctx
.parse
);
561 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
563 R600_ERR("%d tgsi opcode unsupported\n", ctx
->inst_info
->tgsi_opcode
);
567 static int tgsi_end(struct r600_shader_ctx
*ctx
)
572 static int tgsi_src(struct r600_shader_ctx
*ctx
,
573 const struct tgsi_full_src_register
*tgsi_src
,
574 struct r600_bc_alu_src
*r600_src
)
577 memset(r600_src
, 0, sizeof(struct r600_bc_alu_src
));
578 r600_src
->sel
= tgsi_src
->Register
.Index
;
579 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
581 index
= tgsi_src
->Register
.Index
;
582 ctx
->value
[0] = ctx
->literals
[index
* 4 + 0];
583 ctx
->value
[1] = ctx
->literals
[index
* 4 + 1];
584 ctx
->value
[2] = ctx
->literals
[index
* 4 + 2];
585 ctx
->value
[3] = ctx
->literals
[index
* 4 + 3];
587 if (tgsi_src
->Register
.Indirect
)
588 r600_src
->rel
= V_SQ_REL_RELATIVE
;
589 r600_src
->neg
= tgsi_src
->Register
.Negate
;
590 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
594 static int tgsi_dst(struct r600_shader_ctx
*ctx
,
595 const struct tgsi_full_dst_register
*tgsi_dst
,
597 struct r600_bc_alu_dst
*r600_dst
)
599 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
601 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
602 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
603 r600_dst
->chan
= swizzle
;
605 if (tgsi_dst
->Register
.Indirect
)
606 r600_dst
->rel
= V_SQ_REL_RELATIVE
;
607 if (inst
->Instruction
.Saturate
) {
613 static unsigned tgsi_chan(const struct tgsi_full_src_register
*tgsi_src
, unsigned swizzle
)
617 return tgsi_src
->Register
.SwizzleX
;
619 return tgsi_src
->Register
.SwizzleY
;
621 return tgsi_src
->Register
.SwizzleZ
;
623 return tgsi_src
->Register
.SwizzleW
;
629 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
631 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
632 struct r600_bc_alu alu
;
633 int i
, j
, k
, nconst
, r
;
635 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
636 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
639 r
= tgsi_src(ctx
, &inst
->Src
[i
], &r600_src
[i
]);
644 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
645 if (inst
->Src
[j
].Register
.File
== TGSI_FILE_CONSTANT
&& j
> 0) {
646 int treg
= r600_get_temp(ctx
);
647 for (k
= 0; k
< 4; k
++) {
648 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
649 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
650 alu
.src
[0].sel
= r600_src
[j
].sel
;
657 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
661 r600_src
[j
].sel
= treg
;
668 /* need to move any immediate into a temp - for trig functions which use literal for PI stuff */
669 static int tgsi_split_literal_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
671 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
672 struct r600_bc_alu alu
;
673 int i
, j
, k
, nliteral
, r
;
675 for (i
= 0, nliteral
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
676 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_IMMEDIATE
) {
680 for (i
= 0, j
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
681 if (inst
->Src
[j
].Register
.File
== TGSI_FILE_IMMEDIATE
) {
682 int treg
= r600_get_temp(ctx
);
683 for (k
= 0; k
< 4; k
++) {
684 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
685 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
686 alu
.src
[0].sel
= r600_src
[j
].sel
;
693 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
697 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
700 r600_src
[j
].sel
= treg
;
707 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
)
709 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
710 struct r600_bc_alu_src r600_src
[3];
711 struct r600_bc_alu alu
;
715 for (i
= 0; i
< 4; i
++) {
716 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
721 r
= tgsi_split_constant(ctx
, r600_src
);
724 for (i
= 0; i
< lasti
+ 1; i
++) {
725 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
728 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
729 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
733 alu
.inst
= ctx
->inst_info
->r600_opcode
;
735 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
736 alu
.src
[j
] = r600_src
[j
];
737 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
740 alu
.src
[0] = r600_src
[1];
741 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], i
);
743 alu
.src
[1] = r600_src
[0];
744 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
746 /* handle some special cases */
747 switch (ctx
->inst_info
->tgsi_opcode
) {
748 case TGSI_OPCODE_SUB
:
751 case TGSI_OPCODE_ABS
:
760 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
767 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
769 return tgsi_op2_s(ctx
, 0);
772 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
774 return tgsi_op2_s(ctx
, 1);
778 * r600 - trunc to -PI..PI range
779 * r700 - normalize by dividing by 2PI
782 static int tgsi_setup_trig(struct r600_shader_ctx
*ctx
,
783 struct r600_bc_alu_src r600_src
[3])
785 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
787 uint32_t lit_vals
[4];
788 struct r600_bc_alu alu
;
790 memset(lit_vals
, 0, 4*4);
791 r
= tgsi_split_constant(ctx
, r600_src
);
795 r
= tgsi_split_literal_constant(ctx
, r600_src
);
799 lit_vals
[0] = fui(1.0 /(3.1415926535 * 2));
800 lit_vals
[1] = fui(0.5f
);
802 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
803 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
807 alu
.dst
.sel
= ctx
->temp_reg
;
810 alu
.src
[0] = r600_src
[0];
811 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
813 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
815 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
818 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
821 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
825 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
826 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
829 alu
.dst
.sel
= ctx
->temp_reg
;
832 alu
.src
[0].sel
= ctx
->temp_reg
;
835 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
839 if (ctx
->bc
->chiprev
== 0) {
840 lit_vals
[0] = fui(3.1415926535897f
* 2.0f
);
841 lit_vals
[1] = fui(-3.1415926535897f
);
843 lit_vals
[0] = fui(1.0f
);
844 lit_vals
[1] = fui(-0.5f
);
847 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
848 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
852 alu
.dst
.sel
= ctx
->temp_reg
;
855 alu
.src
[0].sel
= ctx
->temp_reg
;
858 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
860 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
863 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
866 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
872 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
874 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
875 struct r600_bc_alu_src r600_src
[3];
876 struct r600_bc_alu alu
;
880 r
= tgsi_setup_trig(ctx
, r600_src
);
884 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
885 alu
.inst
= ctx
->inst_info
->r600_opcode
;
887 alu
.dst
.sel
= ctx
->temp_reg
;
890 alu
.src
[0].sel
= ctx
->temp_reg
;
893 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
897 /* replicate result */
898 for (i
= 0; i
< 4; i
++) {
899 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
))
902 for (i
= 0; i
< lasti
+ 1; i
++) {
903 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
906 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
907 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
909 alu
.src
[0].sel
= ctx
->temp_reg
;
910 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
915 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
922 static int tgsi_scs(struct r600_shader_ctx
*ctx
)
924 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
925 struct r600_bc_alu_src r600_src
[3];
926 struct r600_bc_alu alu
;
929 /* We'll only need the trig stuff if we are going to write to the
930 * X or Y components of the destination vector.
932 if (likely(inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_XY
)) {
933 r
= tgsi_setup_trig(ctx
, r600_src
);
939 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_X
) {
940 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
941 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
942 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
946 alu
.src
[0].sel
= ctx
->temp_reg
;
949 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
955 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Y
) {
956 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
957 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
958 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
962 alu
.src
[0].sel
= ctx
->temp_reg
;
965 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
971 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Z
) {
972 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
974 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
976 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
980 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
985 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
989 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
995 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
996 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
998 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1000 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1004 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1005 alu
.src
[0].chan
= 0;
1009 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1013 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1021 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
1023 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1024 struct r600_bc_alu alu
;
1027 for (i
= 0; i
< 4; i
++) {
1028 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1029 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1033 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1035 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
1036 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1039 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1042 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1047 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1051 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1055 /* kill must be last in ALU */
1056 ctx
->bc
->force_add_cf
= 1;
1057 ctx
->shader
->uses_kill
= TRUE
;
1061 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
1063 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1064 struct r600_bc_alu alu
;
1065 struct r600_bc_alu_src r600_src
[3];
1068 r
= tgsi_split_constant(ctx
, r600_src
);
1071 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1076 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1077 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1078 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
1079 alu
.src
[0].chan
= 0;
1080 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1083 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
1084 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1088 /* dst.y = max(src.x, 0.0) */
1089 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1090 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1091 alu
.src
[0] = r600_src
[0];
1092 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1093 alu
.src
[1].chan
= 0;
1094 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1097 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
1098 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1103 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1104 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1105 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1106 alu
.src
[0].chan
= 0;
1107 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1110 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
1112 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1116 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1120 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
1125 /* dst.z = log(src.y) */
1126 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1127 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1128 alu
.src
[0] = r600_src
[0];
1129 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1130 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1134 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1138 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1142 chan
= alu
.dst
.chan
;
1145 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
1146 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1147 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
1148 alu
.src
[0] = r600_src
[0];
1149 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1150 alu
.src
[1].sel
= sel
;
1151 alu
.src
[1].chan
= chan
;
1153 alu
.src
[2] = r600_src
[0];
1154 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], 0);
1155 alu
.dst
.sel
= ctx
->temp_reg
;
1160 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1164 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1167 /* dst.z = exp(tmp.x) */
1168 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1169 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1170 alu
.src
[0].sel
= ctx
->temp_reg
;
1171 alu
.src
[0].chan
= 0;
1172 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1176 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1183 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
1185 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1186 struct r600_bc_alu alu
;
1189 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1192 * For state trackers other than OpenGL, we'll want to use
1193 * _RECIPSQRT_IEEE instead.
1195 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
1197 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1198 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1201 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1204 alu
.dst
.sel
= ctx
->temp_reg
;
1207 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1210 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1213 /* replicate result */
1214 return tgsi_helper_tempx_replicate(ctx
);
1217 static int tgsi_trans(struct r600_shader_ctx
*ctx
)
1219 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1220 struct r600_bc_alu alu
;
1223 for (i
= 0; i
< 4; i
++) {
1224 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1225 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
1226 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1227 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1228 r
= tgsi_src(ctx
, &inst
->Src
[j
], &alu
.src
[j
]);
1231 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1233 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1237 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1245 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1247 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1248 struct r600_bc_alu alu
;
1251 for (i
= 0; i
< 4; i
++) {
1252 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1253 alu
.src
[0].sel
= ctx
->temp_reg
;
1254 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1256 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1259 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1262 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1269 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1271 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1272 struct r600_bc_alu alu
;
1275 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1276 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1277 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1278 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1281 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1283 alu
.dst
.sel
= ctx
->temp_reg
;
1286 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1289 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1292 /* replicate result */
1293 return tgsi_helper_tempx_replicate(ctx
);
1296 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1298 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1299 struct r600_bc_alu alu
;
1303 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1304 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1305 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1308 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1309 alu
.dst
.sel
= ctx
->temp_reg
;
1312 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1315 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1319 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1320 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL_IEEE
);
1321 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[0]);
1324 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], 0);
1325 alu
.src
[1].sel
= ctx
->temp_reg
;
1326 alu
.dst
.sel
= ctx
->temp_reg
;
1329 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1332 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1335 /* POW(a,b) = EXP2(b * LOG2(a))*/
1336 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1337 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1338 alu
.src
[0].sel
= ctx
->temp_reg
;
1339 alu
.dst
.sel
= ctx
->temp_reg
;
1342 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1345 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1348 return tgsi_helper_tempx_replicate(ctx
);
1351 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1353 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1354 struct r600_bc_alu alu
;
1355 struct r600_bc_alu_src r600_src
[3];
1358 r
= tgsi_split_constant(ctx
, r600_src
);
1362 /* tmp = (src > 0 ? 1 : src) */
1363 for (i
= 0; i
< 4; i
++) {
1364 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1365 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1368 alu
.dst
.sel
= ctx
->temp_reg
;
1371 alu
.src
[0] = r600_src
[0];
1372 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1374 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1376 alu
.src
[2] = r600_src
[0];
1377 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], i
);
1380 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1384 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1388 /* dst = (-tmp > 0 ? -1 : tmp) */
1389 for (i
= 0; i
< 4; i
++) {
1390 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1391 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1393 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1397 alu
.src
[0].sel
= ctx
->temp_reg
;
1398 alu
.src
[0].chan
= i
;
1401 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1404 alu
.src
[2].sel
= ctx
->temp_reg
;
1405 alu
.src
[2].chan
= i
;
1409 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1416 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1418 struct r600_bc_alu alu
;
1421 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1424 for (i
= 0; i
< 4; i
++) {
1425 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1426 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1427 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
1430 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1431 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1434 alu
.src
[0].sel
= ctx
->temp_reg
;
1435 alu
.src
[0].chan
= i
;
1440 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1447 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1449 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1450 struct r600_bc_alu_src r600_src
[3];
1451 struct r600_bc_alu alu
;
1454 r
= tgsi_split_constant(ctx
, r600_src
);
1457 /* do it in 2 step as op3 doesn't support writemask */
1458 for (i
= 0; i
< 4; i
++) {
1459 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1460 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1461 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1462 alu
.src
[j
] = r600_src
[j
];
1463 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1465 alu
.dst
.sel
= ctx
->temp_reg
;
1472 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1476 return tgsi_helper_copy(ctx
, inst
);
1479 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1481 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1482 struct r600_bc_alu_src r600_src
[3];
1483 struct r600_bc_alu alu
;
1486 r
= tgsi_split_constant(ctx
, r600_src
);
1489 for (i
= 0; i
< 4; i
++) {
1490 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1491 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1492 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1493 alu
.src
[j
] = r600_src
[j
];
1494 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1496 alu
.dst
.sel
= ctx
->temp_reg
;
1499 /* handle some special cases */
1500 switch (ctx
->inst_info
->tgsi_opcode
) {
1501 case TGSI_OPCODE_DP2
:
1503 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1504 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1507 case TGSI_OPCODE_DP3
:
1509 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1510 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1513 case TGSI_OPCODE_DPH
:
1515 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1516 alu
.src
[0].chan
= 0;
1526 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1530 return tgsi_helper_copy(ctx
, inst
);
1533 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1535 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1536 struct r600_bc_tex tex
;
1537 struct r600_bc_alu alu
;
1541 boolean src_not_temp
= inst
->Src
[0].Register
.File
!= TGSI_FILE_TEMPORARY
;
1542 uint32_t lit_vals
[4];
1544 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
1546 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1547 /* Add perspective divide */
1548 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1549 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1550 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1554 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1555 alu
.dst
.sel
= ctx
->temp_reg
;
1559 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1563 for (i
= 0; i
< 3; i
++) {
1564 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1565 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1566 alu
.src
[0].sel
= ctx
->temp_reg
;
1567 alu
.src
[0].chan
= 3;
1568 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1571 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1572 alu
.dst
.sel
= ctx
->temp_reg
;
1575 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1579 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1580 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1581 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1582 alu
.src
[0].chan
= 0;
1583 alu
.dst
.sel
= ctx
->temp_reg
;
1587 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1590 src_not_temp
= FALSE
;
1591 src_gpr
= ctx
->temp_reg
;
1594 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1595 int src_chan
, src2_chan
;
1597 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
1598 for (i
= 0; i
< 4; i
++) {
1599 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1600 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
1619 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1622 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], src_chan
);
1623 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1626 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], src2_chan
);
1627 alu
.dst
.sel
= ctx
->temp_reg
;
1632 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1637 /* tmp1.z = RCP_e(|tmp1.z|) */
1638 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1639 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1640 alu
.src
[0].sel
= ctx
->temp_reg
;
1641 alu
.src
[0].chan
= 2;
1643 alu
.dst
.sel
= ctx
->temp_reg
;
1647 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1651 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
1652 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
1653 * muladd has no writemask, have to use another temp
1655 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1656 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1659 alu
.src
[0].sel
= ctx
->temp_reg
;
1660 alu
.src
[0].chan
= 0;
1661 alu
.src
[1].sel
= ctx
->temp_reg
;
1662 alu
.src
[1].chan
= 2;
1664 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1665 alu
.src
[2].chan
= 0;
1667 alu
.dst
.sel
= ctx
->temp_reg
;
1671 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1675 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1676 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1679 alu
.src
[0].sel
= ctx
->temp_reg
;
1680 alu
.src
[0].chan
= 1;
1681 alu
.src
[1].sel
= ctx
->temp_reg
;
1682 alu
.src
[1].chan
= 2;
1684 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1685 alu
.src
[2].chan
= 0;
1687 alu
.dst
.sel
= ctx
->temp_reg
;
1692 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1696 lit_vals
[0] = fui(1.5f
);
1698 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
1701 src_not_temp
= FALSE
;
1702 src_gpr
= ctx
->temp_reg
;
1706 for (i
= 0; i
< 4; i
++) {
1707 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1708 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1709 alu
.src
[0].sel
= src_gpr
;
1710 alu
.src
[0].chan
= i
;
1711 alu
.dst
.sel
= ctx
->temp_reg
;
1716 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1720 src_gpr
= ctx
->temp_reg
;
1723 opcode
= ctx
->inst_info
->r600_opcode
;
1724 if (opcode
== SQ_TEX_INST_SAMPLE
&&
1725 (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
))
1726 opcode
= SQ_TEX_INST_SAMPLE_C
;
1728 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
1730 tex
.resource_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
1731 tex
.sampler_id
= tex
.resource_id
;
1732 tex
.src_gpr
= src_gpr
;
1733 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
1743 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1750 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
1751 tex
.coord_type_x
= 1;
1752 tex
.coord_type_y
= 1;
1753 tex
.coord_type_z
= 1;
1754 tex
.coord_type_w
= 1;
1757 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
)
1760 r
= r600_bc_add_tex(ctx
->bc
, &tex
);
1764 /* add shadow ambient support - gallium doesn't do it yet */
1769 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
1771 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1772 struct r600_bc_alu_src r600_src
[3];
1773 struct r600_bc_alu alu
;
1777 r
= tgsi_split_constant(ctx
, r600_src
);
1781 for (i
= 0; i
< 4; i
++) {
1782 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1783 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
1784 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1785 alu
.src
[0].chan
= 0;
1786 alu
.src
[1] = r600_src
[0];
1787 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1789 alu
.dst
.sel
= ctx
->temp_reg
;
1795 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1799 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1803 /* (1 - src0) * src2 */
1804 for (i
= 0; i
< 4; i
++) {
1805 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1806 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1807 alu
.src
[0].sel
= ctx
->temp_reg
;
1808 alu
.src
[0].chan
= i
;
1809 alu
.src
[1] = r600_src
[2];
1810 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1811 alu
.dst
.sel
= ctx
->temp_reg
;
1817 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1821 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1825 /* src0 * src1 + (1 - src0) * src2 */
1826 for (i
= 0; i
< 4; i
++) {
1827 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1828 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1830 alu
.src
[0] = r600_src
[0];
1831 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1832 alu
.src
[1] = r600_src
[1];
1833 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
1834 alu
.src
[2].sel
= ctx
->temp_reg
;
1835 alu
.src
[2].chan
= i
;
1836 alu
.dst
.sel
= ctx
->temp_reg
;
1841 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1845 return tgsi_helper_copy(ctx
, inst
);
1848 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
1850 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1851 struct r600_bc_alu_src r600_src
[3];
1852 struct r600_bc_alu alu
;
1856 r
= tgsi_split_constant(ctx
, r600_src
);
1860 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1863 for (i
= 0; i
< 4; i
++) {
1864 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1865 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
1866 alu
.src
[0] = r600_src
[0];
1867 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1869 alu
.src
[1] = r600_src
[2];
1870 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1872 alu
.src
[2] = r600_src
[1];
1873 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[1], i
);
1876 alu
.dst
.sel
= ctx
->temp_reg
;
1878 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1887 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1892 return tgsi_helper_copy(ctx
, inst
);
1896 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
1898 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1899 struct r600_bc_alu_src r600_src
[3];
1900 struct r600_bc_alu alu
;
1901 uint32_t use_temp
= 0;
1904 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1907 r
= tgsi_split_constant(ctx
, r600_src
);
1911 for (i
= 0; i
< 4; i
++) {
1912 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1913 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1915 alu
.src
[0] = r600_src
[0];
1918 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1921 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1924 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1927 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1928 alu
.src
[0].chan
= i
;
1931 alu
.src
[1] = r600_src
[1];
1934 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1937 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1940 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1943 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1944 alu
.src
[1].chan
= i
;
1947 alu
.dst
.sel
= ctx
->temp_reg
;
1953 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1957 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1962 for (i
= 0; i
< 4; i
++) {
1963 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1964 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1966 alu
.src
[0] = r600_src
[0];
1969 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1972 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1975 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1978 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1979 alu
.src
[0].chan
= i
;
1982 alu
.src
[1] = r600_src
[1];
1985 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1988 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1991 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1994 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1995 alu
.src
[1].chan
= i
;
1998 alu
.src
[2].sel
= ctx
->temp_reg
;
2000 alu
.src
[2].chan
= i
;
2003 alu
.dst
.sel
= ctx
->temp_reg
;
2005 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2014 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2018 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2023 return tgsi_helper_copy(ctx
, inst
);
2027 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
2029 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2030 struct r600_bc_alu_src r600_src
[3];
2031 struct r600_bc_alu alu
;
2034 /* result.x = 2^floor(src); */
2035 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2036 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2038 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2039 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2043 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2045 alu
.dst
.sel
= ctx
->temp_reg
;
2049 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2053 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2057 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2058 alu
.src
[0].sel
= ctx
->temp_reg
;
2059 alu
.src
[0].chan
= 0;
2061 alu
.dst
.sel
= ctx
->temp_reg
;
2065 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2069 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2074 /* result.y = tmp - floor(tmp); */
2075 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2076 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2078 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
2079 alu
.src
[0] = r600_src
[0];
2080 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2083 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2085 alu
.dst
.sel
= ctx
->temp_reg
;
2086 // r = tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
2094 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2097 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2102 /* result.z = RoughApprox2ToX(tmp);*/
2103 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
2104 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2105 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2106 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2109 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2111 alu
.dst
.sel
= ctx
->temp_reg
;
2117 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2120 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2125 /* result.w = 1.0;*/
2126 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
2127 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2129 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2130 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2131 alu
.src
[0].chan
= 0;
2133 alu
.dst
.sel
= ctx
->temp_reg
;
2137 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2140 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2144 return tgsi_helper_copy(ctx
, inst
);
2147 static int tgsi_log(struct r600_shader_ctx
*ctx
)
2149 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2150 struct r600_bc_alu alu
;
2153 /* result.x = floor(log2(src)); */
2154 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2155 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2157 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2158 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2162 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2164 alu
.dst
.sel
= ctx
->temp_reg
;
2168 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2172 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2176 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2177 alu
.src
[0].sel
= ctx
->temp_reg
;
2178 alu
.src
[0].chan
= 0;
2180 alu
.dst
.sel
= ctx
->temp_reg
;
2185 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2189 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2194 /* result.y = src.x / (2 ^ floor(log2(src.x))); */
2195 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2196 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2198 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2199 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2203 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2205 alu
.dst
.sel
= ctx
->temp_reg
;
2210 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2214 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2218 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2220 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2221 alu
.src
[0].sel
= ctx
->temp_reg
;
2222 alu
.src
[0].chan
= 1;
2224 alu
.dst
.sel
= ctx
->temp_reg
;
2229 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2233 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2237 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2239 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2240 alu
.src
[0].sel
= ctx
->temp_reg
;
2241 alu
.src
[0].chan
= 1;
2243 alu
.dst
.sel
= ctx
->temp_reg
;
2248 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2252 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2256 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2258 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2259 alu
.src
[0].sel
= ctx
->temp_reg
;
2260 alu
.src
[0].chan
= 1;
2262 alu
.dst
.sel
= ctx
->temp_reg
;
2267 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2271 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2275 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2277 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2279 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2283 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2285 alu
.src
[1].sel
= ctx
->temp_reg
;
2286 alu
.src
[1].chan
= 1;
2288 alu
.dst
.sel
= ctx
->temp_reg
;
2293 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2297 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2302 /* result.z = log2(src);*/
2303 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
2304 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2306 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2307 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2311 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2313 alu
.dst
.sel
= ctx
->temp_reg
;
2318 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2322 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2327 /* result.w = 1.0; */
2328 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
2329 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2331 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2332 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2333 alu
.src
[0].chan
= 0;
2335 alu
.dst
.sel
= ctx
->temp_reg
;
2340 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2344 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2349 return tgsi_helper_copy(ctx
, inst
);
2352 /* r6/7 only for now */
2353 static int tgsi_arl(struct r600_shader_ctx
*ctx
)
2355 /* TODO from r600c, ar values don't persist between clauses */
2356 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2357 struct r600_bc_alu alu
;
2359 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2361 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR
;
2363 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2366 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2370 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2373 ctx
->bc
->cf_last
->r6xx_uses_waterfall
= 1;
2377 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
2379 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2380 struct r600_bc_alu alu
;
2383 for (i
= 0; i
< 4; i
++) {
2384 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2386 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2387 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2391 if (i
== 0 || i
== 3) {
2392 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2394 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2397 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2400 if (i
== 0 || i
== 2) {
2401 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2403 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[1]);
2406 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
2410 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2417 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
2419 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2420 struct r600_bc_alu alu
;
2423 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2427 alu
.dst
.sel
= ctx
->temp_reg
;
2431 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2434 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2435 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2436 alu
.src
[1].chan
= 0;
2440 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
2446 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
2448 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
2449 ctx
->bc
->cf_last
->pop_count
= pops
;
2453 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
2457 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2461 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
2464 /* TOODO : for 16 vp asic should -= 2; */
2465 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2470 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
2472 if (check_max_only
) {
2485 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
2486 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2487 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2488 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
2494 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2498 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
2501 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2505 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
2506 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2507 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2508 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
2512 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
2514 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
2516 sp
->mid
= (struct r600_bc_cf
**)realloc((void *)sp
->mid
,
2517 sizeof(struct r600_bc_cf
*) * (sp
->num_mid
+ 1));
2518 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
2522 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
2525 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
2526 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
2529 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
2531 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
2543 static int emit_return(struct r600_shader_ctx
*ctx
)
2545 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
2549 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
2552 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_JUMP
);
2553 ctx
->bc
->cf_last
->pop_count
= pops
;
2554 /* TODO work out offset */
2558 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
2563 static void emit_testflag(struct r600_shader_ctx
*ctx
)
2568 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
2571 emit_jump_to_offset(ctx
, 1, 4);
2572 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
2573 pops(ctx
, ifidx
+ 1);
2577 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
2581 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2582 ctx
->bc
->cf_last
->pop_count
= 1;
2584 fc_set_mid(ctx
, fc_sp
);
2590 static int tgsi_if(struct r600_shader_ctx
*ctx
)
2592 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
2594 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
2596 fc_pushlevel(ctx
, FC_IF
);
2598 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
2602 static int tgsi_else(struct r600_shader_ctx
*ctx
)
2604 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
2605 ctx
->bc
->cf_last
->pop_count
= 1;
2607 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
2608 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
2612 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
2615 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
2616 R600_ERR("if/endif unbalanced in shader\n");
2620 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
2621 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2622 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
2624 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2628 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
2632 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
2634 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
2636 fc_pushlevel(ctx
, FC_LOOP
);
2638 /* check stack depth */
2639 callstack_check_depth(ctx
, FC_LOOP
, 0);
2643 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
2647 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
2649 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
2650 R600_ERR("loop/endloop in shader code are not paired.\n");
2654 /* fixup loop pointers - from r600isa
2655 LOOP END points to CF after LOOP START,
2656 LOOP START point to CF after LOOP END
2657 BRK/CONT point to LOOP END CF
2659 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
2661 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2663 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
2664 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
2666 /* TODO add LOOPRET support */
2668 callstack_decrease_current(ctx
, FC_LOOP
);
2672 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
2676 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
2678 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
2683 R600_ERR("Break not inside loop/endloop pair\n");
2687 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2688 ctx
->bc
->cf_last
->pop_count
= 1;
2690 fc_set_mid(ctx
, fscp
);
2693 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
2697 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
2698 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_arl
},
2699 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2700 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2703 * For state trackers other than OpenGL, we'll want to use
2704 * _RECIP_IEEE instead.
2706 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
2708 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
2709 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2710 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
2711 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2712 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2713 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2714 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2715 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2716 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2717 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2718 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2719 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2720 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2721 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2722 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2723 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2725 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2726 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2728 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2729 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2730 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2731 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2732 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2733 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2734 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2735 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2736 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2737 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2739 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2740 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2741 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2742 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2743 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2744 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2745 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2746 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
2747 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2748 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2749 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2750 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2751 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2752 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
2753 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2754 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
2755 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
2756 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
2757 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
2758 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2759 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2760 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2761 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2762 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2763 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2764 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2765 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2766 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2767 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2768 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2769 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2770 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2771 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2772 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
2773 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
2774 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
2775 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2776 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2777 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2778 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2779 {TGSI_OPCODE_TXL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2780 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
2781 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
2783 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2784 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2785 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
2786 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
2788 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2789 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2790 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2791 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2792 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2793 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2794 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2795 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
2796 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2798 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2799 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2800 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2801 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2802 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2803 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2804 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2805 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2806 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
2807 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2808 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2809 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
2810 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2811 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
2812 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2814 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2815 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2816 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2817 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2818 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2820 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2821 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2822 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2823 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2824 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2825 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2826 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2827 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2828 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
2829 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
2831 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2832 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2833 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2834 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2835 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2836 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2837 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2838 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2839 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2840 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2841 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2842 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2843 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2844 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2845 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2846 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2847 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2848 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2849 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2850 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2851 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2852 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2853 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2854 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2855 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2856 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2857 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2858 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2861 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
2862 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2863 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2864 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2865 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
2866 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
2867 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2868 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2869 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2870 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2871 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2872 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2873 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2874 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2875 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2876 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2877 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2878 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2879 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2880 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2881 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2883 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2884 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2886 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2887 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2888 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2889 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2890 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2891 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2892 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2893 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2894 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2895 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2897 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2898 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2899 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2900 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2901 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2902 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2903 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2904 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
2905 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2906 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2907 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2908 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2909 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2910 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
2911 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2912 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
2913 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
2914 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
2915 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
2916 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2917 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2918 {TGSI_OPCODE_TXD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2919 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2920 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2921 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2922 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2923 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2924 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2925 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2926 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2927 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2928 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2929 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2930 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
2931 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
2932 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
2933 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2934 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2935 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2936 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2937 {TGSI_OPCODE_TXL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2938 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
2939 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
2941 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2942 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2943 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
2944 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
2946 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2947 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2948 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2949 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2950 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2951 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2952 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2953 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
2954 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2956 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2957 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2958 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2959 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2960 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2961 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2962 {TGSI_OPCODE_TXF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2963 {TGSI_OPCODE_TXQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2964 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
2965 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2966 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2967 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
2968 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2969 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
2970 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2972 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2973 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2974 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2975 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2976 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2978 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2979 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2980 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2981 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2982 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2983 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2984 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2985 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2986 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
2987 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
2989 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2990 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2991 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2992 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2993 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2994 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2995 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2996 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2997 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2998 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2999 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3000 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3001 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3002 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3003 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3004 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3005 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3006 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3007 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3008 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3009 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3010 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3011 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3012 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3013 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3014 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3015 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3016 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},