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_pipe.h"
31 #include "r600_formats.h"
32 #include "r600_opcodes.h"
37 int r600_find_vs_semantic_index(struct r600_shader
*vs
,
38 struct r600_shader
*ps
, int id
)
40 struct r600_shader_io
*input
= &ps
->input
[id
];
42 for (int i
= 0; i
< vs
->noutput
; i
++) {
43 if (input
->name
== vs
->output
[i
].name
&&
44 input
->sid
== vs
->output
[i
].sid
) {
51 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
53 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
54 struct r600_shader
*rshader
= &shader
->shader
;
58 if (shader
->bo
== NULL
) {
59 shader
->bo
= r600_bo(rctx
->radeon
, rshader
->bc
.ndw
* 4, 4096, 0, 0);
60 if (shader
->bo
== NULL
) {
63 ptr
= r600_bo_map(rctx
->radeon
, shader
->bo
, 0, NULL
);
64 memcpy(ptr
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* 4);
65 r600_bo_unmap(rctx
->radeon
, shader
->bo
);
68 switch (rshader
->processor_type
) {
69 case TGSI_PROCESSOR_VERTEX
:
70 if (rshader
->family
>= CHIP_CEDAR
) {
71 evergreen_pipe_shader_vs(ctx
, shader
);
73 r600_pipe_shader_vs(ctx
, shader
);
76 case TGSI_PROCESSOR_FRAGMENT
:
77 if (rshader
->family
>= CHIP_CEDAR
) {
78 evergreen_pipe_shader_ps(ctx
, shader
);
80 r600_pipe_shader_ps(ctx
, shader
);
89 static int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
);
91 int r600_pipe_shader_create(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
, const struct tgsi_token
*tokens
)
93 static int dump_shaders
= -1;
94 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
97 /* Would like some magic "get_bool_option_once" routine.
99 if (dump_shaders
== -1)
100 dump_shaders
= debug_get_bool_option("R600_DUMP_SHADERS", FALSE
);
103 fprintf(stderr
, "--------------------------------------------------------------\n");
104 tgsi_dump(tokens
, 0);
106 shader
->shader
.family
= r600_get_family(rctx
->radeon
);
107 r
= r600_shader_from_tgsi(tokens
, &shader
->shader
);
109 R600_ERR("translation from TGSI failed !\n");
112 r
= r600_bc_build(&shader
->shader
.bc
);
114 R600_ERR("building bytecode failed !\n");
118 r600_bc_dump(&shader
->shader
.bc
);
119 fprintf(stderr
, "______________________________________________________________\n");
121 return r600_pipe_shader(ctx
, shader
);
124 void r600_pipe_shader_destroy(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
126 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
128 r600_bo_reference(rctx
->radeon
, &shader
->bo
, NULL
);
129 r600_bc_clear(&shader
->shader
.bc
);
133 * tgsi -> r600 shader
135 struct r600_shader_tgsi_instruction
;
137 struct r600_shader_src
{
146 struct r600_shader_ctx
{
147 struct tgsi_shader_info info
;
148 struct tgsi_parse_context parse
;
149 const struct tgsi_token
*tokens
;
151 unsigned file_offset
[TGSI_FILE_COUNT
];
154 struct r600_shader_tgsi_instruction
*inst_info
;
156 struct r600_shader
*shader
;
157 struct r600_shader_src src
[3];
160 u32 max_driver_temp_used
;
161 /* needed for evergreen interpolation */
162 boolean input_centroid
;
163 boolean input_linear
;
164 boolean input_perspective
;
168 struct r600_shader_tgsi_instruction
{
169 unsigned tgsi_opcode
;
171 unsigned r600_opcode
;
172 int (*process
)(struct r600_shader_ctx
*ctx
);
175 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[], eg_shader_tgsi_instruction
[];
176 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
178 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
180 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
183 if (i
->Instruction
.NumDstRegs
> 1) {
184 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
187 if (i
->Instruction
.Predicate
) {
188 R600_ERR("predicate unsupported\n");
192 if (i
->Instruction
.Label
) {
193 R600_ERR("label unsupported\n");
197 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
198 if (i
->Src
[j
].Register
.Dimension
) {
199 R600_ERR("unsupported src %d (dimension %d)\n", j
,
200 i
->Src
[j
].Register
.Dimension
);
204 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
205 if (i
->Dst
[j
].Register
.Dimension
) {
206 R600_ERR("unsupported dst (dimension)\n");
213 static int evergreen_interp_alu(struct r600_shader_ctx
*ctx
, int input
)
216 struct r600_bc_alu alu
;
217 int gpr
= 0, base_chan
= 0;
220 if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_PERSPECTIVE
) {
222 if (ctx
->shader
->input
[input
].centroid
)
224 } else if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_LINEAR
) {
226 /* if we have perspective add one */
227 if (ctx
->input_perspective
) {
229 /* if we have perspective centroid */
230 if (ctx
->input_centroid
)
233 if (ctx
->shader
->input
[input
].centroid
)
237 /* work out gpr and base_chan from index */
239 base_chan
= (2 * (ij_index
% 2)) + 1;
241 for (i
= 0; i
< 8; i
++) {
242 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
245 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW
;
247 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_XY
;
249 if ((i
> 1) && (i
< 6)) {
250 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
254 alu
.dst
.chan
= i
% 4;
256 alu
.src
[0].sel
= gpr
;
257 alu
.src
[0].chan
= (base_chan
- (i
% 2));
259 alu
.src
[1].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
261 alu
.bank_swizzle_force
= SQ_ALU_VEC_210
;
264 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
272 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
274 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
278 switch (d
->Declaration
.File
) {
279 case TGSI_FILE_INPUT
:
280 i
= ctx
->shader
->ninput
++;
281 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
282 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
283 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
284 ctx
->shader
->input
[i
].centroid
= d
->Declaration
.Centroid
;
285 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + i
;
286 if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
->bc
->chiprev
== CHIPREV_EVERGREEN
) {
287 /* turn input into interpolate on EG */
288 if (ctx
->shader
->input
[i
].name
!= TGSI_SEMANTIC_POSITION
) {
289 if (ctx
->shader
->input
[i
].interpolate
> 0) {
290 ctx
->shader
->input
[i
].lds_pos
= ctx
->shader
->nlds
++;
291 evergreen_interp_alu(ctx
, i
);
296 case TGSI_FILE_OUTPUT
:
297 i
= ctx
->shader
->noutput
++;
298 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
299 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
300 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + i
;
301 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
303 case TGSI_FILE_CONSTANT
:
304 case TGSI_FILE_TEMPORARY
:
305 case TGSI_FILE_SAMPLER
:
306 case TGSI_FILE_ADDRESS
:
309 case TGSI_FILE_SYSTEM_VALUE
:
310 if (d
->Semantic
.Name
== TGSI_SEMANTIC_INSTANCEID
) {
311 struct r600_bc_alu alu
;
312 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
314 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
);
323 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
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
++;
341 * for evergreen we need to scan the shader to find the number of GPRs we need to
342 * reserve for interpolation.
344 * we need to know if we are going to emit
345 * any centroid inputs
346 * if perspective and linear are required
348 static int evergreen_gpr_count(struct r600_shader_ctx
*ctx
)
353 ctx
->input_linear
= FALSE
;
354 ctx
->input_perspective
= FALSE
;
355 ctx
->input_centroid
= FALSE
;
356 ctx
->num_interp_gpr
= 1;
358 /* any centroid inputs */
359 for (i
= 0; i
< ctx
->info
.num_inputs
; i
++) {
360 /* skip position/face */
361 if (ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_POSITION
||
362 ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_FACE
)
364 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_LINEAR
)
365 ctx
->input_linear
= TRUE
;
366 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_PERSPECTIVE
)
367 ctx
->input_perspective
= TRUE
;
368 if (ctx
->info
.input_centroid
[i
])
369 ctx
->input_centroid
= TRUE
;
373 /* ignoring sample for now */
374 if (ctx
->input_perspective
)
376 if (ctx
->input_linear
)
378 if (ctx
->input_centroid
)
381 ctx
->num_interp_gpr
+= (num_baryc
+ 1) >> 1;
383 /* TODO PULL MODEL and LINE STIPPLE, FIXED PT POS */
384 return ctx
->num_interp_gpr
;
387 static void tgsi_src(struct r600_shader_ctx
*ctx
,
388 const struct tgsi_full_src_register
*tgsi_src
,
389 struct r600_shader_src
*r600_src
)
391 memset(r600_src
, 0, sizeof(*r600_src
));
392 r600_src
->swizzle
[0] = tgsi_src
->Register
.SwizzleX
;
393 r600_src
->swizzle
[1] = tgsi_src
->Register
.SwizzleY
;
394 r600_src
->swizzle
[2] = tgsi_src
->Register
.SwizzleZ
;
395 r600_src
->swizzle
[3] = tgsi_src
->Register
.SwizzleW
;
396 r600_src
->neg
= tgsi_src
->Register
.Negate
;
397 r600_src
->abs
= tgsi_src
->Register
.Absolute
;
399 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
401 if ((tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleY
) &&
402 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleZ
) &&
403 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleW
)) {
405 index
= tgsi_src
->Register
.Index
* 4 + tgsi_src
->Register
.SwizzleX
;
406 r600_bc_special_constants(ctx
->literals
[index
], &r600_src
->sel
, &r600_src
->neg
);
407 if (r600_src
->sel
!= V_SQ_ALU_SRC_LITERAL
)
410 index
= tgsi_src
->Register
.Index
;
411 r600_src
->sel
= V_SQ_ALU_SRC_LITERAL
;
412 memcpy(r600_src
->value
, ctx
->literals
+ index
* 4, sizeof(r600_src
->value
));
413 } else if (tgsi_src
->Register
.File
== TGSI_FILE_SYSTEM_VALUE
) {
414 /* assume we wan't TGSI_SEMANTIC_INSTANCEID here */
415 r600_src
->swizzle
[0] = 3;
416 r600_src
->swizzle
[1] = 3;
417 r600_src
->swizzle
[2] = 3;
418 r600_src
->swizzle
[3] = 3;
421 if (tgsi_src
->Register
.Indirect
)
422 r600_src
->rel
= V_SQ_REL_RELATIVE
;
423 r600_src
->sel
= tgsi_src
->Register
.Index
;
424 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
428 static int tgsi_fetch_rel_const(struct r600_shader_ctx
*ctx
, unsigned int offset
, unsigned int dst_reg
)
430 struct r600_bc_vtx vtx
;
435 struct r600_bc_alu alu
;
437 memset(&alu
, 0, sizeof(alu
));
439 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
440 alu
.src
[0].sel
= ctx
->ar_reg
;
442 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
443 alu
.src
[1].value
= offset
;
445 alu
.dst
.sel
= dst_reg
;
449 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
454 ar_reg
= ctx
->ar_reg
;
457 memset(&vtx
, 0, sizeof(vtx
));
458 vtx
.fetch_type
= 2; /* VTX_FETCH_NO_INDEX_OFFSET */
459 vtx
.src_gpr
= ar_reg
;
460 vtx
.mega_fetch_count
= 16;
461 vtx
.dst_gpr
= dst_reg
;
462 vtx
.dst_sel_x
= 0; /* SEL_X */
463 vtx
.dst_sel_y
= 1; /* SEL_Y */
464 vtx
.dst_sel_z
= 2; /* SEL_Z */
465 vtx
.dst_sel_w
= 3; /* SEL_W */
466 vtx
.data_format
= FMT_32_32_32_32_FLOAT
;
467 vtx
.num_format_all
= 2; /* NUM_FORMAT_SCALED */
468 vtx
.format_comp_all
= 1; /* FORMAT_COMP_SIGNED */
469 vtx
.srf_mode_all
= 1; /* SRF_MODE_NO_ZERO */
471 if ((r
= r600_bc_add_vtx(ctx
->bc
, &vtx
)))
477 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
)
479 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
480 struct r600_bc_alu alu
;
481 int i
, j
, k
, nconst
, r
;
483 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
484 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
487 tgsi_src(ctx
, &inst
->Src
[i
], &ctx
->src
[i
]);
489 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
490 if (inst
->Src
[i
].Register
.File
!= TGSI_FILE_CONSTANT
) {
494 if (ctx
->src
[i
].rel
) {
495 int treg
= r600_get_temp(ctx
);
496 if ((r
= tgsi_fetch_rel_const(ctx
, ctx
->src
[i
].sel
- 512, treg
)))
499 ctx
->src
[i
].sel
= treg
;
503 int treg
= r600_get_temp(ctx
);
504 for (k
= 0; k
< 4; k
++) {
505 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
506 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
507 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
509 alu
.src
[0].rel
= ctx
->src
[i
].rel
;
515 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
519 ctx
->src
[i
].sel
= treg
;
527 /* need to move any immediate into a temp - for trig functions which use literal for PI stuff */
528 static int tgsi_split_literal_constant(struct r600_shader_ctx
*ctx
)
530 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
531 struct r600_bc_alu alu
;
532 int i
, j
, k
, nliteral
, r
;
534 for (i
= 0, nliteral
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
535 if (ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
539 for (i
= 0, j
= nliteral
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
540 if (j
> 0 && ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
541 int treg
= r600_get_temp(ctx
);
542 for (k
= 0; k
< 4; k
++) {
543 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
544 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
545 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
547 alu
.src
[0].value
= ctx
->src
[i
].value
[k
];
553 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
557 ctx
->src
[i
].sel
= treg
;
564 static int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
)
566 struct tgsi_full_immediate
*immediate
;
567 struct tgsi_full_property
*property
;
568 struct r600_shader_ctx ctx
;
569 struct r600_bc_output output
[32];
574 ctx
.bc
= &shader
->bc
;
576 r
= r600_bc_init(ctx
.bc
, shader
->family
);
580 tgsi_scan_shader(tokens
, &ctx
.info
);
581 tgsi_parse_init(&ctx
.parse
, tokens
);
582 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
583 shader
->processor_type
= ctx
.type
;
584 ctx
.bc
->type
= shader
->processor_type
;
586 /* register allocations */
587 /* Values [0,127] correspond to GPR[0..127].
588 * Values [128,159] correspond to constant buffer bank 0
589 * Values [160,191] correspond to constant buffer bank 1
590 * Values [256,511] correspond to cfile constants c[0..255]. (Gone on EG)
591 * Values [256,287] correspond to constant buffer bank 2 (EG)
592 * Values [288,319] correspond to constant buffer bank 3 (EG)
593 * Other special values are shown in the list below.
594 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
595 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
596 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
597 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
598 * 248 SQ_ALU_SRC_0: special constant 0.0.
599 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
600 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
601 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
602 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
603 * 253 SQ_ALU_SRC_LITERAL: literal constant.
604 * 254 SQ_ALU_SRC_PV: previous vector result.
605 * 255 SQ_ALU_SRC_PS: previous scalar result.
607 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
608 ctx
.file_offset
[i
] = 0;
610 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
611 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
612 if (ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
) {
613 r600_bc_add_cfinst(ctx
.bc
, EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
615 r600_bc_add_cfinst(ctx
.bc
, V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
618 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
) {
619 ctx
.file_offset
[TGSI_FILE_INPUT
] = evergreen_gpr_count(&ctx
);
621 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
622 ctx
.info
.file_count
[TGSI_FILE_INPUT
];
623 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
624 ctx
.info
.file_count
[TGSI_FILE_OUTPUT
];
626 /* Outside the GPR range. This will be translated to one of the
627 * kcache banks later. */
628 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 512;
630 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = V_SQ_ALU_SRC_LITERAL
;
631 ctx
.ar_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
632 ctx
.info
.file_count
[TGSI_FILE_TEMPORARY
];
633 ctx
.temp_reg
= ctx
.ar_reg
+ 1;
637 shader
->fs_write_all
= FALSE
;
638 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
639 tgsi_parse_token(&ctx
.parse
);
640 switch (ctx
.parse
.FullToken
.Token
.Type
) {
641 case TGSI_TOKEN_TYPE_IMMEDIATE
:
642 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
643 ctx
.literals
= realloc(ctx
.literals
, (ctx
.nliterals
+ 1) * 16);
644 if(ctx
.literals
== NULL
) {
648 ctx
.literals
[ctx
.nliterals
* 4 + 0] = immediate
->u
[0].Uint
;
649 ctx
.literals
[ctx
.nliterals
* 4 + 1] = immediate
->u
[1].Uint
;
650 ctx
.literals
[ctx
.nliterals
* 4 + 2] = immediate
->u
[2].Uint
;
651 ctx
.literals
[ctx
.nliterals
* 4 + 3] = immediate
->u
[3].Uint
;
654 case TGSI_TOKEN_TYPE_DECLARATION
:
655 r
= tgsi_declaration(&ctx
);
659 case TGSI_TOKEN_TYPE_INSTRUCTION
:
660 r
= tgsi_is_supported(&ctx
);
663 ctx
.max_driver_temp_used
= 0;
664 /* reserve first tmp for everyone */
667 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
668 if ((r
= tgsi_split_constant(&ctx
)))
670 if ((r
= tgsi_split_literal_constant(&ctx
)))
672 if (ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
)
673 ctx
.inst_info
= &eg_shader_tgsi_instruction
[opcode
];
675 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
676 r
= ctx
.inst_info
->process(&ctx
);
680 case TGSI_TOKEN_TYPE_PROPERTY
:
681 property
= &ctx
.parse
.FullToken
.FullProperty
;
682 if (property
->Property
.PropertyName
== TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS
) {
683 if (property
->u
[0].Data
== 1)
684 shader
->fs_write_all
= TRUE
;
688 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
694 noutput
= shader
->noutput
;
695 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
696 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
697 output
[i
].gpr
= shader
->output
[i
].gpr
;
698 output
[i
].elem_size
= 3;
699 output
[i
].swizzle_x
= 0;
700 output
[i
].swizzle_y
= 1;
701 output
[i
].swizzle_z
= 2;
702 output
[i
].swizzle_w
= 3;
703 output
[i
].burst_count
= 1;
704 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
705 output
[i
].array_base
= i
- pos0
;
707 case TGSI_PROCESSOR_VERTEX
:
708 if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
709 output
[i
].array_base
= 60;
710 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
711 /* position doesn't count in array_base */
714 if (shader
->output
[i
].name
== TGSI_SEMANTIC_PSIZE
) {
715 output
[i
].array_base
= 61;
716 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
717 /* position doesn't count in array_base */
721 case TGSI_PROCESSOR_FRAGMENT
:
722 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
723 output
[i
].array_base
= shader
->output
[i
].sid
;
724 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
725 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
726 output
[i
].array_base
= 61;
727 output
[i
].swizzle_x
= 2;
728 output
[i
].swizzle_y
= 7;
729 output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
730 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
731 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
) {
732 output
[i
].array_base
= 61;
733 output
[i
].swizzle_x
= 7;
734 output
[i
].swizzle_y
= 1;
735 output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
736 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
738 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
744 R600_ERR("unsupported processor type %d\n", ctx
.type
);
749 /* add fake param output for vertex shader if no param is exported */
750 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
751 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
752 if (output
[i
].type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
) {
758 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
760 output
[i
].elem_size
= 3;
761 output
[i
].swizzle_x
= 0;
762 output
[i
].swizzle_y
= 1;
763 output
[i
].swizzle_z
= 2;
764 output
[i
].swizzle_w
= 3;
765 output
[i
].burst_count
= 1;
766 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
767 output
[i
].array_base
= 0;
771 /* add fake pixel export */
772 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& !noutput
) {
773 memset(&output
[0], 0, sizeof(struct r600_bc_output
));
775 output
[0].elem_size
= 3;
776 output
[0].swizzle_x
= 7;
777 output
[0].swizzle_y
= 7;
778 output
[0].swizzle_z
= 7;
779 output
[0].swizzle_w
= 7;
780 output
[0].burst_count
= 1;
781 output
[0].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
782 output
[0].array_base
= 0;
785 /* add output to bytecode */
786 for (i
= 0; i
< noutput
; i
++) {
787 r
= r600_bc_add_output(ctx
.bc
, &output
[i
]);
792 tgsi_parse_free(&ctx
.parse
);
796 tgsi_parse_free(&ctx
.parse
);
800 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
802 R600_ERR("%d tgsi opcode unsupported\n", ctx
->inst_info
->tgsi_opcode
);
806 static int tgsi_end(struct r600_shader_ctx
*ctx
)
811 static void r600_bc_src(struct r600_bc_alu_src
*bc_src
,
812 const struct r600_shader_src
*shader_src
,
815 bc_src
->sel
= shader_src
->sel
;
816 bc_src
->chan
= shader_src
->swizzle
[chan
];
817 bc_src
->neg
= shader_src
->neg
;
818 bc_src
->abs
= shader_src
->abs
;
819 bc_src
->rel
= shader_src
->rel
;
820 bc_src
->value
= shader_src
->value
[bc_src
->chan
];
823 static void tgsi_dst(struct r600_shader_ctx
*ctx
,
824 const struct tgsi_full_dst_register
*tgsi_dst
,
826 struct r600_bc_alu_dst
*r600_dst
)
828 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
830 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
831 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
832 r600_dst
->chan
= swizzle
;
834 if (tgsi_dst
->Register
.Indirect
)
835 r600_dst
->rel
= V_SQ_REL_RELATIVE
;
836 if (inst
->Instruction
.Saturate
) {
841 static int tgsi_last_instruction(unsigned writemask
)
845 for (i
= 0; i
< 4; i
++) {
846 if (writemask
& (1 << i
)) {
853 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
)
855 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
856 struct r600_bc_alu alu
;
858 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
860 for (i
= 0; i
< lasti
+ 1; i
++) {
861 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
864 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
865 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
867 alu
.inst
= ctx
->inst_info
->r600_opcode
;
869 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
870 r600_bc_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
873 r600_bc_src(&alu
.src
[0], &ctx
->src
[1], i
);
874 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
876 /* handle some special cases */
877 switch (ctx
->inst_info
->tgsi_opcode
) {
878 case TGSI_OPCODE_SUB
:
881 case TGSI_OPCODE_ABS
:
890 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
897 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
899 return tgsi_op2_s(ctx
, 0);
902 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
904 return tgsi_op2_s(ctx
, 1);
908 * r600 - trunc to -PI..PI range
909 * r700 - normalize by dividing by 2PI
912 static int tgsi_setup_trig(struct r600_shader_ctx
*ctx
)
914 static float half_inv_pi
= 1.0 /(3.1415926535 * 2);
915 static float double_pi
= 3.1415926535 * 2;
916 static float neg_pi
= -3.1415926535;
919 struct r600_bc_alu alu
;
921 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
922 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
926 alu
.dst
.sel
= ctx
->temp_reg
;
929 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
931 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
933 alu
.src
[1].value
= *(uint32_t *)&half_inv_pi
;
934 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
937 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
941 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
942 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
945 alu
.dst
.sel
= ctx
->temp_reg
;
948 alu
.src
[0].sel
= ctx
->temp_reg
;
951 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
955 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
956 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
960 alu
.dst
.sel
= ctx
->temp_reg
;
963 alu
.src
[0].sel
= ctx
->temp_reg
;
966 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
968 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
971 if (ctx
->bc
->chiprev
== CHIPREV_R600
) {
972 alu
.src
[1].value
= *(uint32_t *)&double_pi
;
973 alu
.src
[2].value
= *(uint32_t *)&neg_pi
;
975 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
976 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
981 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
987 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
989 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
990 struct r600_bc_alu alu
;
992 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
994 r
= tgsi_setup_trig(ctx
);
998 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
999 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1001 alu
.dst
.sel
= ctx
->temp_reg
;
1004 alu
.src
[0].sel
= ctx
->temp_reg
;
1005 alu
.src
[0].chan
= 0;
1007 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1011 /* replicate result */
1012 for (i
= 0; i
< lasti
+ 1; i
++) {
1013 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1016 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1017 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1019 alu
.src
[0].sel
= ctx
->temp_reg
;
1020 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1023 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1030 static int tgsi_scs(struct r600_shader_ctx
*ctx
)
1032 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1033 struct r600_bc_alu alu
;
1036 /* We'll only need the trig stuff if we are going to write to the
1037 * X or Y components of the destination vector.
1039 if (likely(inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_XY
)) {
1040 r
= tgsi_setup_trig(ctx
);
1046 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_X
) {
1047 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1048 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
1049 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1051 alu
.src
[0].sel
= ctx
->temp_reg
;
1052 alu
.src
[0].chan
= 0;
1054 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1060 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Y
) {
1061 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1062 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
1063 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1065 alu
.src
[0].sel
= ctx
->temp_reg
;
1066 alu
.src
[0].chan
= 0;
1068 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1074 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Z
) {
1075 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1077 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1079 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1081 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1082 alu
.src
[0].chan
= 0;
1086 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1092 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
1093 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1095 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1097 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1099 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1100 alu
.src
[0].chan
= 0;
1104 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1112 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
1114 struct r600_bc_alu alu
;
1117 for (i
= 0; i
< 4; i
++) {
1118 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1119 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1123 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1125 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
1126 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1129 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
1134 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1139 /* kill must be last in ALU */
1140 ctx
->bc
->force_add_cf
= 1;
1141 ctx
->shader
->uses_kill
= TRUE
;
1145 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
1147 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1148 struct r600_bc_alu alu
;
1152 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1153 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1154 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
1155 alu
.src
[0].chan
= 0;
1156 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1157 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
1158 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1162 /* dst.y = max(src.x, 0.0) */
1163 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1164 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1165 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1166 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1167 alu
.src
[1].chan
= 0;
1168 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1169 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
1170 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1175 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1176 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1177 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1178 alu
.src
[0].chan
= 0;
1179 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1180 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
1182 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1186 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
1191 /* dst.z = log(src.y) */
1192 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1193 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1194 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 1);
1195 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1197 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1201 chan
= alu
.dst
.chan
;
1204 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
1205 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1206 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
1207 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 3);
1208 alu
.src
[1].sel
= sel
;
1209 alu
.src
[1].chan
= chan
;
1211 r600_bc_src(&alu
.src
[2], &ctx
->src
[0], 0);
1212 alu
.dst
.sel
= ctx
->temp_reg
;
1217 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1221 /* dst.z = exp(tmp.x) */
1222 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1223 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1224 alu
.src
[0].sel
= ctx
->temp_reg
;
1225 alu
.src
[0].chan
= 0;
1226 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1228 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1235 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
1237 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1238 struct r600_bc_alu alu
;
1241 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1244 * For state trackers other than OpenGL, we'll want to use
1245 * _RECIPSQRT_IEEE instead.
1247 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
1249 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1250 r600_bc_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
1253 alu
.dst
.sel
= ctx
->temp_reg
;
1256 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1259 /* replicate result */
1260 return tgsi_helper_tempx_replicate(ctx
);
1263 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1265 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1266 struct r600_bc_alu alu
;
1269 for (i
= 0; i
< 4; i
++) {
1270 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1271 alu
.src
[0].sel
= ctx
->temp_reg
;
1272 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1274 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1275 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1278 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1285 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1287 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1288 struct r600_bc_alu alu
;
1291 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1292 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1293 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1294 r600_bc_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
1296 alu
.dst
.sel
= ctx
->temp_reg
;
1299 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1302 /* replicate result */
1303 return tgsi_helper_tempx_replicate(ctx
);
1306 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1308 struct r600_bc_alu alu
;
1312 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1313 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1314 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1315 alu
.dst
.sel
= ctx
->temp_reg
;
1318 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1322 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1323 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1324 r600_bc_src(&alu
.src
[0], &ctx
->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 /* POW(a,b) = EXP2(b * LOG2(a))*/
1333 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1334 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1335 alu
.src
[0].sel
= ctx
->temp_reg
;
1336 alu
.dst
.sel
= ctx
->temp_reg
;
1339 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1342 return tgsi_helper_tempx_replicate(ctx
);
1345 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1347 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1348 struct r600_bc_alu alu
;
1351 /* tmp = (src > 0 ? 1 : src) */
1352 for (i
= 0; i
< 4; i
++) {
1353 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1354 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1357 alu
.dst
.sel
= ctx
->temp_reg
;
1360 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
1361 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1362 r600_bc_src(&alu
.src
[2], &ctx
->src
[0], i
);
1366 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1371 /* dst = (-tmp > 0 ? -1 : tmp) */
1372 for (i
= 0; i
< 4; i
++) {
1373 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1374 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1376 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1378 alu
.src
[0].sel
= ctx
->temp_reg
;
1379 alu
.src
[0].chan
= i
;
1382 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1385 alu
.src
[2].sel
= ctx
->temp_reg
;
1386 alu
.src
[2].chan
= i
;
1390 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1397 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1399 struct r600_bc_alu alu
;
1402 for (i
= 0; i
< 4; i
++) {
1403 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1404 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1405 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
1408 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1409 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1410 alu
.src
[0].sel
= ctx
->temp_reg
;
1411 alu
.src
[0].chan
= i
;
1416 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1423 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1425 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1426 struct r600_bc_alu alu
;
1428 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1430 for (i
= 0; i
< lasti
+ 1; i
++) {
1431 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1434 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1435 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1436 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1437 r600_bc_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
1440 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1447 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1454 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1456 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1457 struct r600_bc_alu alu
;
1460 for (i
= 0; i
< 4; i
++) {
1461 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1462 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1463 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1464 r600_bc_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
1467 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1469 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1470 /* handle some special cases */
1471 switch (ctx
->inst_info
->tgsi_opcode
) {
1472 case TGSI_OPCODE_DP2
:
1474 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1475 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1478 case TGSI_OPCODE_DP3
:
1480 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1481 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1484 case TGSI_OPCODE_DPH
:
1486 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1487 alu
.src
[0].chan
= 0;
1497 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1504 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1506 static float one_point_five
= 1.5f
;
1507 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1508 struct r600_bc_tex tex
;
1509 struct r600_bc_alu alu
;
1513 boolean src_not_temp
=
1514 inst
->Src
[0].Register
.File
!= TGSI_FILE_TEMPORARY
&&
1515 inst
->Src
[0].Register
.File
!= TGSI_FILE_INPUT
;
1517 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
1519 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1520 /* Add perspective divide */
1521 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1522 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1523 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 3);
1525 alu
.dst
.sel
= ctx
->temp_reg
;
1529 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1533 for (i
= 0; i
< 3; i
++) {
1534 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1535 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1536 alu
.src
[0].sel
= ctx
->temp_reg
;
1537 alu
.src
[0].chan
= 3;
1538 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
1539 alu
.dst
.sel
= ctx
->temp_reg
;
1542 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1546 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1547 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1548 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1549 alu
.src
[0].chan
= 0;
1550 alu
.dst
.sel
= ctx
->temp_reg
;
1554 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1557 src_not_temp
= FALSE
;
1558 src_gpr
= ctx
->temp_reg
;
1561 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1562 static const unsigned src0_swizzle
[] = {2, 2, 0, 1};
1563 static const unsigned src1_swizzle
[] = {1, 0, 2, 2};
1565 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
1566 for (i
= 0; i
< 4; i
++) {
1567 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1568 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
1569 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], src0_swizzle
[i
]);
1570 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], src1_swizzle
[i
]);
1571 alu
.dst
.sel
= ctx
->temp_reg
;
1576 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1581 /* tmp1.z = RCP_e(|tmp1.z|) */
1582 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1583 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1584 alu
.src
[0].sel
= ctx
->temp_reg
;
1585 alu
.src
[0].chan
= 2;
1587 alu
.dst
.sel
= ctx
->temp_reg
;
1591 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1595 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
1596 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
1597 * muladd has no writemask, have to use another temp
1599 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1600 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1603 alu
.src
[0].sel
= ctx
->temp_reg
;
1604 alu
.src
[0].chan
= 0;
1605 alu
.src
[1].sel
= ctx
->temp_reg
;
1606 alu
.src
[1].chan
= 2;
1608 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1609 alu
.src
[2].chan
= 0;
1610 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
1612 alu
.dst
.sel
= ctx
->temp_reg
;
1616 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1620 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1621 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1624 alu
.src
[0].sel
= ctx
->temp_reg
;
1625 alu
.src
[0].chan
= 1;
1626 alu
.src
[1].sel
= ctx
->temp_reg
;
1627 alu
.src
[1].chan
= 2;
1629 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1630 alu
.src
[2].chan
= 0;
1631 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
1633 alu
.dst
.sel
= ctx
->temp_reg
;
1638 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1642 src_not_temp
= FALSE
;
1643 src_gpr
= ctx
->temp_reg
;
1647 for (i
= 0; i
< 4; i
++) {
1648 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1649 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1650 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
1651 alu
.dst
.sel
= ctx
->temp_reg
;
1656 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1660 src_gpr
= ctx
->temp_reg
;
1663 opcode
= ctx
->inst_info
->r600_opcode
;
1664 if (opcode
== SQ_TEX_INST_SAMPLE
&&
1665 (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
))
1666 opcode
= SQ_TEX_INST_SAMPLE_C
;
1668 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
1670 tex
.sampler_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
1671 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
1672 tex
.src_gpr
= src_gpr
;
1673 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
1674 tex
.dst_sel_x
= (inst
->Dst
[0].Register
.WriteMask
& 1) ? 0 : 7;
1675 tex
.dst_sel_y
= (inst
->Dst
[0].Register
.WriteMask
& 2) ? 1 : 7;
1676 tex
.dst_sel_z
= (inst
->Dst
[0].Register
.WriteMask
& 4) ? 2 : 7;
1677 tex
.dst_sel_w
= (inst
->Dst
[0].Register
.WriteMask
& 8) ? 3 : 7;
1683 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1690 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
1691 tex
.coord_type_x
= 1;
1692 tex
.coord_type_y
= 1;
1693 tex
.coord_type_z
= 1;
1694 tex
.coord_type_w
= 1;
1697 if (inst
->Texture
.Texture
== TGSI_TEXTURE_1D_ARRAY
) {
1698 tex
.coord_type_z
= 0;
1700 } else if (inst
->Texture
.Texture
== TGSI_TEXTURE_2D_ARRAY
)
1701 tex
.coord_type_z
= 0;
1703 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
)
1706 r
= r600_bc_add_tex(ctx
->bc
, &tex
);
1710 /* add shadow ambient support - gallium doesn't do it yet */
1714 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
1716 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1717 struct r600_bc_alu alu
;
1718 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1722 /* optimize if it's just an equal balance */
1723 if (ctx
->src
[0].sel
== V_SQ_ALU_SRC_0_5
) {
1724 for (i
= 0; i
< lasti
+ 1; i
++) {
1725 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1728 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1729 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
1730 r600_bc_src(&alu
.src
[0], &ctx
->src
[1], i
);
1731 r600_bc_src(&alu
.src
[1], &ctx
->src
[2], i
);
1733 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1738 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1746 for (i
= 0; i
< lasti
+ 1; i
++) {
1747 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1750 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1751 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
1752 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1753 alu
.src
[0].chan
= 0;
1754 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
1756 alu
.dst
.sel
= ctx
->temp_reg
;
1762 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1767 /* (1 - src0) * src2 */
1768 for (i
= 0; i
< lasti
+ 1; i
++) {
1769 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1772 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1773 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1774 alu
.src
[0].sel
= ctx
->temp_reg
;
1775 alu
.src
[0].chan
= i
;
1776 r600_bc_src(&alu
.src
[1], &ctx
->src
[2], i
);
1777 alu
.dst
.sel
= ctx
->temp_reg
;
1783 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1788 /* src0 * src1 + (1 - src0) * src2 */
1789 for (i
= 0; i
< lasti
+ 1; i
++) {
1790 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1793 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1794 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1796 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
1797 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], i
);
1798 alu
.src
[2].sel
= ctx
->temp_reg
;
1799 alu
.src
[2].chan
= i
;
1801 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1806 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1813 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
1815 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1816 struct r600_bc_alu alu
;
1818 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1820 for (i
= 0; i
< lasti
+ 1; i
++) {
1821 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1824 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1825 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
1826 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
1827 r600_bc_src(&alu
.src
[1], &ctx
->src
[2], i
);
1828 r600_bc_src(&alu
.src
[2], &ctx
->src
[1], i
);
1829 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1835 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1842 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
1844 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1845 static const unsigned int src0_swizzle
[] = {2, 0, 1};
1846 static const unsigned int src1_swizzle
[] = {1, 2, 0};
1847 struct r600_bc_alu alu
;
1848 uint32_t use_temp
= 0;
1851 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1854 for (i
= 0; i
< 4; i
++) {
1855 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1856 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1858 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], src0_swizzle
[i
]);
1859 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], src1_swizzle
[i
]);
1861 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1862 alu
.src
[0].chan
= i
;
1863 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1864 alu
.src
[1].chan
= i
;
1867 alu
.dst
.sel
= ctx
->temp_reg
;
1873 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1878 for (i
= 0; i
< 4; i
++) {
1879 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1880 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1883 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], src1_swizzle
[i
]);
1884 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], src0_swizzle
[i
]);
1886 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1887 alu
.src
[0].chan
= i
;
1888 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1889 alu
.src
[1].chan
= i
;
1892 alu
.src
[2].sel
= ctx
->temp_reg
;
1894 alu
.src
[2].chan
= i
;
1897 alu
.dst
.sel
= ctx
->temp_reg
;
1899 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1905 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1910 return tgsi_helper_copy(ctx
, inst
);
1914 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
1916 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1917 struct r600_bc_alu alu
;
1920 /* result.x = 2^floor(src); */
1921 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
1922 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1924 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
1925 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1927 alu
.dst
.sel
= ctx
->temp_reg
;
1931 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1935 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1936 alu
.src
[0].sel
= ctx
->temp_reg
;
1937 alu
.src
[0].chan
= 0;
1939 alu
.dst
.sel
= ctx
->temp_reg
;
1943 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1948 /* result.y = tmp - floor(tmp); */
1949 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
1950 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1952 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
1953 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1955 alu
.dst
.sel
= ctx
->temp_reg
;
1956 // r = tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
1964 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1969 /* result.z = RoughApprox2ToX(tmp);*/
1970 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
1971 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1972 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1973 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1975 alu
.dst
.sel
= ctx
->temp_reg
;
1981 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1986 /* result.w = 1.0;*/
1987 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
1988 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1990 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1991 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1992 alu
.src
[0].chan
= 0;
1994 alu
.dst
.sel
= ctx
->temp_reg
;
1998 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2002 return tgsi_helper_copy(ctx
, inst
);
2005 static int tgsi_log(struct r600_shader_ctx
*ctx
)
2007 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2008 struct r600_bc_alu alu
;
2011 /* result.x = floor(log2(src)); */
2012 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2013 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2015 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2016 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2018 alu
.dst
.sel
= ctx
->temp_reg
;
2022 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2026 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2027 alu
.src
[0].sel
= ctx
->temp_reg
;
2028 alu
.src
[0].chan
= 0;
2030 alu
.dst
.sel
= ctx
->temp_reg
;
2035 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2040 /* result.y = src.x / (2 ^ floor(log2(src.x))); */
2041 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2042 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2044 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2045 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2047 alu
.dst
.sel
= ctx
->temp_reg
;
2052 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2056 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2058 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2059 alu
.src
[0].sel
= ctx
->temp_reg
;
2060 alu
.src
[0].chan
= 1;
2062 alu
.dst
.sel
= ctx
->temp_reg
;
2067 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2071 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2073 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2074 alu
.src
[0].sel
= ctx
->temp_reg
;
2075 alu
.src
[0].chan
= 1;
2077 alu
.dst
.sel
= ctx
->temp_reg
;
2082 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2086 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2088 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2089 alu
.src
[0].sel
= ctx
->temp_reg
;
2090 alu
.src
[0].chan
= 1;
2092 alu
.dst
.sel
= ctx
->temp_reg
;
2097 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2101 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2103 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2105 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2107 alu
.src
[1].sel
= ctx
->temp_reg
;
2108 alu
.src
[1].chan
= 1;
2110 alu
.dst
.sel
= ctx
->temp_reg
;
2115 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2120 /* result.z = log2(src);*/
2121 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
2122 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2124 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2125 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2127 alu
.dst
.sel
= ctx
->temp_reg
;
2132 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2137 /* result.w = 1.0; */
2138 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
2139 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2141 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2142 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2143 alu
.src
[0].chan
= 0;
2145 alu
.dst
.sel
= ctx
->temp_reg
;
2150 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2155 return tgsi_helper_copy(ctx
, inst
);
2158 static int tgsi_eg_arl(struct r600_shader_ctx
*ctx
)
2160 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2161 struct r600_bc_alu alu
;
2164 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2166 switch (inst
->Instruction
.Opcode
) {
2167 case TGSI_OPCODE_ARL
:
2168 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR
;
2170 case TGSI_OPCODE_ARR
:
2171 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
2178 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2180 alu
.dst
.sel
= ctx
->ar_reg
;
2182 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2186 /* TODO: Note that the MOVA can be avoided if we never use AR for
2187 * indexing non-CB registers in the current ALU clause. Similarly, we
2188 * need to load AR from ar_reg again if we started a new clause
2189 * between ARL and AR usage. The easy way to do that is to remove
2190 * the MOVA here, and load it for the first AR access after ar_reg
2191 * has been modified in each clause. */
2192 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2193 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
;
2194 alu
.src
[0].sel
= ctx
->ar_reg
;
2195 alu
.src
[0].chan
= 0;
2197 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2202 static int tgsi_r600_arl(struct r600_shader_ctx
*ctx
)
2204 /* TODO from r600c, ar values don't persist between clauses */
2205 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2206 struct r600_bc_alu alu
;
2209 switch (inst
->Instruction
.Opcode
) {
2210 case TGSI_OPCODE_ARL
:
2211 memset(&alu
, 0, sizeof(alu
));
2212 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
;
2213 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2214 alu
.dst
.sel
= ctx
->ar_reg
;
2218 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
2221 memset(&alu
, 0, sizeof(alu
));
2222 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
2223 alu
.src
[0].sel
= ctx
->ar_reg
;
2224 alu
.dst
.sel
= ctx
->ar_reg
;
2228 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
2231 case TGSI_OPCODE_ARR
:
2232 memset(&alu
, 0, sizeof(alu
));
2233 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
2234 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2235 alu
.dst
.sel
= ctx
->ar_reg
;
2239 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
2247 memset(&alu
, 0, sizeof(alu
));
2248 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
;
2249 alu
.src
[0].sel
= ctx
->ar_reg
;
2252 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2255 ctx
->bc
->cf_last
->r6xx_uses_waterfall
= 1;
2259 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
2261 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2262 struct r600_bc_alu alu
;
2265 for (i
= 0; i
< 4; i
++) {
2266 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2268 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2269 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2271 if (i
== 0 || i
== 3) {
2272 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2274 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
2277 if (i
== 0 || i
== 2) {
2278 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2280 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], i
);
2284 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2291 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
2293 struct r600_bc_alu alu
;
2296 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2300 alu
.dst
.sel
= ctx
->temp_reg
;
2304 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2305 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2306 alu
.src
[1].chan
= 0;
2310 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
2316 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
2319 if (ctx
->bc
->cf_last
) {
2320 if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
) << 3)
2322 else if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
) << 3)
2327 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
) << 3;
2328 ctx
->bc
->force_add_cf
= 1;
2329 } else if (alu_pop
== 2) {
2330 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
) << 3;
2331 ctx
->bc
->force_add_cf
= 1;
2333 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
2334 ctx
->bc
->cf_last
->pop_count
= pops
;
2335 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2340 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
2344 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2348 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
2351 /* TOODO : for 16 vp asic should -= 2; */
2352 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2357 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
2359 if (check_max_only
) {
2372 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
2373 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2374 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2375 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
2381 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2385 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
2388 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2392 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
2393 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2394 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2395 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
2399 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
2401 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
2403 sp
->mid
= (struct r600_bc_cf
**)realloc((void *)sp
->mid
,
2404 sizeof(struct r600_bc_cf
*) * (sp
->num_mid
+ 1));
2405 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
2409 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
2412 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
2413 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
2416 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
2418 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
2430 static int emit_return(struct r600_shader_ctx
*ctx
)
2432 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
2436 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
2439 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_JUMP
);
2440 ctx
->bc
->cf_last
->pop_count
= pops
;
2441 /* TODO work out offset */
2445 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
2450 static void emit_testflag(struct r600_shader_ctx
*ctx
)
2455 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
2458 emit_jump_to_offset(ctx
, 1, 4);
2459 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
2460 pops(ctx
, ifidx
+ 1);
2464 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
2468 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2469 ctx
->bc
->cf_last
->pop_count
= 1;
2471 fc_set_mid(ctx
, fc_sp
);
2477 static int tgsi_if(struct r600_shader_ctx
*ctx
)
2479 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
2481 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
2483 fc_pushlevel(ctx
, FC_IF
);
2485 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
2489 static int tgsi_else(struct r600_shader_ctx
*ctx
)
2491 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
2492 ctx
->bc
->cf_last
->pop_count
= 1;
2494 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
2495 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
2499 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
2502 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
2503 R600_ERR("if/endif unbalanced in shader\n");
2507 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
2508 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2509 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
2511 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2515 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
2519 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
2521 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
2523 fc_pushlevel(ctx
, FC_LOOP
);
2525 /* check stack depth */
2526 callstack_check_depth(ctx
, FC_LOOP
, 0);
2530 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
2534 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
2536 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
2537 R600_ERR("loop/endloop in shader code are not paired.\n");
2541 /* fixup loop pointers - from r600isa
2542 LOOP END points to CF after LOOP START,
2543 LOOP START point to CF after LOOP END
2544 BRK/CONT point to LOOP END CF
2546 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
2548 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2550 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
2551 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
2553 /* TODO add LOOPRET support */
2555 callstack_decrease_current(ctx
, FC_LOOP
);
2559 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
2563 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
2565 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
2570 R600_ERR("Break not inside loop/endloop pair\n");
2574 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2575 ctx
->bc
->cf_last
->pop_count
= 1;
2577 fc_set_mid(ctx
, fscp
);
2580 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
2584 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
2585 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
2586 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2587 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2590 * For state trackers other than OpenGL, we'll want to use
2591 * _RECIP_IEEE instead.
2593 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
2595 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
2596 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2597 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
2598 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2599 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2600 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2601 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2602 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2603 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2604 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2605 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2606 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2607 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2608 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2609 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2610 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2612 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2613 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2615 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2616 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2617 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2618 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2619 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2620 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2621 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2622 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2623 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2624 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2626 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2627 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2628 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2629 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2630 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2631 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2632 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2633 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
2634 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2635 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2636 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2637 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2638 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2639 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
2640 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2641 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
2642 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
2643 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
2644 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
2645 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2646 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2647 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2648 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2649 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2650 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2651 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2652 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2653 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2654 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2655 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
2656 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2657 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2658 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2659 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
2660 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
2661 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
2662 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2663 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2664 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2665 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2666 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2667 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
2668 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
2670 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2671 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2672 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
2673 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
2675 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2676 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2677 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2678 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2679 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2680 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2681 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2682 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
2683 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2685 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2686 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2687 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2688 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2689 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2690 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2691 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2692 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2693 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
2694 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2695 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2696 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
2697 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2698 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
2699 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2701 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2702 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2703 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2704 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2705 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2707 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2708 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2709 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2710 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2711 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2712 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2713 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2714 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2715 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
2716 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
2718 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2719 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2720 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2721 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2722 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2723 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2724 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2725 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2726 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2727 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2728 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2729 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2730 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2731 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2732 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2733 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2734 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2735 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2736 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2737 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2738 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2739 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2740 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2741 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2742 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2743 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2744 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2745 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2748 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
2749 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
2750 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2751 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2752 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
2753 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
2754 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2755 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
2756 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2757 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2758 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2759 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2760 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2761 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2762 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2763 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2764 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2765 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2766 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2767 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2768 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2770 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2771 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2773 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2774 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2775 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2776 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2777 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2778 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2779 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2780 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2781 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2782 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2784 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2785 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2786 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2787 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2788 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2789 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2790 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2791 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
2792 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2793 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2794 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2795 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2796 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2797 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
2798 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2799 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
2800 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
2801 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
2802 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
2803 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2804 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2805 {TGSI_OPCODE_TXD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2806 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2807 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2808 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2809 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2810 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2811 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2812 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2813 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
2814 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2815 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2816 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2817 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
2818 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
2819 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
2820 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2821 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2822 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2823 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2824 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2825 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
2826 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
2828 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2829 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2830 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
2831 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
2833 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2834 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2835 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2836 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2837 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2838 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2839 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2840 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
2841 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2843 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2844 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2845 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2846 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2847 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2848 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2849 {TGSI_OPCODE_TXF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2850 {TGSI_OPCODE_TXQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2851 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
2852 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2853 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2854 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
2855 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2856 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
2857 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2859 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2860 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2861 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2862 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2863 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2865 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2866 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2867 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2868 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2869 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2870 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2871 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2872 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2873 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
2874 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
2876 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2877 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2878 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2879 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2880 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2881 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2882 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2883 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2884 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2885 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2886 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2887 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2888 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2889 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2890 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2891 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2892 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2893 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2894 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2895 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2896 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2897 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2898 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2899 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2900 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2901 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2902 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2903 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},