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 fprintf(stderr
, "writing z\n");
973 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
975 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
977 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
981 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
986 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
990 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
996 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
997 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
999 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1001 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1005 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1006 alu
.src
[0].chan
= 0;
1010 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1014 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1022 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
1024 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1025 struct r600_bc_alu alu
;
1028 for (i
= 0; i
< 4; i
++) {
1029 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1030 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1034 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1036 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
1037 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1040 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1043 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1048 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1052 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1056 /* kill must be last in ALU */
1057 ctx
->bc
->force_add_cf
= 1;
1058 ctx
->shader
->uses_kill
= TRUE
;
1062 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
1064 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1065 struct r600_bc_alu alu
;
1066 struct r600_bc_alu_src r600_src
[3];
1069 r
= tgsi_split_constant(ctx
, r600_src
);
1072 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1077 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1078 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1079 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
1080 alu
.src
[0].chan
= 0;
1081 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1084 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
1085 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1089 /* dst.y = max(src.x, 0.0) */
1090 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1091 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1092 alu
.src
[0] = r600_src
[0];
1093 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1094 alu
.src
[1].chan
= 0;
1095 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1098 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
1099 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1104 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1105 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1106 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1107 alu
.src
[0].chan
= 0;
1108 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1111 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
1113 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1117 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1121 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
1126 /* dst.z = log(src.y) */
1127 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1128 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1129 alu
.src
[0] = r600_src
[0];
1130 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1131 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1135 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1139 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1143 chan
= alu
.dst
.chan
;
1146 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
1147 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1148 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
1149 alu
.src
[0] = r600_src
[0];
1150 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1151 alu
.src
[1].sel
= sel
;
1152 alu
.src
[1].chan
= chan
;
1154 alu
.src
[2] = r600_src
[0];
1155 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], 0);
1156 alu
.dst
.sel
= ctx
->temp_reg
;
1161 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1165 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1168 /* dst.z = exp(tmp.x) */
1169 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1170 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1171 alu
.src
[0].sel
= ctx
->temp_reg
;
1172 alu
.src
[0].chan
= 0;
1173 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1177 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1184 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
1186 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1187 struct r600_bc_alu alu
;
1190 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1193 * For state trackers other than OpenGL, we'll want to use
1194 * _RECIPSQRT_IEEE instead.
1196 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
1198 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1199 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1202 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1205 alu
.dst
.sel
= ctx
->temp_reg
;
1208 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1211 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1214 /* replicate result */
1215 return tgsi_helper_tempx_replicate(ctx
);
1218 static int tgsi_trans(struct r600_shader_ctx
*ctx
)
1220 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1221 struct r600_bc_alu alu
;
1224 for (i
= 0; i
< 4; i
++) {
1225 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1226 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
1227 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1228 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1229 r
= tgsi_src(ctx
, &inst
->Src
[j
], &alu
.src
[j
]);
1232 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1234 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1238 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1246 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1248 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1249 struct r600_bc_alu alu
;
1252 for (i
= 0; i
< 4; i
++) {
1253 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1254 alu
.src
[0].sel
= ctx
->temp_reg
;
1255 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1257 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1260 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1263 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1270 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1272 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1273 struct r600_bc_alu alu
;
1276 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1277 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1278 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1279 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1282 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1284 alu
.dst
.sel
= ctx
->temp_reg
;
1287 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1290 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1293 /* replicate result */
1294 return tgsi_helper_tempx_replicate(ctx
);
1297 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1299 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1300 struct r600_bc_alu alu
;
1304 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1305 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1306 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1309 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1310 alu
.dst
.sel
= ctx
->temp_reg
;
1313 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1316 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1320 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1321 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL_IEEE
);
1322 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[0]);
1325 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], 0);
1326 alu
.src
[1].sel
= ctx
->temp_reg
;
1327 alu
.dst
.sel
= ctx
->temp_reg
;
1330 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1333 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1336 /* POW(a,b) = EXP2(b * LOG2(a))*/
1337 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1338 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1339 alu
.src
[0].sel
= ctx
->temp_reg
;
1340 alu
.dst
.sel
= ctx
->temp_reg
;
1343 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1346 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1349 return tgsi_helper_tempx_replicate(ctx
);
1352 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1354 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1355 struct r600_bc_alu alu
;
1356 struct r600_bc_alu_src r600_src
[3];
1359 r
= tgsi_split_constant(ctx
, r600_src
);
1363 /* tmp = (src > 0 ? 1 : src) */
1364 for (i
= 0; i
< 4; i
++) {
1365 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1366 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1369 alu
.dst
.sel
= ctx
->temp_reg
;
1372 alu
.src
[0] = r600_src
[0];
1373 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1375 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1377 alu
.src
[2] = r600_src
[0];
1378 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], i
);
1381 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1385 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1389 /* dst = (-tmp > 0 ? -1 : tmp) */
1390 for (i
= 0; i
< 4; i
++) {
1391 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1392 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1394 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1398 alu
.src
[0].sel
= ctx
->temp_reg
;
1399 alu
.src
[0].chan
= i
;
1402 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1405 alu
.src
[2].sel
= ctx
->temp_reg
;
1406 alu
.src
[2].chan
= i
;
1410 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1417 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1419 struct r600_bc_alu alu
;
1422 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1425 for (i
= 0; i
< 4; i
++) {
1426 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1427 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1428 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
1431 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1432 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1435 alu
.src
[0].sel
= ctx
->temp_reg
;
1436 alu
.src
[0].chan
= i
;
1441 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1448 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1450 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1451 struct r600_bc_alu_src r600_src
[3];
1452 struct r600_bc_alu alu
;
1455 r
= tgsi_split_constant(ctx
, r600_src
);
1458 /* do it in 2 step as op3 doesn't support writemask */
1459 for (i
= 0; i
< 4; i
++) {
1460 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1461 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1462 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1463 alu
.src
[j
] = r600_src
[j
];
1464 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1466 alu
.dst
.sel
= ctx
->temp_reg
;
1473 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1477 return tgsi_helper_copy(ctx
, inst
);
1480 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1482 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1483 struct r600_bc_alu_src r600_src
[3];
1484 struct r600_bc_alu alu
;
1487 r
= tgsi_split_constant(ctx
, r600_src
);
1490 for (i
= 0; i
< 4; i
++) {
1491 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1492 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1493 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1494 alu
.src
[j
] = r600_src
[j
];
1495 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1497 alu
.dst
.sel
= ctx
->temp_reg
;
1500 /* handle some special cases */
1501 switch (ctx
->inst_info
->tgsi_opcode
) {
1502 case TGSI_OPCODE_DP2
:
1504 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1505 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1508 case TGSI_OPCODE_DP3
:
1510 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1511 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1514 case TGSI_OPCODE_DPH
:
1516 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1517 alu
.src
[0].chan
= 0;
1527 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1531 return tgsi_helper_copy(ctx
, inst
);
1534 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1536 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1537 struct r600_bc_tex tex
;
1538 struct r600_bc_alu alu
;
1542 boolean src_not_temp
= inst
->Src
[0].Register
.File
!= TGSI_FILE_TEMPORARY
;
1543 uint32_t lit_vals
[4];
1545 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
1547 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1548 /* Add perspective divide */
1549 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1550 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1551 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1555 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1556 alu
.dst
.sel
= ctx
->temp_reg
;
1560 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1564 for (i
= 0; i
< 3; i
++) {
1565 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1566 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1567 alu
.src
[0].sel
= ctx
->temp_reg
;
1568 alu
.src
[0].chan
= 3;
1569 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1572 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1573 alu
.dst
.sel
= ctx
->temp_reg
;
1576 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1580 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1581 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1582 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1583 alu
.src
[0].chan
= 0;
1584 alu
.dst
.sel
= ctx
->temp_reg
;
1588 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1591 src_not_temp
= FALSE
;
1592 src_gpr
= ctx
->temp_reg
;
1595 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1596 int src_chan
, src2_chan
;
1598 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
1599 for (i
= 0; i
< 4; i
++) {
1600 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1601 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
1620 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1623 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], src_chan
);
1624 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1627 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], src2_chan
);
1628 alu
.dst
.sel
= ctx
->temp_reg
;
1633 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1638 /* tmp1.z = RCP_e(|tmp1.z|) */
1639 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1640 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1641 alu
.src
[0].sel
= ctx
->temp_reg
;
1642 alu
.src
[0].chan
= 2;
1644 alu
.dst
.sel
= ctx
->temp_reg
;
1648 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1652 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
1653 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
1654 * muladd has no writemask, have to use another temp
1656 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1657 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1660 alu
.src
[0].sel
= ctx
->temp_reg
;
1661 alu
.src
[0].chan
= 0;
1662 alu
.src
[1].sel
= ctx
->temp_reg
;
1663 alu
.src
[1].chan
= 2;
1665 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1666 alu
.src
[2].chan
= 0;
1668 alu
.dst
.sel
= ctx
->temp_reg
;
1672 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1676 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1677 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1680 alu
.src
[0].sel
= ctx
->temp_reg
;
1681 alu
.src
[0].chan
= 1;
1682 alu
.src
[1].sel
= ctx
->temp_reg
;
1683 alu
.src
[1].chan
= 2;
1685 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1686 alu
.src
[2].chan
= 0;
1688 alu
.dst
.sel
= ctx
->temp_reg
;
1693 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1697 lit_vals
[0] = fui(1.5f
);
1699 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
1702 src_not_temp
= FALSE
;
1703 src_gpr
= ctx
->temp_reg
;
1707 for (i
= 0; i
< 4; i
++) {
1708 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1709 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1710 alu
.src
[0].sel
= src_gpr
;
1711 alu
.src
[0].chan
= i
;
1712 alu
.dst
.sel
= ctx
->temp_reg
;
1717 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1721 src_gpr
= ctx
->temp_reg
;
1724 opcode
= ctx
->inst_info
->r600_opcode
;
1725 if (opcode
== SQ_TEX_INST_SAMPLE
&&
1726 (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
))
1727 opcode
= SQ_TEX_INST_SAMPLE_C
;
1729 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
1731 tex
.resource_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
1732 tex
.sampler_id
= tex
.resource_id
;
1733 tex
.src_gpr
= src_gpr
;
1734 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
1744 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1751 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
1752 tex
.coord_type_x
= 1;
1753 tex
.coord_type_y
= 1;
1754 tex
.coord_type_z
= 1;
1755 tex
.coord_type_w
= 1;
1758 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
)
1761 r
= r600_bc_add_tex(ctx
->bc
, &tex
);
1765 /* add shadow ambient support - gallium doesn't do it yet */
1770 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
1772 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1773 struct r600_bc_alu_src r600_src
[3];
1774 struct r600_bc_alu alu
;
1778 r
= tgsi_split_constant(ctx
, r600_src
);
1782 for (i
= 0; i
< 4; i
++) {
1783 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1784 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
1785 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1786 alu
.src
[0].chan
= 0;
1787 alu
.src
[1] = r600_src
[0];
1788 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1790 alu
.dst
.sel
= ctx
->temp_reg
;
1796 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1800 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1804 /* (1 - src0) * src2 */
1805 for (i
= 0; i
< 4; i
++) {
1806 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1807 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1808 alu
.src
[0].sel
= ctx
->temp_reg
;
1809 alu
.src
[0].chan
= i
;
1810 alu
.src
[1] = r600_src
[2];
1811 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1812 alu
.dst
.sel
= ctx
->temp_reg
;
1818 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1822 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1826 /* src0 * src1 + (1 - src0) * src2 */
1827 for (i
= 0; i
< 4; i
++) {
1828 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1829 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1831 alu
.src
[0] = r600_src
[0];
1832 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1833 alu
.src
[1] = r600_src
[1];
1834 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
1835 alu
.src
[2].sel
= ctx
->temp_reg
;
1836 alu
.src
[2].chan
= i
;
1837 alu
.dst
.sel
= ctx
->temp_reg
;
1842 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1846 return tgsi_helper_copy(ctx
, inst
);
1849 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
1851 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1852 struct r600_bc_alu_src r600_src
[3];
1853 struct r600_bc_alu alu
;
1857 r
= tgsi_split_constant(ctx
, r600_src
);
1861 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1864 for (i
= 0; i
< 4; i
++) {
1865 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1866 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
1867 alu
.src
[0] = r600_src
[0];
1868 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1870 alu
.src
[1] = r600_src
[2];
1871 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1873 alu
.src
[2] = r600_src
[1];
1874 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[1], i
);
1877 alu
.dst
.sel
= ctx
->temp_reg
;
1879 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1888 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1893 return tgsi_helper_copy(ctx
, inst
);
1897 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
1899 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1900 struct r600_bc_alu_src r600_src
[3];
1901 struct r600_bc_alu alu
;
1902 uint32_t use_temp
= 0;
1905 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1908 r
= tgsi_split_constant(ctx
, r600_src
);
1912 for (i
= 0; i
< 4; i
++) {
1913 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1914 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1916 alu
.src
[0] = r600_src
[0];
1919 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1922 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1925 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1928 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1929 alu
.src
[0].chan
= i
;
1932 alu
.src
[1] = r600_src
[1];
1935 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1938 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1941 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1944 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1945 alu
.src
[1].chan
= i
;
1948 alu
.dst
.sel
= ctx
->temp_reg
;
1954 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1958 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1963 for (i
= 0; i
< 4; i
++) {
1964 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1965 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1967 alu
.src
[0] = r600_src
[0];
1970 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1973 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1976 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1979 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1980 alu
.src
[0].chan
= i
;
1983 alu
.src
[1] = r600_src
[1];
1986 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1989 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1992 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1995 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1996 alu
.src
[1].chan
= i
;
1999 alu
.src
[2].sel
= ctx
->temp_reg
;
2001 alu
.src
[2].chan
= i
;
2004 alu
.dst
.sel
= ctx
->temp_reg
;
2006 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2015 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2019 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2024 return tgsi_helper_copy(ctx
, inst
);
2028 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
2030 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2031 struct r600_bc_alu_src r600_src
[3];
2032 struct r600_bc_alu alu
;
2035 /* result.x = 2^floor(src); */
2036 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2037 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2039 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2040 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2044 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2046 alu
.dst
.sel
= ctx
->temp_reg
;
2050 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2054 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2058 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2059 alu
.src
[0].sel
= ctx
->temp_reg
;
2060 alu
.src
[0].chan
= 0;
2062 alu
.dst
.sel
= ctx
->temp_reg
;
2066 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2070 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2075 /* result.y = tmp - floor(tmp); */
2076 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2077 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2079 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
2080 alu
.src
[0] = r600_src
[0];
2081 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2084 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2086 alu
.dst
.sel
= ctx
->temp_reg
;
2087 // r = tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
2095 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2098 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2103 /* result.z = RoughApprox2ToX(tmp);*/
2104 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
2105 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2106 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2107 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2110 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2112 alu
.dst
.sel
= ctx
->temp_reg
;
2118 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2121 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2126 /* result.w = 1.0;*/
2127 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
2128 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2130 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2131 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2132 alu
.src
[0].chan
= 0;
2134 alu
.dst
.sel
= ctx
->temp_reg
;
2138 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2141 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2145 return tgsi_helper_copy(ctx
, inst
);
2148 static int tgsi_log(struct r600_shader_ctx
*ctx
)
2150 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2151 struct r600_bc_alu alu
;
2154 /* result.x = floor(log2(src)); */
2155 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2156 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2158 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2159 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2163 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2165 alu
.dst
.sel
= ctx
->temp_reg
;
2169 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2173 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2177 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2178 alu
.src
[0].sel
= ctx
->temp_reg
;
2179 alu
.src
[0].chan
= 0;
2181 alu
.dst
.sel
= ctx
->temp_reg
;
2186 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2190 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2195 /* result.y = src.x / (2 ^ floor(log2(src.x))); */
2196 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2197 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2199 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2200 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2204 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2206 alu
.dst
.sel
= ctx
->temp_reg
;
2211 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2215 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2219 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2221 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2222 alu
.src
[0].sel
= ctx
->temp_reg
;
2223 alu
.src
[0].chan
= 1;
2225 alu
.dst
.sel
= ctx
->temp_reg
;
2230 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2234 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2238 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2240 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2241 alu
.src
[0].sel
= ctx
->temp_reg
;
2242 alu
.src
[0].chan
= 1;
2244 alu
.dst
.sel
= ctx
->temp_reg
;
2249 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2253 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2257 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2259 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2260 alu
.src
[0].sel
= ctx
->temp_reg
;
2261 alu
.src
[0].chan
= 1;
2263 alu
.dst
.sel
= ctx
->temp_reg
;
2268 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2272 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2276 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2278 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2280 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2284 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2286 alu
.src
[1].sel
= ctx
->temp_reg
;
2287 alu
.src
[1].chan
= 1;
2289 alu
.dst
.sel
= ctx
->temp_reg
;
2294 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2298 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2303 /* result.z = log2(src);*/
2304 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
2305 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2307 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2308 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2312 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2314 alu
.dst
.sel
= ctx
->temp_reg
;
2319 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2323 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2328 /* result.w = 1.0; */
2329 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
2330 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2332 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2333 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2334 alu
.src
[0].chan
= 0;
2336 alu
.dst
.sel
= ctx
->temp_reg
;
2341 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2345 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2350 return tgsi_helper_copy(ctx
, inst
);
2353 /* r6/7 only for now */
2354 static int tgsi_arl(struct r600_shader_ctx
*ctx
)
2356 /* TODO from r600c, ar values don't persist between clauses */
2357 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2358 struct r600_bc_alu alu
;
2360 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2362 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR
;
2364 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2367 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2371 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2374 ctx
->bc
->cf_last
->r6xx_uses_waterfall
= 1;
2378 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
2380 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2381 struct r600_bc_alu alu
;
2384 for (i
= 0; i
< 4; i
++) {
2385 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2387 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2388 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2392 if (i
== 0 || i
== 3) {
2393 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2395 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2398 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2401 if (i
== 0 || i
== 2) {
2402 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2404 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[1]);
2407 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
2411 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2418 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
2420 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2421 struct r600_bc_alu alu
;
2424 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2428 alu
.dst
.sel
= ctx
->temp_reg
;
2432 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2435 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2436 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2437 alu
.src
[1].chan
= 0;
2441 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
2447 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
2449 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
2450 ctx
->bc
->cf_last
->pop_count
= pops
;
2454 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
2458 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2462 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
2465 /* TOODO : for 16 vp asic should -= 2; */
2466 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2471 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
2473 if (check_max_only
) {
2486 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
2487 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2488 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2489 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
2495 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2499 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
2502 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2506 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
2507 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2508 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2509 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
2513 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
2515 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
2517 sp
->mid
= (struct r600_bc_cf
**)realloc((void *)sp
->mid
,
2518 sizeof(struct r600_bc_cf
*) * (sp
->num_mid
+ 1));
2519 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
2523 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
2526 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
2527 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
2530 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
2532 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
2544 static int emit_return(struct r600_shader_ctx
*ctx
)
2546 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
2550 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
2553 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_JUMP
);
2554 ctx
->bc
->cf_last
->pop_count
= pops
;
2555 /* TODO work out offset */
2559 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
2564 static void emit_testflag(struct r600_shader_ctx
*ctx
)
2569 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
2572 emit_jump_to_offset(ctx
, 1, 4);
2573 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
2574 pops(ctx
, ifidx
+ 1);
2578 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
2582 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2583 ctx
->bc
->cf_last
->pop_count
= 1;
2585 fc_set_mid(ctx
, fc_sp
);
2591 static int tgsi_if(struct r600_shader_ctx
*ctx
)
2593 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
2595 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
2597 fc_pushlevel(ctx
, FC_IF
);
2599 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
2603 static int tgsi_else(struct r600_shader_ctx
*ctx
)
2605 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
2606 ctx
->bc
->cf_last
->pop_count
= 1;
2608 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
2609 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
2613 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
2616 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
2617 R600_ERR("if/endif unbalanced in shader\n");
2621 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
2622 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2623 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
2625 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2629 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
2633 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
2635 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
2637 fc_pushlevel(ctx
, FC_LOOP
);
2639 /* check stack depth */
2640 callstack_check_depth(ctx
, FC_LOOP
, 0);
2644 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
2648 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
2650 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
2651 R600_ERR("loop/endloop in shader code are not paired.\n");
2655 /* fixup loop pointers - from r600isa
2656 LOOP END points to CF after LOOP START,
2657 LOOP START point to CF after LOOP END
2658 BRK/CONT point to LOOP END CF
2660 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
2662 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2664 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
2665 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
2667 /* TODO add LOOPRET support */
2669 callstack_decrease_current(ctx
, FC_LOOP
);
2673 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
2677 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
2679 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
2684 R600_ERR("Break not inside loop/endloop pair\n");
2688 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2689 ctx
->bc
->cf_last
->pop_count
= 1;
2691 fc_set_mid(ctx
, fscp
);
2694 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
2698 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
2699 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_arl
},
2700 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2701 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2704 * For state trackers other than OpenGL, we'll want to use
2705 * _RECIP_IEEE instead.
2707 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
2709 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
2710 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2711 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
2712 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2713 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2714 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2715 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2716 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2717 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2718 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2719 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2720 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2721 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2722 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2723 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2724 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2726 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2727 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2729 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2730 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2731 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2732 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2733 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2734 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2735 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2736 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2737 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2738 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2740 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2741 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2742 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2743 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2744 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2745 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2746 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2747 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
2748 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2749 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2750 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2751 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2752 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2753 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
2754 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2755 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
2756 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
2757 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
2758 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
2759 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2760 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2761 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2762 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2763 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2764 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2765 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2766 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2767 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2768 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2769 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2770 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2771 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2772 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2773 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
2774 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
2775 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
2776 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2777 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2778 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2779 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2780 {TGSI_OPCODE_TXL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2781 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
2782 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
2784 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2785 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2786 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
2787 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
2789 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2790 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2791 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2792 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2793 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2794 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2795 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2796 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
2797 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2799 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2800 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2801 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2802 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2803 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2804 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2805 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2806 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2807 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
2808 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2809 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2810 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
2811 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2812 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
2813 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2815 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2816 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2817 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2818 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2819 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2821 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2822 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2823 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2824 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2825 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2826 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2827 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2828 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2829 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
2830 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
2832 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2833 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2834 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2835 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2836 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2837 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2838 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2839 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2840 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2841 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2842 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2843 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2844 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2845 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2846 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2847 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2848 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2849 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2850 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2851 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2852 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2853 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2854 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2855 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2856 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2857 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2858 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2859 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2862 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
2863 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2864 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2865 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2866 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
2867 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
2868 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2869 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2870 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2871 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2872 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2873 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2874 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2875 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2876 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2877 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2878 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2879 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2880 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2881 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2882 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2884 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2885 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2887 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2888 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2889 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2890 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2891 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2892 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2893 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2894 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2895 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2896 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2898 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2899 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2900 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2901 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2902 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2903 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2904 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2905 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
2906 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2907 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2908 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2909 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2910 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2911 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
2912 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2913 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
2914 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
2915 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
2916 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
2917 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2918 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2919 {TGSI_OPCODE_TXD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2920 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2921 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2922 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2923 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2924 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2925 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2926 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2927 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2928 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2929 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2930 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2931 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
2932 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
2933 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
2934 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2935 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2936 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2937 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2938 {TGSI_OPCODE_TXL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2939 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
2940 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
2942 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2943 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2944 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
2945 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
2947 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2948 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2949 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2950 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2951 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2952 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2953 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2954 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
2955 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2957 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2958 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2959 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2960 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2961 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2962 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2963 {TGSI_OPCODE_TXF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2964 {TGSI_OPCODE_TXQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2965 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
2966 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2967 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2968 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
2969 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2970 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
2971 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2973 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2974 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2975 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2976 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2977 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2979 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2980 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2981 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2982 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2983 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2984 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2985 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2986 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2987 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
2988 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
2990 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2991 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2992 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2993 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2994 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2995 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2996 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2997 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2998 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2999 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3000 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3001 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3002 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3003 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3004 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3005 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3006 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3007 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3008 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3009 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3010 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3011 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3012 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3013 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3014 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3015 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3016 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3017 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},