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 r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
);
66 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
68 static int r600_shader_update(struct pipe_context
*ctx
, struct r600_shader
*shader
)
70 struct r600_context
*rctx
= r600_context(ctx
);
71 const struct util_format_description
*desc
;
72 enum pipe_format resource_format
[160];
73 unsigned i
, nresources
= 0;
74 struct r600_bc
*bc
= &shader
->bc
;
75 struct r600_bc_cf
*cf
;
76 struct r600_bc_vtx
*vtx
;
78 if (shader
->processor_type
!= TGSI_PROCESSOR_VERTEX
)
80 for (i
= 0; i
< rctx
->vertex_elements
->count
; i
++) {
81 resource_format
[nresources
++] = rctx
->vertex_elements
->elements
[i
].src_format
;
83 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
85 case V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
86 case V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC
:
87 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
88 desc
= util_format_description(resource_format
[vtx
->buffer_id
]);
90 R600_ERR("unknown format %d\n", resource_format
[vtx
->buffer_id
]);
93 vtx
->dst_sel_x
= desc
->swizzle
[0];
94 vtx
->dst_sel_y
= desc
->swizzle
[1];
95 vtx
->dst_sel_z
= desc
->swizzle
[2];
96 vtx
->dst_sel_w
= desc
->swizzle
[3];
103 return r600_bc_build(&shader
->bc
);
106 int r600_pipe_shader_create(struct pipe_context
*ctx
,
107 struct r600_context_state
*rpshader
,
108 const struct tgsi_token
*tokens
)
110 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
113 //fprintf(stderr, "--------------------------------------------------------------\n");
114 //tgsi_dump(tokens, 0);
115 if (rpshader
== NULL
)
117 rpshader
->shader
.family
= radeon_get_family(rscreen
->rw
);
118 rpshader
->shader
.use_mem_constant
= rscreen
->use_mem_constant
;
119 r
= r600_shader_from_tgsi(tokens
, &rpshader
->shader
);
121 R600_ERR("translation from TGSI failed !\n");
124 r
= r600_bc_build(&rpshader
->shader
.bc
);
126 R600_ERR("building bytecode failed !\n");
129 //fprintf(stderr, "______________________________________________________________\n");
133 static int r600_pipe_shader_vs(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
135 struct r600_context
*rctx
= r600_context(ctx
);
136 struct radeon_state
*state
;
138 state
= &rpshader
->rstate
[0];
139 radeon_state_fini(&rpshader
->rstate
[0]);
141 return rctx
->vtbl
->vs_shader(rctx
, rpshader
, state
);
144 static int r600_pipe_shader_ps(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
146 struct r600_context
*rctx
= r600_context(ctx
);
147 struct radeon_state
*state
;
149 state
= &rpshader
->rstate
[0];
150 radeon_state_fini(state
);
152 return rctx
->vtbl
->ps_shader(rctx
, rpshader
, state
);
155 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
157 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
158 struct r600_context
*rctx
= r600_context(ctx
);
159 struct r600_shader
*rshader
= &rpshader
->shader
;
162 /* copy new shader */
163 radeon_bo_decref(rscreen
->rw
, rpshader
->bo
);
165 rpshader
->bo
= radeon_bo(rscreen
->rw
, 0, rshader
->bc
.ndw
* 4,
167 if (rpshader
->bo
== NULL
) {
170 radeon_bo_map(rscreen
->rw
, rpshader
->bo
);
171 memcpy(rpshader
->bo
->data
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* 4);
172 radeon_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
= 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 r
= tgsi_setup_trig(ctx
, r600_src
);
935 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
936 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
937 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
941 alu
.src
[0].sel
= ctx
->temp_reg
;
944 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
949 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
950 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
951 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
955 alu
.src
[0].sel
= ctx
->temp_reg
;
958 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
964 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
966 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
967 struct r600_bc_alu alu
;
970 for (i
= 0; i
< 4; i
++) {
971 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
972 alu
.inst
= ctx
->inst_info
->r600_opcode
;
976 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
978 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
979 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
982 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
985 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
990 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
994 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
998 /* kill must be last in ALU */
999 ctx
->bc
->force_add_cf
= 1;
1000 ctx
->shader
->uses_kill
= TRUE
;
1004 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
1006 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1007 struct r600_bc_alu alu
;
1008 struct r600_bc_alu_src r600_src
[3];
1011 r
= tgsi_split_constant(ctx
, r600_src
);
1014 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1019 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1020 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1021 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
1022 alu
.src
[0].chan
= 0;
1023 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1026 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
1027 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1031 /* dst.y = max(src.x, 0.0) */
1032 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1033 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1034 alu
.src
[0] = r600_src
[0];
1035 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1036 alu
.src
[1].chan
= 0;
1037 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1040 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
1041 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1046 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1047 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1048 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1049 alu
.src
[0].chan
= 0;
1050 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1053 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
1055 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1059 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1063 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
1068 /* dst.z = log(src.y) */
1069 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1070 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1071 alu
.src
[0] = r600_src
[0];
1072 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1073 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1077 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1081 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1085 chan
= alu
.dst
.chan
;
1088 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
1089 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1090 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
1091 alu
.src
[0] = r600_src
[0];
1092 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1093 alu
.src
[1].sel
= sel
;
1094 alu
.src
[1].chan
= chan
;
1096 alu
.src
[2] = r600_src
[0];
1097 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], 0);
1098 alu
.dst
.sel
= ctx
->temp_reg
;
1103 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1107 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1110 /* dst.z = exp(tmp.x) */
1111 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1112 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1113 alu
.src
[0].sel
= ctx
->temp_reg
;
1114 alu
.src
[0].chan
= 0;
1115 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1119 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1126 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
1128 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1129 struct r600_bc_alu alu
;
1132 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1133 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
);
1134 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1135 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1138 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1141 alu
.dst
.sel
= ctx
->temp_reg
;
1144 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1147 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1150 /* replicate result */
1151 return tgsi_helper_tempx_replicate(ctx
);
1154 static int tgsi_trans(struct r600_shader_ctx
*ctx
)
1156 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1157 struct r600_bc_alu alu
;
1160 for (i
= 0; i
< 4; i
++) {
1161 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1162 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
1163 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1164 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1165 r
= tgsi_src(ctx
, &inst
->Src
[j
], &alu
.src
[j
]);
1168 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1170 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1174 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1182 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1184 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1185 struct r600_bc_alu alu
;
1188 for (i
= 0; i
< 4; i
++) {
1189 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1190 alu
.src
[0].sel
= ctx
->temp_reg
;
1191 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1193 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1196 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1199 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1206 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1208 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1209 struct r600_bc_alu alu
;
1212 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1213 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1214 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1215 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1218 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1220 alu
.dst
.sel
= ctx
->temp_reg
;
1223 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1226 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1229 /* replicate result */
1230 return tgsi_helper_tempx_replicate(ctx
);
1233 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1235 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1236 struct r600_bc_alu alu
;
1240 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1241 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1242 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1245 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1246 alu
.dst
.sel
= ctx
->temp_reg
;
1249 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1252 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1256 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1257 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL_IEEE
);
1258 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[0]);
1261 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], 0);
1262 alu
.src
[1].sel
= ctx
->temp_reg
;
1263 alu
.dst
.sel
= ctx
->temp_reg
;
1266 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1269 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1272 /* POW(a,b) = EXP2(b * LOG2(a))*/
1273 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1274 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1275 alu
.src
[0].sel
= ctx
->temp_reg
;
1276 alu
.dst
.sel
= ctx
->temp_reg
;
1279 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1282 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1285 return tgsi_helper_tempx_replicate(ctx
);
1288 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1290 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1291 struct r600_bc_alu alu
;
1292 struct r600_bc_alu_src r600_src
[3];
1295 r
= tgsi_split_constant(ctx
, r600_src
);
1299 /* tmp = (src > 0 ? 1 : src) */
1300 for (i
= 0; i
< 4; i
++) {
1301 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1302 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1305 alu
.dst
.sel
= ctx
->temp_reg
;
1308 alu
.src
[0] = r600_src
[0];
1309 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1311 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1313 alu
.src
[2] = r600_src
[0];
1314 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], i
);
1317 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1321 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1325 /* dst = (-tmp > 0 ? -1 : tmp) */
1326 for (i
= 0; i
< 4; i
++) {
1327 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1328 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1330 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1334 alu
.src
[0].sel
= ctx
->temp_reg
;
1335 alu
.src
[0].chan
= i
;
1338 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1341 alu
.src
[2].sel
= ctx
->temp_reg
;
1342 alu
.src
[2].chan
= i
;
1346 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1353 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1355 struct r600_bc_alu alu
;
1358 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1361 for (i
= 0; i
< 4; i
++) {
1362 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1363 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1364 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
1367 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1368 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1371 alu
.src
[0].sel
= ctx
->temp_reg
;
1372 alu
.src
[0].chan
= i
;
1377 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1384 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1386 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1387 struct r600_bc_alu_src r600_src
[3];
1388 struct r600_bc_alu alu
;
1391 r
= tgsi_split_constant(ctx
, r600_src
);
1394 /* do it in 2 step as op3 doesn't support writemask */
1395 for (i
= 0; i
< 4; i
++) {
1396 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1397 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1398 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1399 alu
.src
[j
] = r600_src
[j
];
1400 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1402 alu
.dst
.sel
= ctx
->temp_reg
;
1409 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1413 return tgsi_helper_copy(ctx
, inst
);
1416 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1418 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1419 struct r600_bc_alu_src r600_src
[3];
1420 struct r600_bc_alu alu
;
1423 r
= tgsi_split_constant(ctx
, r600_src
);
1426 for (i
= 0; i
< 4; i
++) {
1427 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1428 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1429 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1430 alu
.src
[j
] = r600_src
[j
];
1431 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1433 alu
.dst
.sel
= ctx
->temp_reg
;
1436 /* handle some special cases */
1437 switch (ctx
->inst_info
->tgsi_opcode
) {
1438 case TGSI_OPCODE_DP2
:
1440 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1441 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1444 case TGSI_OPCODE_DP3
:
1446 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1447 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1450 case TGSI_OPCODE_DPH
:
1452 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1453 alu
.src
[0].chan
= 0;
1463 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1467 return tgsi_helper_copy(ctx
, inst
);
1470 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1472 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1473 struct r600_bc_tex tex
;
1474 struct r600_bc_alu alu
;
1478 boolean src_not_temp
= inst
->Src
[0].Register
.File
!= TGSI_FILE_TEMPORARY
;
1479 uint32_t lit_vals
[4];
1481 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
1483 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1484 /* Add perspective divide */
1485 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1486 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1487 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1491 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1492 alu
.dst
.sel
= ctx
->temp_reg
;
1496 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1500 for (i
= 0; i
< 3; i
++) {
1501 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1502 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1503 alu
.src
[0].sel
= ctx
->temp_reg
;
1504 alu
.src
[0].chan
= 3;
1505 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1508 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1509 alu
.dst
.sel
= ctx
->temp_reg
;
1512 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1516 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1517 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1518 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1519 alu
.src
[0].chan
= 0;
1520 alu
.dst
.sel
= ctx
->temp_reg
;
1524 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1527 src_not_temp
= false;
1528 src_gpr
= ctx
->temp_reg
;
1531 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1532 int src_chan
, src2_chan
;
1534 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
1535 for (i
= 0; i
< 4; i
++) {
1536 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1537 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
1556 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1559 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], src_chan
);
1560 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1563 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], src2_chan
);
1564 alu
.dst
.sel
= ctx
->temp_reg
;
1569 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1574 /* tmp1.z = RCP_e(|tmp1.z|) */
1575 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1576 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1577 alu
.src
[0].sel
= ctx
->temp_reg
;
1578 alu
.src
[0].chan
= 2;
1580 alu
.dst
.sel
= ctx
->temp_reg
;
1584 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1588 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
1589 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
1590 * muladd has no writemask, have to use another temp
1592 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1593 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1596 alu
.src
[0].sel
= ctx
->temp_reg
;
1597 alu
.src
[0].chan
= 0;
1598 alu
.src
[1].sel
= ctx
->temp_reg
;
1599 alu
.src
[1].chan
= 2;
1601 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1602 alu
.src
[2].chan
= 0;
1604 alu
.dst
.sel
= ctx
->temp_reg
;
1608 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1612 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1613 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1616 alu
.src
[0].sel
= ctx
->temp_reg
;
1617 alu
.src
[0].chan
= 1;
1618 alu
.src
[1].sel
= ctx
->temp_reg
;
1619 alu
.src
[1].chan
= 2;
1621 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1622 alu
.src
[2].chan
= 0;
1624 alu
.dst
.sel
= ctx
->temp_reg
;
1629 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1633 lit_vals
[0] = fui(1.5f
);
1635 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
1638 src_not_temp
= false;
1639 src_gpr
= ctx
->temp_reg
;
1643 for (i
= 0; i
< 4; i
++) {
1644 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1645 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1646 alu
.src
[0].sel
= src_gpr
;
1647 alu
.src
[0].chan
= i
;
1648 alu
.dst
.sel
= ctx
->temp_reg
;
1653 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1657 src_gpr
= ctx
->temp_reg
;
1660 opcode
= ctx
->inst_info
->r600_opcode
;
1661 if (opcode
== SQ_TEX_INST_SAMPLE
&&
1662 (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
))
1663 opcode
= SQ_TEX_INST_SAMPLE_C
;
1665 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
1667 tex
.resource_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
1668 tex
.sampler_id
= tex
.resource_id
;
1669 tex
.src_gpr
= src_gpr
;
1670 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
1680 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1687 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
1688 tex
.coord_type_x
= 1;
1689 tex
.coord_type_y
= 1;
1690 tex
.coord_type_z
= 1;
1691 tex
.coord_type_w
= 1;
1694 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
)
1697 r
= r600_bc_add_tex(ctx
->bc
, &tex
);
1701 /* add shadow ambient support - gallium doesn't do it yet */
1706 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
1708 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1709 struct r600_bc_alu_src r600_src
[3];
1710 struct r600_bc_alu alu
;
1714 r
= tgsi_split_constant(ctx
, r600_src
);
1718 for (i
= 0; i
< 4; i
++) {
1719 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1720 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
1721 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1722 alu
.src
[0].chan
= 0;
1723 alu
.src
[1] = r600_src
[0];
1724 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1726 alu
.dst
.sel
= ctx
->temp_reg
;
1732 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1736 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1740 /* (1 - src0) * src2 */
1741 for (i
= 0; i
< 4; i
++) {
1742 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1743 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1744 alu
.src
[0].sel
= ctx
->temp_reg
;
1745 alu
.src
[0].chan
= i
;
1746 alu
.src
[1] = r600_src
[2];
1747 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1748 alu
.dst
.sel
= ctx
->temp_reg
;
1754 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1758 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1762 /* src0 * src1 + (1 - src0) * src2 */
1763 for (i
= 0; i
< 4; i
++) {
1764 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1765 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1767 alu
.src
[0] = r600_src
[0];
1768 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1769 alu
.src
[1] = r600_src
[1];
1770 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
1771 alu
.src
[2].sel
= ctx
->temp_reg
;
1772 alu
.src
[2].chan
= i
;
1773 alu
.dst
.sel
= ctx
->temp_reg
;
1778 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1782 return tgsi_helper_copy(ctx
, inst
);
1785 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
1787 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1788 struct r600_bc_alu_src r600_src
[3];
1789 struct r600_bc_alu alu
;
1793 r
= tgsi_split_constant(ctx
, r600_src
);
1797 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1800 for (i
= 0; i
< 4; i
++) {
1801 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1802 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
1803 alu
.src
[0] = r600_src
[0];
1804 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1806 alu
.src
[1] = r600_src
[2];
1807 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1809 alu
.src
[2] = r600_src
[1];
1810 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[1], i
);
1813 alu
.dst
.sel
= ctx
->temp_reg
;
1815 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1824 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1829 return tgsi_helper_copy(ctx
, inst
);
1833 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
1835 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1836 struct r600_bc_alu_src r600_src
[3];
1837 struct r600_bc_alu alu
;
1838 uint32_t use_temp
= 0;
1841 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1844 r
= tgsi_split_constant(ctx
, r600_src
);
1848 for (i
= 0; i
< 4; i
++) {
1849 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1850 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1852 alu
.src
[0] = r600_src
[0];
1855 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1858 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1861 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1864 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1865 alu
.src
[0].chan
= i
;
1868 alu
.src
[1] = r600_src
[1];
1871 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1874 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1877 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1880 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1881 alu
.src
[1].chan
= i
;
1884 alu
.dst
.sel
= ctx
->temp_reg
;
1890 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1894 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1899 for (i
= 0; i
< 4; i
++) {
1900 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1901 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1903 alu
.src
[0] = r600_src
[0];
1906 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1909 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1912 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1915 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1916 alu
.src
[0].chan
= i
;
1919 alu
.src
[1] = r600_src
[1];
1922 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1925 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1928 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1931 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1932 alu
.src
[1].chan
= i
;
1935 alu
.src
[2].sel
= ctx
->temp_reg
;
1937 alu
.src
[2].chan
= i
;
1940 alu
.dst
.sel
= ctx
->temp_reg
;
1942 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1951 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1955 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1960 return tgsi_helper_copy(ctx
, inst
);
1964 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
1966 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1967 struct r600_bc_alu_src r600_src
[3];
1968 struct r600_bc_alu alu
;
1971 /* result.x = 2^floor(src); */
1972 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
1973 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1975 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
1976 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1980 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1982 alu
.dst
.sel
= ctx
->temp_reg
;
1986 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1990 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1994 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1995 alu
.src
[0].sel
= ctx
->temp_reg
;
1996 alu
.src
[0].chan
= 0;
1998 alu
.dst
.sel
= ctx
->temp_reg
;
2002 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2006 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2011 /* result.y = tmp - floor(tmp); */
2012 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2013 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2015 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
2016 alu
.src
[0] = r600_src
[0];
2017 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2020 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2022 alu
.dst
.sel
= ctx
->temp_reg
;
2023 // r = tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
2031 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2034 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2039 /* result.z = RoughApprox2ToX(tmp);*/
2040 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
2041 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2042 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2043 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2046 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2048 alu
.dst
.sel
= ctx
->temp_reg
;
2054 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2057 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2062 /* result.w = 1.0;*/
2063 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
2064 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2066 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2067 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2068 alu
.src
[0].chan
= 0;
2070 alu
.dst
.sel
= ctx
->temp_reg
;
2074 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2077 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2081 return tgsi_helper_copy(ctx
, inst
);
2084 static int tgsi_log(struct r600_shader_ctx
*ctx
)
2086 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2087 struct r600_bc_alu alu
;
2090 /* result.x = floor(log2(src)); */
2091 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2092 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2094 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2095 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2099 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2101 alu
.dst
.sel
= ctx
->temp_reg
;
2105 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2109 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2113 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2114 alu
.src
[0].sel
= ctx
->temp_reg
;
2115 alu
.src
[0].chan
= 0;
2117 alu
.dst
.sel
= ctx
->temp_reg
;
2122 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2126 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2131 /* result.y = src.x / (2 ^ floor(log2(src.x))); */
2132 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2133 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2135 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2136 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2140 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2142 alu
.dst
.sel
= ctx
->temp_reg
;
2147 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2151 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2155 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2157 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2158 alu
.src
[0].sel
= ctx
->temp_reg
;
2159 alu
.src
[0].chan
= 1;
2161 alu
.dst
.sel
= ctx
->temp_reg
;
2166 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2170 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2174 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2176 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2177 alu
.src
[0].sel
= ctx
->temp_reg
;
2178 alu
.src
[0].chan
= 1;
2180 alu
.dst
.sel
= ctx
->temp_reg
;
2185 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2189 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2193 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2195 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2196 alu
.src
[0].sel
= ctx
->temp_reg
;
2197 alu
.src
[0].chan
= 1;
2199 alu
.dst
.sel
= ctx
->temp_reg
;
2204 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2208 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2212 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2214 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2216 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2220 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2222 alu
.src
[1].sel
= ctx
->temp_reg
;
2223 alu
.src
[1].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
);
2239 /* result.z = log2(src);*/
2240 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
2241 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2243 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2244 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2248 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2250 alu
.dst
.sel
= ctx
->temp_reg
;
2255 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2259 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2264 /* result.w = 1.0; */
2265 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
2266 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2268 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2269 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2270 alu
.src
[0].chan
= 0;
2272 alu
.dst
.sel
= ctx
->temp_reg
;
2277 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2281 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2286 return tgsi_helper_copy(ctx
, inst
);
2289 /* r6/7 only for now */
2290 static int tgsi_arl(struct r600_shader_ctx
*ctx
)
2292 /* TODO from r600c, ar values don't persist between clauses */
2293 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2294 struct r600_bc_alu alu
;
2296 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2298 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR
;
2300 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2303 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2307 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2313 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
2315 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2316 struct r600_bc_alu alu
;
2319 for (i
= 0; i
< 4; i
++) {
2320 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2322 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2323 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2327 if (i
== 0 || i
== 3) {
2328 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2330 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2333 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2336 if (i
== 0 || i
== 2) {
2337 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2339 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[1]);
2342 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
2346 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2353 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
2355 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2356 struct r600_bc_alu alu
;
2359 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2363 alu
.dst
.sel
= ctx
->temp_reg
;
2367 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2370 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2371 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2372 alu
.src
[1].chan
= 0;
2376 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
2382 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
2384 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
2385 ctx
->bc
->cf_last
->pop_count
= pops
;
2389 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
2393 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2397 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
2400 /* TOODO : for 16 vp asic should -= 2; */
2401 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2406 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
2408 if (check_max_only
) {
2421 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
2422 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2423 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2424 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
2430 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2434 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
2437 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2441 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
2442 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2443 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2444 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
2448 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
2450 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
2452 sp
->mid
= (struct r600_bc_cf
**)realloc((void *)sp
->mid
,
2453 sizeof(struct r600_bc_cf
*) * (sp
->num_mid
+ 1));
2454 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
2458 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
2461 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
2462 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
2465 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
2467 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
2479 static int emit_return(struct r600_shader_ctx
*ctx
)
2481 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
2485 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
2488 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_JUMP
);
2489 ctx
->bc
->cf_last
->pop_count
= pops
;
2490 /* TODO work out offset */
2494 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
2499 static void emit_testflag(struct r600_shader_ctx
*ctx
)
2504 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
2507 emit_jump_to_offset(ctx
, 1, 4);
2508 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
2509 pops(ctx
, ifidx
+ 1);
2513 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
2517 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2518 ctx
->bc
->cf_last
->pop_count
= 1;
2520 fc_set_mid(ctx
, fc_sp
);
2526 static int tgsi_if(struct r600_shader_ctx
*ctx
)
2528 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
2530 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
2532 fc_pushlevel(ctx
, FC_IF
);
2534 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
2538 static int tgsi_else(struct r600_shader_ctx
*ctx
)
2540 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
2541 ctx
->bc
->cf_last
->pop_count
= 1;
2543 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
2544 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
2548 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
2551 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
2552 R600_ERR("if/endif unbalanced in shader\n");
2556 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
2557 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2558 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
2560 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2564 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
2568 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
2570 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
2572 fc_pushlevel(ctx
, FC_LOOP
);
2574 /* check stack depth */
2575 callstack_check_depth(ctx
, FC_LOOP
, 0);
2579 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
2583 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
2585 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
2586 R600_ERR("loop/endloop in shader code are not paired.\n");
2590 /* fixup loop pointers - from r600isa
2591 LOOP END points to CF after LOOP START,
2592 LOOP START point to CF after LOOP END
2593 BRK/CONT point to LOOP END CF
2595 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
2597 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2599 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
2600 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
2602 /* TODO add LOOPRET support */
2604 callstack_decrease_current(ctx
, FC_LOOP
);
2608 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
2612 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
2614 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
2619 R600_ERR("Break not inside loop/endloop pair\n");
2623 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2624 ctx
->bc
->cf_last
->pop_count
= 1;
2626 fc_set_mid(ctx
, fscp
);
2629 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
2633 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
2634 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_arl
},
2635 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2636 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2637 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
2638 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
2639 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2640 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
2641 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2642 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2643 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2644 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2645 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2646 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2647 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2648 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2649 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2650 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2651 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2652 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2653 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2655 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2656 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2658 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2659 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2660 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2661 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2662 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2663 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2664 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2665 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2666 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2667 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2669 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2670 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2671 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2672 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2673 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2674 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2675 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2676 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
2677 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2678 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2679 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2680 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2681 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2682 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
2683 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2684 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
2685 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
2686 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
2687 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
2688 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2689 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2690 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2691 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2692 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2693 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2694 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2695 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2696 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2697 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2698 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2699 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2700 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2701 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2702 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
2703 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
2704 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
2705 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2706 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2707 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2708 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2709 {TGSI_OPCODE_TXL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2710 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
2711 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
2713 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2714 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2715 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
2716 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
2718 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2719 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2720 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2721 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2722 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2723 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2724 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2725 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
2726 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2728 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2729 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2730 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2731 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2732 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2733 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2734 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2735 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2736 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
2737 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2738 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2739 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
2740 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2741 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
2742 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2744 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2745 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2746 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2747 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2748 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2750 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2751 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2752 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2753 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2754 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2755 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2756 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2757 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2758 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
2759 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
2761 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2762 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2763 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2764 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2765 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2766 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2767 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2768 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2769 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2770 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2771 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2772 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2773 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2774 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2775 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2776 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2777 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2778 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2779 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2780 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2781 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2782 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2783 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2784 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2785 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2786 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2787 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2788 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2791 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
2792 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2793 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2794 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2795 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
2796 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
2797 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2798 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2799 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2800 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2801 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2802 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2803 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2804 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2805 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2806 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2807 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2808 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2809 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2810 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2811 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2813 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2814 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2816 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2817 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2818 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2819 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2820 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2821 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2822 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2823 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2824 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2825 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2827 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2828 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2829 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2830 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2831 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2832 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2833 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2834 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
2835 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2836 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2837 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2838 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2839 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2840 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
2841 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2842 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
2843 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
2844 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
2845 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
2846 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2847 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2848 {TGSI_OPCODE_TXD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2849 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2850 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2851 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2852 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2853 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2854 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2855 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2856 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2857 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2858 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2859 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2860 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
2861 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
2862 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
2863 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2864 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2865 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2866 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2867 {TGSI_OPCODE_TXL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2868 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
2869 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
2871 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2872 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2873 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
2874 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
2876 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2877 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2878 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2879 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2880 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2881 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2882 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2883 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
2884 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2886 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2887 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2888 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2889 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2890 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2891 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2892 {TGSI_OPCODE_TXF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2893 {TGSI_OPCODE_TXQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2894 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
2895 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2896 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2897 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
2898 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2899 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
2900 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2902 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2903 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2904 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2905 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2906 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2908 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2909 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2910 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2911 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2912 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2913 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2914 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2915 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2916 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
2917 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
2919 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2920 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2921 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2922 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2923 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2924 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2925 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2926 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2927 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2928 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2929 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2930 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2931 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2932 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2933 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2934 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2935 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2936 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2937 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2938 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2939 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2940 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2941 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2942 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2943 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2944 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2945 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2946 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},