2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #include "pipe/p_shader_tokens.h"
24 #include "tgsi/tgsi_parse.h"
25 #include "tgsi/tgsi_scan.h"
26 #include "tgsi/tgsi_dump.h"
27 #include "util/u_format.h"
28 #include "r600_pipe.h"
31 #include "r600_opcodes.h"
37 struct r600_shader_tgsi_instruction
;
39 struct r600_shader_ctx
{
40 struct tgsi_shader_info info
;
41 struct tgsi_parse_context parse
;
42 const struct tgsi_token
*tokens
;
44 unsigned file_offset
[TGSI_FILE_COUNT
];
46 struct r600_shader_tgsi_instruction
*inst_info
;
48 struct r600_shader
*shader
;
52 u32 max_driver_temp_used
;
55 struct r600_shader_tgsi_instruction
{
59 int (*process
)(struct r600_shader_ctx
*ctx
);
62 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[], eg_shader_tgsi_instruction
[];
63 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
65 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
67 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
70 if (i
->Instruction
.NumDstRegs
> 1) {
71 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
74 if (i
->Instruction
.Predicate
) {
75 R600_ERR("predicate unsupported\n");
79 if (i
->Instruction
.Label
) {
80 R600_ERR("label unsupported\n");
84 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
85 if (i
->Src
[j
].Register
.Dimension
||
86 i
->Src
[j
].Register
.Absolute
) {
87 R600_ERR("unsupported src %d (dimension %d|absolute %d)\n", j
,
88 i
->Src
[j
].Register
.Dimension
,
89 i
->Src
[j
].Register
.Absolute
);
93 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
94 if (i
->Dst
[j
].Register
.Dimension
) {
95 R600_ERR("unsupported dst (dimension)\n");
102 static int evergreen_interp_alu(struct r600_shader_ctx
*ctx
, int gpr
)
105 struct r600_bc_alu alu
;
107 for (i
= 0; i
< 8; i
++) {
108 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
111 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW
;
113 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_XY
;
115 if ((i
> 1) && (i
< 6)) {
116 alu
.dst
.sel
= ctx
->shader
->input
[gpr
].gpr
;
120 alu
.dst
.chan
= i
% 4;
121 alu
.src
[0].chan
= (1 - (i
% 2));
122 alu
.src
[1].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ gpr
;
124 alu
.bank_swizzle_force
= SQ_ALU_VEC_210
;
127 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
135 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
137 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
138 struct r600_bc_vtx vtx
;
142 switch (d
->Declaration
.File
) {
143 case TGSI_FILE_INPUT
:
144 i
= ctx
->shader
->ninput
++;
145 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
146 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
147 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
148 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + i
;
149 if (ctx
->type
== TGSI_PROCESSOR_VERTEX
) {
150 /* turn input into fetch */
151 memset(&vtx
, 0, sizeof(struct r600_bc_vtx
));
155 /* register containing the index into the buffer */
158 vtx
.mega_fetch_count
= 0x1F;
159 vtx
.dst_gpr
= ctx
->shader
->input
[i
].gpr
;
164 r
= r600_bc_add_vtx(ctx
->bc
, &vtx
);
168 if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
->bc
->chiprev
== 2) {
169 /* turn input into interpolate on EG */
170 evergreen_interp_alu(ctx
, i
);
173 case TGSI_FILE_OUTPUT
:
174 i
= ctx
->shader
->noutput
++;
175 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
176 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
177 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + i
;
178 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
180 case TGSI_FILE_CONSTANT
:
181 case TGSI_FILE_TEMPORARY
:
182 case TGSI_FILE_SAMPLER
:
183 case TGSI_FILE_ADDRESS
:
186 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
192 static int r600_get_temp(struct r600_shader_ctx
*ctx
)
194 return ctx
->temp_reg
+ ctx
->max_driver_temp_used
++;
197 int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
)
199 struct tgsi_full_immediate
*immediate
;
200 struct r600_shader_ctx ctx
;
201 struct r600_bc_output output
[32];
202 unsigned output_done
, noutput
;
206 ctx
.bc
= &shader
->bc
;
208 r
= r600_bc_init(ctx
.bc
, shader
->family
);
211 ctx
.bc
->use_mem_constant
= shader
->use_mem_constant
;
213 tgsi_scan_shader(tokens
, &ctx
.info
);
214 tgsi_parse_init(&ctx
.parse
, tokens
);
215 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
216 shader
->processor_type
= ctx
.type
;
218 /* register allocations */
219 /* Values [0,127] correspond to GPR[0..127].
220 * Values [128,159] correspond to constant buffer bank 0
221 * Values [160,191] correspond to constant buffer bank 1
222 * Values [256,511] correspond to cfile constants c[0..255].
223 * Other special values are shown in the list below.
224 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
225 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
226 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
227 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
228 * 248 SQ_ALU_SRC_0: special constant 0.0.
229 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
230 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
231 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
232 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
233 * 253 SQ_ALU_SRC_LITERAL: literal constant.
234 * 254 SQ_ALU_SRC_PV: previous vector result.
235 * 255 SQ_ALU_SRC_PS: previous scalar result.
237 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
238 ctx
.file_offset
[i
] = 0;
240 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
241 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
243 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
244 ctx
.info
.file_count
[TGSI_FILE_INPUT
];
245 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
246 ctx
.info
.file_count
[TGSI_FILE_OUTPUT
];
247 if (ctx
.shader
->use_mem_constant
)
248 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 128;
250 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 256;
252 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = 253;
253 ctx
.temp_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
254 ctx
.info
.file_count
[TGSI_FILE_TEMPORARY
];
259 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
260 tgsi_parse_token(&ctx
.parse
);
261 switch (ctx
.parse
.FullToken
.Token
.Type
) {
262 case TGSI_TOKEN_TYPE_IMMEDIATE
:
263 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
264 ctx
.literals
= realloc(ctx
.literals
, (ctx
.nliterals
+ 1) * 16);
265 if(ctx
.literals
== NULL
) {
269 ctx
.literals
[ctx
.nliterals
* 4 + 0] = immediate
->u
[0].Uint
;
270 ctx
.literals
[ctx
.nliterals
* 4 + 1] = immediate
->u
[1].Uint
;
271 ctx
.literals
[ctx
.nliterals
* 4 + 2] = immediate
->u
[2].Uint
;
272 ctx
.literals
[ctx
.nliterals
* 4 + 3] = immediate
->u
[3].Uint
;
275 case TGSI_TOKEN_TYPE_DECLARATION
:
276 r
= tgsi_declaration(&ctx
);
280 case TGSI_TOKEN_TYPE_INSTRUCTION
:
281 r
= tgsi_is_supported(&ctx
);
284 ctx
.max_driver_temp_used
= 0;
285 /* reserve first tmp for everyone */
287 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
288 if (ctx
.bc
->chiprev
== 2)
289 ctx
.inst_info
= &eg_shader_tgsi_instruction
[opcode
];
291 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
292 r
= ctx
.inst_info
->process(&ctx
);
295 r
= r600_bc_add_literal(ctx
.bc
, ctx
.value
);
300 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
306 noutput
= shader
->noutput
;
307 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
308 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
309 output
[i
].gpr
= shader
->output
[i
].gpr
;
310 output
[i
].elem_size
= 3;
311 output
[i
].swizzle_x
= 0;
312 output
[i
].swizzle_y
= 1;
313 output
[i
].swizzle_z
= 2;
314 output
[i
].swizzle_w
= 3;
315 output
[i
].barrier
= 1;
316 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
317 output
[i
].array_base
= i
- pos0
;
318 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
320 case TGSI_PROCESSOR_VERTEX
:
321 if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
322 output
[i
].array_base
= 60;
323 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
324 /* position doesn't count in array_base */
327 if (shader
->output
[i
].name
== TGSI_SEMANTIC_PSIZE
) {
328 output
[i
].array_base
= 61;
329 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
330 /* position doesn't count in array_base */
334 case TGSI_PROCESSOR_FRAGMENT
:
335 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
336 output
[i
].array_base
= shader
->output
[i
].sid
;
337 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
338 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
339 output
[i
].array_base
= 61;
340 output
[i
].swizzle_x
= 2;
341 output
[i
].swizzle_y
= output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
342 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
344 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
350 R600_ERR("unsupported processor type %d\n", ctx
.type
);
355 /* add fake param output for vertex shader if no param is exported */
356 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
357 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
358 if (output
[i
].type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
) {
364 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
366 output
[i
].elem_size
= 3;
367 output
[i
].swizzle_x
= 0;
368 output
[i
].swizzle_y
= 1;
369 output
[i
].swizzle_z
= 2;
370 output
[i
].swizzle_w
= 3;
371 output
[i
].barrier
= 1;
372 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
373 output
[i
].array_base
= 0;
374 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
378 /* add fake pixel export */
379 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& !noutput
) {
380 memset(&output
[0], 0, sizeof(struct r600_bc_output
));
382 output
[0].elem_size
= 3;
383 output
[0].swizzle_x
= 7;
384 output
[0].swizzle_y
= 7;
385 output
[0].swizzle_z
= 7;
386 output
[0].swizzle_w
= 7;
387 output
[0].barrier
= 1;
388 output
[0].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
389 output
[0].array_base
= 0;
390 output
[0].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
393 /* set export done on last export of each type */
394 for (i
= noutput
- 1, output_done
= 0; i
>= 0; i
--) {
395 if (i
== (noutput
- 1)) {
396 output
[i
].end_of_program
= 1;
398 if (!(output_done
& (1 << output
[i
].type
))) {
399 output_done
|= (1 << output
[i
].type
);
400 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
);
403 /* add output to bytecode */
404 for (i
= 0; i
< noutput
; i
++) {
405 r
= r600_bc_add_output(ctx
.bc
, &output
[i
]);
410 tgsi_parse_free(&ctx
.parse
);
414 tgsi_parse_free(&ctx
.parse
);
418 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
420 R600_ERR("%d tgsi opcode unsupported\n", ctx
->inst_info
->tgsi_opcode
);
424 static int tgsi_end(struct r600_shader_ctx
*ctx
)
429 static int tgsi_src(struct r600_shader_ctx
*ctx
,
430 const struct tgsi_full_src_register
*tgsi_src
,
431 struct r600_bc_alu_src
*r600_src
)
434 memset(r600_src
, 0, sizeof(struct r600_bc_alu_src
));
435 r600_src
->sel
= tgsi_src
->Register
.Index
;
436 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
438 index
= tgsi_src
->Register
.Index
;
439 ctx
->value
[0] = ctx
->literals
[index
* 4 + 0];
440 ctx
->value
[1] = ctx
->literals
[index
* 4 + 1];
441 ctx
->value
[2] = ctx
->literals
[index
* 4 + 2];
442 ctx
->value
[3] = ctx
->literals
[index
* 4 + 3];
444 if (tgsi_src
->Register
.Indirect
)
445 r600_src
->rel
= V_SQ_REL_RELATIVE
;
446 r600_src
->neg
= tgsi_src
->Register
.Negate
;
447 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
451 static int tgsi_dst(struct r600_shader_ctx
*ctx
,
452 const struct tgsi_full_dst_register
*tgsi_dst
,
454 struct r600_bc_alu_dst
*r600_dst
)
456 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
458 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
459 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
460 r600_dst
->chan
= swizzle
;
462 if (tgsi_dst
->Register
.Indirect
)
463 r600_dst
->rel
= V_SQ_REL_RELATIVE
;
464 if (inst
->Instruction
.Saturate
) {
470 static unsigned tgsi_chan(const struct tgsi_full_src_register
*tgsi_src
, unsigned swizzle
)
474 return tgsi_src
->Register
.SwizzleX
;
476 return tgsi_src
->Register
.SwizzleY
;
478 return tgsi_src
->Register
.SwizzleZ
;
480 return tgsi_src
->Register
.SwizzleW
;
486 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
488 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
489 struct r600_bc_alu alu
;
490 int i
, j
, k
, nconst
, r
;
492 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
493 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
496 r
= tgsi_src(ctx
, &inst
->Src
[i
], &r600_src
[i
]);
501 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
502 if (inst
->Src
[j
].Register
.File
== TGSI_FILE_CONSTANT
&& j
> 0) {
503 int treg
= r600_get_temp(ctx
);
504 for (k
= 0; k
< 4; k
++) {
505 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
506 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
507 alu
.src
[0].sel
= r600_src
[j
].sel
;
514 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
518 r600_src
[j
].sel
= treg
;
525 /* need to move any immediate into a temp - for trig functions which use literal for PI stuff */
526 static int tgsi_split_literal_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
528 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
529 struct r600_bc_alu alu
;
530 int i
, j
, k
, nliteral
, r
;
532 for (i
= 0, nliteral
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
533 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_IMMEDIATE
) {
537 for (i
= 0, j
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
538 if (inst
->Src
[j
].Register
.File
== TGSI_FILE_IMMEDIATE
) {
539 int treg
= r600_get_temp(ctx
);
540 for (k
= 0; k
< 4; k
++) {
541 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
542 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
543 alu
.src
[0].sel
= r600_src
[j
].sel
;
550 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
554 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
557 r600_src
[j
].sel
= treg
;
564 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
)
566 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
567 struct r600_bc_alu_src r600_src
[3];
568 struct r600_bc_alu alu
;
572 for (i
= 0; i
< 4; i
++) {
573 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
578 r
= tgsi_split_constant(ctx
, r600_src
);
581 for (i
= 0; i
< lasti
+ 1; i
++) {
582 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
585 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
586 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
590 alu
.inst
= ctx
->inst_info
->r600_opcode
;
592 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
593 alu
.src
[j
] = r600_src
[j
];
594 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
597 alu
.src
[0] = r600_src
[1];
598 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], i
);
600 alu
.src
[1] = r600_src
[0];
601 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
603 /* handle some special cases */
604 switch (ctx
->inst_info
->tgsi_opcode
) {
605 case TGSI_OPCODE_SUB
:
608 case TGSI_OPCODE_ABS
:
617 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
624 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
626 return tgsi_op2_s(ctx
, 0);
629 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
631 return tgsi_op2_s(ctx
, 1);
635 * r600 - trunc to -PI..PI range
636 * r700 - normalize by dividing by 2PI
639 static int tgsi_setup_trig(struct r600_shader_ctx
*ctx
,
640 struct r600_bc_alu_src r600_src
[3])
642 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
644 uint32_t lit_vals
[4];
645 struct r600_bc_alu alu
;
647 memset(lit_vals
, 0, 4*4);
648 r
= tgsi_split_constant(ctx
, r600_src
);
652 r
= tgsi_split_literal_constant(ctx
, r600_src
);
656 lit_vals
[0] = fui(1.0 /(3.1415926535 * 2));
657 lit_vals
[1] = fui(0.5f
);
659 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
660 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
664 alu
.dst
.sel
= ctx
->temp_reg
;
667 alu
.src
[0] = r600_src
[0];
668 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
670 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
672 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
675 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
678 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
682 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
683 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
686 alu
.dst
.sel
= ctx
->temp_reg
;
689 alu
.src
[0].sel
= ctx
->temp_reg
;
692 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
696 if (ctx
->bc
->chiprev
== 0) {
697 lit_vals
[0] = fui(3.1415926535897f
* 2.0f
);
698 lit_vals
[1] = fui(-3.1415926535897f
);
700 lit_vals
[0] = fui(1.0f
);
701 lit_vals
[1] = fui(-0.5f
);
704 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
705 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
709 alu
.dst
.sel
= ctx
->temp_reg
;
712 alu
.src
[0].sel
= ctx
->temp_reg
;
715 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
717 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
720 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
723 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
729 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
731 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
732 struct r600_bc_alu_src r600_src
[3];
733 struct r600_bc_alu alu
;
737 r
= tgsi_setup_trig(ctx
, r600_src
);
741 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
742 alu
.inst
= ctx
->inst_info
->r600_opcode
;
744 alu
.dst
.sel
= ctx
->temp_reg
;
747 alu
.src
[0].sel
= ctx
->temp_reg
;
750 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
754 /* replicate result */
755 for (i
= 0; i
< 4; i
++) {
756 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
))
759 for (i
= 0; i
< lasti
+ 1; i
++) {
760 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
763 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
764 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
766 alu
.src
[0].sel
= ctx
->temp_reg
;
767 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
772 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
779 static int tgsi_scs(struct r600_shader_ctx
*ctx
)
781 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
782 struct r600_bc_alu_src r600_src
[3];
783 struct r600_bc_alu alu
;
786 /* We'll only need the trig stuff if we are going to write to the
787 * X or Y components of the destination vector.
789 if (likely(inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_XY
)) {
790 r
= tgsi_setup_trig(ctx
, r600_src
);
796 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_X
) {
797 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
798 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
799 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
803 alu
.src
[0].sel
= ctx
->temp_reg
;
806 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
812 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Y
) {
813 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
814 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
815 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
819 alu
.src
[0].sel
= ctx
->temp_reg
;
822 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
828 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Z
) {
829 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
831 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
833 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
837 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
842 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
846 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
852 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
853 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
855 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
857 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
861 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
866 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
870 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
878 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
880 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
881 struct r600_bc_alu alu
;
884 for (i
= 0; i
< 4; i
++) {
885 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
886 alu
.inst
= ctx
->inst_info
->r600_opcode
;
890 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
892 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
893 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
896 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
899 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
904 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
908 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
912 /* kill must be last in ALU */
913 ctx
->bc
->force_add_cf
= 1;
914 ctx
->shader
->uses_kill
= TRUE
;
918 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
920 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
921 struct r600_bc_alu alu
;
922 struct r600_bc_alu_src r600_src
[3];
925 r
= tgsi_split_constant(ctx
, r600_src
);
928 r
= tgsi_split_literal_constant(ctx
, r600_src
);
933 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
934 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
935 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
937 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
940 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
941 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
945 /* dst.y = max(src.x, 0.0) */
946 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
947 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
948 alu
.src
[0] = r600_src
[0];
949 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
951 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
954 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
955 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
960 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
961 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
962 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
964 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
967 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
969 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
973 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
977 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
982 /* dst.z = log(src.y) */
983 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
984 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
985 alu
.src
[0] = r600_src
[0];
986 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
987 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
991 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
995 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1002 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
1003 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1004 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
1005 alu
.src
[0] = r600_src
[0];
1006 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1007 alu
.src
[1].sel
= sel
;
1008 alu
.src
[1].chan
= chan
;
1010 alu
.src
[2] = r600_src
[0];
1011 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], 0);
1012 alu
.dst
.sel
= ctx
->temp_reg
;
1017 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1021 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1024 /* dst.z = exp(tmp.x) */
1025 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1026 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1027 alu
.src
[0].sel
= ctx
->temp_reg
;
1028 alu
.src
[0].chan
= 0;
1029 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1033 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1040 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
1042 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1043 struct r600_bc_alu alu
;
1046 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1049 * For state trackers other than OpenGL, we'll want to use
1050 * _RECIPSQRT_IEEE instead.
1052 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
1054 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1055 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1058 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1061 alu
.dst
.sel
= ctx
->temp_reg
;
1064 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1067 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1070 /* replicate result */
1071 return tgsi_helper_tempx_replicate(ctx
);
1074 static int tgsi_trans(struct r600_shader_ctx
*ctx
)
1076 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1077 struct r600_bc_alu alu
;
1080 for (i
= 0; i
< 4; i
++) {
1081 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1082 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
1083 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1084 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1085 r
= tgsi_src(ctx
, &inst
->Src
[j
], &alu
.src
[j
]);
1088 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1090 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1094 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1102 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1104 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1105 struct r600_bc_alu alu
;
1108 for (i
= 0; i
< 4; i
++) {
1109 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1110 alu
.src
[0].sel
= ctx
->temp_reg
;
1111 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1113 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1116 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1119 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1126 static int tgsi_trans_srcx_replicate(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_info
->r600_opcode
;
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);
1140 alu
.dst
.sel
= ctx
->temp_reg
;
1143 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1146 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1149 /* replicate result */
1150 return tgsi_helper_tempx_replicate(ctx
);
1153 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1155 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1156 struct r600_bc_alu alu
;
1160 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1161 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1162 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1165 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1166 alu
.dst
.sel
= ctx
->temp_reg
;
1169 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1172 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1176 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1177 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL_IEEE
);
1178 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[0]);
1181 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], 0);
1182 alu
.src
[1].sel
= ctx
->temp_reg
;
1183 alu
.dst
.sel
= ctx
->temp_reg
;
1186 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1189 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1192 /* POW(a,b) = EXP2(b * LOG2(a))*/
1193 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1194 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1195 alu
.src
[0].sel
= ctx
->temp_reg
;
1196 alu
.dst
.sel
= ctx
->temp_reg
;
1199 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1202 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1205 return tgsi_helper_tempx_replicate(ctx
);
1208 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1210 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1211 struct r600_bc_alu alu
;
1212 struct r600_bc_alu_src r600_src
[3];
1215 r
= tgsi_split_constant(ctx
, r600_src
);
1219 /* tmp = (src > 0 ? 1 : src) */
1220 for (i
= 0; i
< 4; i
++) {
1221 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1222 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1225 alu
.dst
.sel
= ctx
->temp_reg
;
1228 alu
.src
[0] = r600_src
[0];
1229 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1231 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1233 alu
.src
[2] = r600_src
[0];
1234 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], i
);
1237 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1241 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1245 /* dst = (-tmp > 0 ? -1 : tmp) */
1246 for (i
= 0; i
< 4; i
++) {
1247 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1248 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1250 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1254 alu
.src
[0].sel
= ctx
->temp_reg
;
1255 alu
.src
[0].chan
= i
;
1258 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1261 alu
.src
[2].sel
= ctx
->temp_reg
;
1262 alu
.src
[2].chan
= i
;
1266 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1273 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1275 struct r600_bc_alu alu
;
1278 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1281 for (i
= 0; i
< 4; i
++) {
1282 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1283 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1284 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
1287 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1288 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1291 alu
.src
[0].sel
= ctx
->temp_reg
;
1292 alu
.src
[0].chan
= i
;
1297 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1304 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1306 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1307 struct r600_bc_alu_src r600_src
[3];
1308 struct r600_bc_alu alu
;
1311 r
= tgsi_split_constant(ctx
, r600_src
);
1314 /* do it in 2 step as op3 doesn't support writemask */
1315 for (i
= 0; i
< 4; i
++) {
1316 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1317 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1318 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1319 alu
.src
[j
] = r600_src
[j
];
1320 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1322 alu
.dst
.sel
= ctx
->temp_reg
;
1329 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1333 return tgsi_helper_copy(ctx
, inst
);
1336 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1338 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1339 struct r600_bc_alu_src r600_src
[3];
1340 struct r600_bc_alu alu
;
1343 r
= tgsi_split_constant(ctx
, r600_src
);
1346 for (i
= 0; i
< 4; i
++) {
1347 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1348 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1349 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1350 alu
.src
[j
] = r600_src
[j
];
1351 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1353 alu
.dst
.sel
= ctx
->temp_reg
;
1356 /* handle some special cases */
1357 switch (ctx
->inst_info
->tgsi_opcode
) {
1358 case TGSI_OPCODE_DP2
:
1360 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1361 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1364 case TGSI_OPCODE_DP3
:
1366 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1367 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1370 case TGSI_OPCODE_DPH
:
1372 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1373 alu
.src
[0].chan
= 0;
1383 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1387 return tgsi_helper_copy(ctx
, inst
);
1390 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1392 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1393 struct r600_bc_tex tex
;
1394 struct r600_bc_alu alu
;
1398 boolean src_not_temp
= inst
->Src
[0].Register
.File
!= TGSI_FILE_TEMPORARY
;
1399 uint32_t lit_vals
[4];
1401 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
1403 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1404 /* Add perspective divide */
1405 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1406 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1407 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1411 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1412 alu
.dst
.sel
= ctx
->temp_reg
;
1416 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1420 for (i
= 0; i
< 3; i
++) {
1421 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1422 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1423 alu
.src
[0].sel
= ctx
->temp_reg
;
1424 alu
.src
[0].chan
= 3;
1425 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1428 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1429 alu
.dst
.sel
= ctx
->temp_reg
;
1432 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1436 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1437 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1438 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1439 alu
.src
[0].chan
= 0;
1440 alu
.dst
.sel
= ctx
->temp_reg
;
1444 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1447 src_not_temp
= FALSE
;
1448 src_gpr
= ctx
->temp_reg
;
1451 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1452 int src_chan
, src2_chan
;
1454 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
1455 for (i
= 0; i
< 4; i
++) {
1456 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1457 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
1481 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1484 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], src_chan
);
1485 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1488 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], src2_chan
);
1489 alu
.dst
.sel
= ctx
->temp_reg
;
1494 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1499 /* tmp1.z = RCP_e(|tmp1.z|) */
1500 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1501 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1502 alu
.src
[0].sel
= ctx
->temp_reg
;
1503 alu
.src
[0].chan
= 2;
1505 alu
.dst
.sel
= ctx
->temp_reg
;
1509 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1513 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
1514 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
1515 * muladd has no writemask, have to use another temp
1517 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1518 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1521 alu
.src
[0].sel
= ctx
->temp_reg
;
1522 alu
.src
[0].chan
= 0;
1523 alu
.src
[1].sel
= ctx
->temp_reg
;
1524 alu
.src
[1].chan
= 2;
1526 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1527 alu
.src
[2].chan
= 0;
1529 alu
.dst
.sel
= ctx
->temp_reg
;
1533 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1537 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1538 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1541 alu
.src
[0].sel
= ctx
->temp_reg
;
1542 alu
.src
[0].chan
= 1;
1543 alu
.src
[1].sel
= ctx
->temp_reg
;
1544 alu
.src
[1].chan
= 2;
1546 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1547 alu
.src
[2].chan
= 0;
1549 alu
.dst
.sel
= ctx
->temp_reg
;
1554 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1558 lit_vals
[0] = fui(1.5f
);
1560 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
1563 src_not_temp
= FALSE
;
1564 src_gpr
= ctx
->temp_reg
;
1568 for (i
= 0; i
< 4; i
++) {
1569 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1570 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1571 alu
.src
[0].sel
= src_gpr
;
1572 alu
.src
[0].chan
= i
;
1573 alu
.dst
.sel
= ctx
->temp_reg
;
1578 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1582 src_gpr
= ctx
->temp_reg
;
1585 opcode
= ctx
->inst_info
->r600_opcode
;
1586 if (opcode
== SQ_TEX_INST_SAMPLE
&&
1587 (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
))
1588 opcode
= SQ_TEX_INST_SAMPLE_C
;
1590 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
1592 tex
.resource_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
1593 tex
.sampler_id
= tex
.resource_id
;
1594 tex
.src_gpr
= src_gpr
;
1595 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
1605 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1612 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
1613 tex
.coord_type_x
= 1;
1614 tex
.coord_type_y
= 1;
1615 tex
.coord_type_z
= 1;
1616 tex
.coord_type_w
= 1;
1619 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
)
1622 r
= r600_bc_add_tex(ctx
->bc
, &tex
);
1626 /* add shadow ambient support - gallium doesn't do it yet */
1631 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
1633 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1634 struct r600_bc_alu_src r600_src
[3];
1635 struct r600_bc_alu alu
;
1639 r
= tgsi_split_constant(ctx
, r600_src
);
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_ADD
);
1646 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1647 alu
.src
[0].chan
= 0;
1648 alu
.src
[1] = r600_src
[0];
1649 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1651 alu
.dst
.sel
= ctx
->temp_reg
;
1657 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1661 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1665 /* (1 - src0) * src2 */
1666 for (i
= 0; i
< 4; i
++) {
1667 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1668 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1669 alu
.src
[0].sel
= ctx
->temp_reg
;
1670 alu
.src
[0].chan
= i
;
1671 alu
.src
[1] = r600_src
[2];
1672 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1673 alu
.dst
.sel
= ctx
->temp_reg
;
1679 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1683 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1687 /* src0 * src1 + (1 - src0) * src2 */
1688 for (i
= 0; i
< 4; i
++) {
1689 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1690 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1692 alu
.src
[0] = r600_src
[0];
1693 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1694 alu
.src
[1] = r600_src
[1];
1695 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
1696 alu
.src
[2].sel
= ctx
->temp_reg
;
1697 alu
.src
[2].chan
= i
;
1698 alu
.dst
.sel
= ctx
->temp_reg
;
1703 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1707 return tgsi_helper_copy(ctx
, inst
);
1710 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
1712 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1713 struct r600_bc_alu_src r600_src
[3];
1714 struct r600_bc_alu alu
;
1718 r
= tgsi_split_constant(ctx
, r600_src
);
1722 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1725 for (i
= 0; i
< 4; i
++) {
1726 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1727 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
1728 alu
.src
[0] = r600_src
[0];
1729 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1731 alu
.src
[1] = r600_src
[2];
1732 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1734 alu
.src
[2] = r600_src
[1];
1735 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[1], i
);
1738 alu
.dst
.sel
= ctx
->temp_reg
;
1740 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1749 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1754 return tgsi_helper_copy(ctx
, inst
);
1758 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
1760 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1761 struct r600_bc_alu_src r600_src
[3];
1762 struct r600_bc_alu alu
;
1763 uint32_t use_temp
= 0;
1766 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1769 r
= tgsi_split_constant(ctx
, r600_src
);
1773 for (i
= 0; i
< 4; i
++) {
1774 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1775 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1777 alu
.src
[0] = r600_src
[0];
1780 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1783 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1786 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1789 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1790 alu
.src
[0].chan
= i
;
1793 alu
.src
[1] = r600_src
[1];
1796 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1799 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1802 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1805 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1806 alu
.src
[1].chan
= i
;
1809 alu
.dst
.sel
= ctx
->temp_reg
;
1815 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1819 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1824 for (i
= 0; i
< 4; i
++) {
1825 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1826 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1828 alu
.src
[0] = r600_src
[0];
1831 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1834 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1837 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1840 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1841 alu
.src
[0].chan
= i
;
1844 alu
.src
[1] = r600_src
[1];
1847 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1850 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1853 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1856 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1857 alu
.src
[1].chan
= i
;
1860 alu
.src
[2].sel
= ctx
->temp_reg
;
1862 alu
.src
[2].chan
= i
;
1865 alu
.dst
.sel
= ctx
->temp_reg
;
1867 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1876 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1880 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1885 return tgsi_helper_copy(ctx
, inst
);
1889 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
1891 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1892 struct r600_bc_alu_src r600_src
[3];
1893 struct r600_bc_alu alu
;
1896 /* result.x = 2^floor(src); */
1897 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
1898 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1900 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
1901 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1905 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1907 alu
.dst
.sel
= ctx
->temp_reg
;
1911 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1915 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1919 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1920 alu
.src
[0].sel
= ctx
->temp_reg
;
1921 alu
.src
[0].chan
= 0;
1923 alu
.dst
.sel
= ctx
->temp_reg
;
1927 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1931 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1936 /* result.y = tmp - floor(tmp); */
1937 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
1938 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1940 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
1941 alu
.src
[0] = r600_src
[0];
1942 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1945 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1947 alu
.dst
.sel
= ctx
->temp_reg
;
1948 // r = tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
1956 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1959 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1964 /* result.z = RoughApprox2ToX(tmp);*/
1965 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
1966 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1967 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1968 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1971 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1973 alu
.dst
.sel
= ctx
->temp_reg
;
1979 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1982 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1987 /* result.w = 1.0;*/
1988 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
1989 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1991 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1992 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1993 alu
.src
[0].chan
= 0;
1995 alu
.dst
.sel
= ctx
->temp_reg
;
1999 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2002 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2006 return tgsi_helper_copy(ctx
, inst
);
2009 static int tgsi_log(struct r600_shader_ctx
*ctx
)
2011 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2012 struct r600_bc_alu alu
;
2015 /* result.x = floor(log2(src)); */
2016 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2017 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2019 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2020 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2024 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2026 alu
.dst
.sel
= ctx
->temp_reg
;
2030 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2034 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2038 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2039 alu
.src
[0].sel
= ctx
->temp_reg
;
2040 alu
.src
[0].chan
= 0;
2042 alu
.dst
.sel
= ctx
->temp_reg
;
2047 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2051 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2056 /* result.y = src.x / (2 ^ floor(log2(src.x))); */
2057 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2058 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2060 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2061 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2065 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2067 alu
.dst
.sel
= ctx
->temp_reg
;
2072 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2076 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2080 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2082 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2083 alu
.src
[0].sel
= ctx
->temp_reg
;
2084 alu
.src
[0].chan
= 1;
2086 alu
.dst
.sel
= ctx
->temp_reg
;
2091 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2095 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2099 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2101 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2102 alu
.src
[0].sel
= ctx
->temp_reg
;
2103 alu
.src
[0].chan
= 1;
2105 alu
.dst
.sel
= ctx
->temp_reg
;
2110 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2114 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2118 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2120 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2121 alu
.src
[0].sel
= ctx
->temp_reg
;
2122 alu
.src
[0].chan
= 1;
2124 alu
.dst
.sel
= ctx
->temp_reg
;
2129 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2133 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2137 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2139 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2141 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2145 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2147 alu
.src
[1].sel
= ctx
->temp_reg
;
2148 alu
.src
[1].chan
= 1;
2150 alu
.dst
.sel
= ctx
->temp_reg
;
2155 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2159 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2164 /* result.z = log2(src);*/
2165 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
2166 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2168 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2169 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2173 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2175 alu
.dst
.sel
= ctx
->temp_reg
;
2180 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2184 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2189 /* result.w = 1.0; */
2190 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
2191 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2193 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2194 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2195 alu
.src
[0].chan
= 0;
2197 alu
.dst
.sel
= ctx
->temp_reg
;
2202 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2206 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2211 return tgsi_helper_copy(ctx
, inst
);
2214 /* r6/7 only for now */
2215 static int tgsi_arl(struct r600_shader_ctx
*ctx
)
2217 /* TODO from r600c, ar values don't persist between clauses */
2218 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2219 struct r600_bc_alu alu
;
2221 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2223 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR
;
2225 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2228 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2232 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2235 ctx
->bc
->cf_last
->r6xx_uses_waterfall
= 1;
2239 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
2241 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2242 struct r600_bc_alu alu
;
2245 for (i
= 0; i
< 4; i
++) {
2246 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2248 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2249 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2253 if (i
== 0 || i
== 3) {
2254 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2256 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2259 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2262 if (i
== 0 || i
== 2) {
2263 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2265 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[1]);
2268 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
2272 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2279 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
2281 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2282 struct r600_bc_alu alu
;
2285 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2289 alu
.dst
.sel
= ctx
->temp_reg
;
2293 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2296 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2297 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2298 alu
.src
[1].chan
= 0;
2302 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
2308 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
2310 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
2311 ctx
->bc
->cf_last
->pop_count
= pops
;
2315 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
2319 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2323 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
2326 /* TOODO : for 16 vp asic should -= 2; */
2327 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2332 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
2334 if (check_max_only
) {
2347 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
2348 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2349 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2350 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
2356 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2360 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
2363 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2367 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
2368 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2369 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2370 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
2374 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
2376 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
2378 sp
->mid
= (struct r600_bc_cf
**)realloc((void *)sp
->mid
,
2379 sizeof(struct r600_bc_cf
*) * (sp
->num_mid
+ 1));
2380 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
2384 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
2387 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
2388 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
2391 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
2393 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
2405 static int emit_return(struct r600_shader_ctx
*ctx
)
2407 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
2411 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
2414 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_JUMP
);
2415 ctx
->bc
->cf_last
->pop_count
= pops
;
2416 /* TODO work out offset */
2420 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
2425 static void emit_testflag(struct r600_shader_ctx
*ctx
)
2430 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
2433 emit_jump_to_offset(ctx
, 1, 4);
2434 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
2435 pops(ctx
, ifidx
+ 1);
2439 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
2443 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2444 ctx
->bc
->cf_last
->pop_count
= 1;
2446 fc_set_mid(ctx
, fc_sp
);
2452 static int tgsi_if(struct r600_shader_ctx
*ctx
)
2454 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
2456 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
2458 fc_pushlevel(ctx
, FC_IF
);
2460 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
2464 static int tgsi_else(struct r600_shader_ctx
*ctx
)
2466 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
2467 ctx
->bc
->cf_last
->pop_count
= 1;
2469 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
2470 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
2474 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
2477 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
2478 R600_ERR("if/endif unbalanced in shader\n");
2482 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
2483 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2484 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
2486 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2490 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
2494 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
2496 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
2498 fc_pushlevel(ctx
, FC_LOOP
);
2500 /* check stack depth */
2501 callstack_check_depth(ctx
, FC_LOOP
, 0);
2505 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
2509 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
2511 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
2512 R600_ERR("loop/endloop in shader code are not paired.\n");
2516 /* fixup loop pointers - from r600isa
2517 LOOP END points to CF after LOOP START,
2518 LOOP START point to CF after LOOP END
2519 BRK/CONT point to LOOP END CF
2521 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
2523 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2525 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
2526 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
2528 /* TODO add LOOPRET support */
2530 callstack_decrease_current(ctx
, FC_LOOP
);
2534 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
2538 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
2540 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
2545 R600_ERR("Break not inside loop/endloop pair\n");
2549 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2550 ctx
->bc
->cf_last
->pop_count
= 1;
2552 fc_set_mid(ctx
, fscp
);
2555 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
2559 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
2560 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_arl
},
2561 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2562 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2565 * For state trackers other than OpenGL, we'll want to use
2566 * _RECIP_IEEE instead.
2568 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
2570 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
2571 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2572 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
2573 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2574 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2575 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2576 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2577 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2578 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2579 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2580 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2581 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2582 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2583 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2584 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2585 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2587 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2588 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2590 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2591 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2592 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2593 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2594 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2595 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2596 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2597 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2598 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2599 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2601 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2602 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2603 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2604 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2605 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2606 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2607 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2608 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
2609 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2610 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2611 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2612 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2613 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2614 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
2615 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2616 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
2617 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
2618 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
2619 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
2620 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2621 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2622 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2623 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2624 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2625 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2626 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2627 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2628 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2629 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2630 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2631 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2632 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2633 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2634 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
2635 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
2636 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
2637 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2638 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2639 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2640 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2641 {TGSI_OPCODE_TXL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2642 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
2643 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
2645 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2646 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2647 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
2648 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
2650 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2651 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2652 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2653 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2654 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2655 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2656 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2657 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
2658 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2660 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2661 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2662 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2663 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2664 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2665 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2666 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2667 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2668 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
2669 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2670 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2671 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
2672 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2673 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
2674 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2676 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2677 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2678 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2679 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2680 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2682 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2683 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2684 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2685 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2686 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2687 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2688 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2689 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2690 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
2691 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
2693 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2694 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2695 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2696 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2697 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2698 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2699 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2700 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2701 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2702 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2703 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2704 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2705 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2706 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2707 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2708 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2709 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2710 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2711 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2712 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2713 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2714 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2715 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2716 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2717 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2718 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2719 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2720 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2723 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
2724 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2725 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2726 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2727 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
2728 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
2729 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2730 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2731 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2732 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2733 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2734 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2735 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2736 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2737 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2738 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2739 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2740 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2741 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2742 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2743 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2745 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2746 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2748 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2749 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2750 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2751 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2752 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2753 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2754 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2755 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2756 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2757 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2759 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2760 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2761 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2762 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2763 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2764 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2765 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2766 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
2767 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2768 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2769 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2770 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2771 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2772 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
2773 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2774 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
2775 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
2776 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
2777 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
2778 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2779 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2780 {TGSI_OPCODE_TXD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2781 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2782 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2783 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2784 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2785 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2786 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2787 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2788 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2789 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2790 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2791 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2792 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
2793 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
2794 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
2795 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2796 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2797 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2798 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2799 {TGSI_OPCODE_TXL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2800 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
2801 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
2803 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2804 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2805 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
2806 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
2808 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2809 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2810 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2811 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2812 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2813 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2814 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2815 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
2816 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2818 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2819 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2820 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2821 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2822 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2823 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2824 {TGSI_OPCODE_TXF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2825 {TGSI_OPCODE_TXQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2826 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
2827 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2828 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2829 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
2830 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2831 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
2832 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2834 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2835 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2836 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2837 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2838 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2840 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2841 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2842 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2843 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2844 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2845 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2846 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2847 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2848 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
2849 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
2851 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2852 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2853 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2854 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2855 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2856 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2857 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2858 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2859 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2860 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2861 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2862 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2863 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2864 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2865 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2866 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2867 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2868 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2869 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2870 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2871 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2872 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2873 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2874 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2875 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2876 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2877 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2878 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},