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"
38 struct r600_shader_tgsi_instruction
;
40 struct r600_shader_ctx
{
41 struct tgsi_shader_info info
;
42 struct tgsi_parse_context parse
;
43 const struct tgsi_token
*tokens
;
45 unsigned file_offset
[TGSI_FILE_COUNT
];
47 struct r600_shader_tgsi_instruction
*inst_info
;
49 struct r600_shader
*shader
;
53 struct r600_shader_tgsi_instruction
{
57 int (*process
)(struct r600_shader_ctx
*ctx
);
60 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[];
61 static int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
);
63 static int r600_shader_update(struct pipe_context
*ctx
, struct r600_shader
*shader
)
65 struct r600_context
*rctx
= r600_context(ctx
);
66 const struct util_format_description
*desc
;
67 enum pipe_format resource_format
[160];
68 unsigned i
, nresources
= 0;
69 struct r600_bc
*bc
= &shader
->bc
;
70 struct r600_bc_cf
*cf
;
71 struct r600_bc_vtx
*vtx
;
73 if (shader
->processor_type
!= TGSI_PROCESSOR_VERTEX
)
75 for (i
= 0; i
< rctx
->vertex_elements
->count
; i
++) {
76 resource_format
[nresources
++] = rctx
->vertex_elements
->elements
[i
].src_format
;
78 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
80 case V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
81 case V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC
:
82 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
83 desc
= util_format_description(resource_format
[vtx
->buffer_id
]);
85 R600_ERR("unknown format %d\n", resource_format
[vtx
->buffer_id
]);
88 vtx
->dst_sel_x
= desc
->swizzle
[0];
89 vtx
->dst_sel_y
= desc
->swizzle
[1];
90 vtx
->dst_sel_z
= desc
->swizzle
[2];
91 vtx
->dst_sel_w
= desc
->swizzle
[3];
98 return r600_bc_build(&shader
->bc
);
101 int r600_pipe_shader_create(struct pipe_context
*ctx
,
102 struct r600_context_state
*rpshader
,
103 const struct tgsi_token
*tokens
)
105 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
108 //fprintf(stderr, "--------------------------------------------------------------\n");
109 //tgsi_dump(tokens, 0);
110 if (rpshader
== NULL
)
112 rpshader
->shader
.family
= radeon_get_family(rscreen
->rw
);
113 r
= r600_shader_from_tgsi(tokens
, &rpshader
->shader
);
115 R600_ERR("translation from TGSI failed !\n");
118 r
= r600_bc_build(&rpshader
->shader
.bc
);
120 R600_ERR("building bytecode failed !\n");
123 //fprintf(stderr, "______________________________________________________________\n");
127 static int r600_pipe_shader_vs(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
129 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
130 struct r600_shader
*rshader
= &rpshader
->shader
;
131 struct radeon_state
*state
;
134 rpshader
->rstate
= radeon_state_decref(rpshader
->rstate
);
135 state
= radeon_state(rscreen
->rw
, R600_VS_SHADER_TYPE
, R600_VS_SHADER
);
138 for (i
= 0; i
< 10; i
++) {
139 state
->states
[R600_VS_SHADER__SPI_VS_OUT_ID_0
+ i
] = 0;
141 /* so far never got proper semantic id from tgsi */
142 for (i
= 0; i
< 32; i
++) {
143 tmp
= i
<< ((i
& 3) * 8);
144 state
->states
[R600_VS_SHADER__SPI_VS_OUT_ID_0
+ i
/ 4] |= tmp
;
146 state
->states
[R600_VS_SHADER__SPI_VS_OUT_CONFIG
] = S_0286C4_VS_EXPORT_COUNT(rshader
->noutput
- 2);
147 state
->states
[R600_VS_SHADER__SQ_PGM_RESOURCES_VS
] = S_028868_NUM_GPRS(rshader
->bc
.ngpr
);
148 rpshader
->rstate
= state
;
149 rpshader
->rstate
->bo
[0] = radeon_bo_incref(rscreen
->rw
, rpshader
->bo
);
150 rpshader
->rstate
->bo
[1] = radeon_bo_incref(rscreen
->rw
, rpshader
->bo
);
151 rpshader
->rstate
->nbo
= 2;
152 rpshader
->rstate
->placement
[0] = RADEON_GEM_DOMAIN_GTT
;
153 return radeon_state_pm4(state
);
156 static int r600_pipe_shader_ps(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
158 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
159 struct r600_shader
*rshader
= &rpshader
->shader
;
160 struct radeon_state
*state
;
161 unsigned i
, tmp
, exports_ps
, num_cout
;
163 rpshader
->rstate
= radeon_state_decref(rpshader
->rstate
);
164 state
= radeon_state(rscreen
->rw
, R600_PS_SHADER_TYPE
, R600_PS_SHADER
);
167 for (i
= 0; i
< rshader
->ninput
; i
++) {
168 tmp
= S_028644_SEMANTIC(i
);
169 tmp
|= S_028644_SEL_CENTROID(1);
170 if (rshader
->input
[i
].name
== TGSI_SEMANTIC_COLOR
||
171 rshader
->input
[i
].name
== TGSI_SEMANTIC_BCOLOR
) {
172 tmp
|= S_028644_FLAT_SHADE(rshader
->flat_shade
);
174 state
->states
[R600_PS_SHADER__SPI_PS_INPUT_CNTL_0
+ i
] = tmp
;
179 for (i
= 0; i
< rshader
->noutput
; i
++) {
180 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
)
182 else if (rshader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
183 exports_ps
|= (1 << (num_cout
+1));
187 state
->states
[R600_PS_SHADER__SPI_PS_IN_CONTROL_0
] = S_0286CC_NUM_INTERP(rshader
->ninput
) |
188 S_0286CC_PERSP_GRADIENT_ENA(1);
189 state
->states
[R600_PS_SHADER__SPI_PS_IN_CONTROL_1
] = 0x00000000;
190 state
->states
[R600_PS_SHADER__SQ_PGM_RESOURCES_PS
] = S_028868_NUM_GPRS(rshader
->bc
.ngpr
);
191 state
->states
[R600_PS_SHADER__SQ_PGM_EXPORTS_PS
] = exports_ps
;
192 rpshader
->rstate
= state
;
193 rpshader
->rstate
->bo
[0] = radeon_bo_incref(rscreen
->rw
, rpshader
->bo
);
194 rpshader
->rstate
->nbo
= 1;
195 rpshader
->rstate
->placement
[0] = RADEON_GEM_DOMAIN_GTT
;
196 return radeon_state_pm4(state
);
199 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
201 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
202 struct r600_context
*rctx
= r600_context(ctx
);
203 struct r600_shader
*rshader
= &rpshader
->shader
;
206 /* copy new shader */
207 radeon_bo_decref(rscreen
->rw
, rpshader
->bo
);
209 rpshader
->bo
= radeon_bo(rscreen
->rw
, 0, rshader
->bc
.ndw
* 4,
211 if (rpshader
->bo
== NULL
) {
214 radeon_bo_map(rscreen
->rw
, rpshader
->bo
);
215 memcpy(rpshader
->bo
->data
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* 4);
216 radeon_bo_unmap(rscreen
->rw
, rpshader
->bo
);
218 rshader
->flat_shade
= rctx
->flat_shade
;
219 switch (rshader
->processor_type
) {
220 case TGSI_PROCESSOR_VERTEX
:
221 r
= r600_pipe_shader_vs(ctx
, rpshader
);
223 case TGSI_PROCESSOR_FRAGMENT
:
224 r
= r600_pipe_shader_ps(ctx
, rpshader
);
233 int r600_pipe_shader_update(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
235 struct r600_context
*rctx
= r600_context(ctx
);
238 if (rpshader
== NULL
)
240 /* there should be enough input */
241 if (rctx
->vertex_elements
->count
< rpshader
->shader
.bc
.nresource
) {
242 R600_ERR("%d resources provided, expecting %d\n",
243 rctx
->vertex_elements
->count
, rpshader
->shader
.bc
.nresource
);
246 r
= r600_shader_update(ctx
, &rpshader
->shader
);
249 return r600_pipe_shader(ctx
, rpshader
);
252 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
254 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
257 if (i
->Instruction
.NumDstRegs
> 1) {
258 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
261 if (i
->Instruction
.Predicate
) {
262 R600_ERR("predicate unsupported\n");
265 if (i
->Instruction
.Label
) {
266 R600_ERR("label unsupported\n");
269 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
270 if (i
->Src
[j
].Register
.Indirect
||
271 i
->Src
[j
].Register
.Dimension
||
272 i
->Src
[j
].Register
.Absolute
) {
273 R600_ERR("unsupported src (indirect|dimension|absolute)\n");
277 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
278 if (i
->Dst
[j
].Register
.Indirect
|| i
->Dst
[j
].Register
.Dimension
) {
279 R600_ERR("unsupported dst (indirect|dimension)\n");
286 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
288 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
289 struct r600_bc_vtx vtx
;
293 switch (d
->Declaration
.File
) {
294 case TGSI_FILE_INPUT
:
295 i
= ctx
->shader
->ninput
++;
296 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
297 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
298 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
299 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + i
;
300 if (ctx
->type
== TGSI_PROCESSOR_VERTEX
) {
301 /* turn input into fetch */
302 memset(&vtx
, 0, sizeof(struct r600_bc_vtx
));
306 /* register containing the index into the buffer */
309 vtx
.mega_fetch_count
= 0x1F;
310 vtx
.dst_gpr
= ctx
->shader
->input
[i
].gpr
;
315 r
= r600_bc_add_vtx(ctx
->bc
, &vtx
);
320 case TGSI_FILE_OUTPUT
:
321 i
= ctx
->shader
->noutput
++;
322 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
323 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
324 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + i
;
325 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
327 case TGSI_FILE_CONSTANT
:
328 case TGSI_FILE_TEMPORARY
:
329 case TGSI_FILE_SAMPLER
:
332 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
338 int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
)
340 struct tgsi_full_immediate
*immediate
;
341 struct r600_shader_ctx ctx
;
342 struct r600_bc_output output
[32];
343 unsigned output_done
;
347 ctx
.bc
= &shader
->bc
;
349 r
= r600_bc_init(ctx
.bc
, shader
->family
);
353 tgsi_scan_shader(tokens
, &ctx
.info
);
354 tgsi_parse_init(&ctx
.parse
, tokens
);
355 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
356 shader
->processor_type
= ctx
.type
;
358 /* register allocations */
359 /* Values [0,127] correspond to GPR[0..127].
360 * Values [256,511] correspond to cfile constants c[0..255].
361 * Other special values are shown in the list below.
362 * 248 SQ_ALU_SRC_0: special constant 0.0.
363 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
364 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
365 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
366 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
367 * 253 SQ_ALU_SRC_LITERAL: literal constant.
368 * 254 SQ_ALU_SRC_PV: previous vector result.
369 * 255 SQ_ALU_SRC_PS: previous scalar result.
371 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
372 ctx
.file_offset
[i
] = 0;
374 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
375 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
377 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
378 ctx
.info
.file_count
[TGSI_FILE_INPUT
];
379 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
380 ctx
.info
.file_count
[TGSI_FILE_OUTPUT
];
381 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 256;
382 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = 253;
383 ctx
.temp_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
384 ctx
.info
.file_count
[TGSI_FILE_TEMPORARY
];
386 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
387 tgsi_parse_token(&ctx
.parse
);
388 switch (ctx
.parse
.FullToken
.Token
.Type
) {
389 case TGSI_TOKEN_TYPE_IMMEDIATE
:
390 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
391 ctx
.value
[0] = immediate
->u
[0].Uint
;
392 ctx
.value
[1] = immediate
->u
[1].Uint
;
393 ctx
.value
[2] = immediate
->u
[2].Uint
;
394 ctx
.value
[3] = immediate
->u
[3].Uint
;
396 case TGSI_TOKEN_TYPE_DECLARATION
:
397 r
= tgsi_declaration(&ctx
);
401 case TGSI_TOKEN_TYPE_INSTRUCTION
:
402 r
= tgsi_is_supported(&ctx
);
405 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
406 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
407 r
= ctx
.inst_info
->process(&ctx
);
410 r
= r600_bc_add_literal(ctx
.bc
, ctx
.value
);
415 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
421 for (i
= 0, pos0
= 0; i
< shader
->noutput
; i
++) {
422 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
423 output
[i
].gpr
= shader
->output
[i
].gpr
;
424 output
[i
].elem_size
= 3;
425 output
[i
].swizzle_x
= 0;
426 output
[i
].swizzle_y
= 1;
427 output
[i
].swizzle_z
= 2;
428 output
[i
].swizzle_w
= 3;
429 output
[i
].barrier
= 1;
430 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
431 output
[i
].array_base
= i
- pos0
;
432 output
[i
].inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
;
433 switch (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
434 case TGSI_PROCESSOR_VERTEX
:
435 if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
436 output
[i
].array_base
= 60;
437 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
438 /* position doesn't count in array_base */
442 case TGSI_PROCESSOR_FRAGMENT
:
443 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
444 output
[i
].array_base
= shader
->output
[i
].sid
;
445 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
446 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
447 output
[i
].array_base
= 61;
448 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
450 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
456 R600_ERR("unsupported processor type %d\n", ctx
.type
);
460 if (i
== (shader
->noutput
- 1)) {
461 output
[i
].end_of_program
= 1;
464 for (i
= shader
->noutput
- 1, output_done
= 0; i
>= 0; i
--) {
465 if (!(output_done
& (1 << output
[i
].type
))) {
466 output_done
|= (1 << output
[i
].type
);
467 output
[i
].inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
;
470 for (i
= 0; i
< shader
->noutput
; i
++) {
471 r
= r600_bc_add_output(ctx
.bc
, &output
[i
]);
475 tgsi_parse_free(&ctx
.parse
);
478 tgsi_parse_free(&ctx
.parse
);
482 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
484 R600_ERR("%d tgsi opcode unsupported\n", ctx
->inst_info
->tgsi_opcode
);
488 static int tgsi_end(struct r600_shader_ctx
*ctx
)
493 static int tgsi_src(struct r600_shader_ctx
*ctx
,
494 const struct tgsi_full_src_register
*tgsi_src
,
495 struct r600_bc_alu_src
*r600_src
)
497 memset(r600_src
, 0, sizeof(struct r600_bc_alu_src
));
498 r600_src
->sel
= tgsi_src
->Register
.Index
;
499 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
502 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
506 static int tgsi_dst(struct r600_shader_ctx
*ctx
,
507 const struct tgsi_full_dst_register
*tgsi_dst
,
509 struct r600_bc_alu_dst
*r600_dst
)
511 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
513 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
514 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
515 r600_dst
->chan
= swizzle
;
517 if (inst
->Instruction
.Saturate
) {
523 static unsigned tgsi_chan(const struct tgsi_full_src_register
*tgsi_src
, unsigned swizzle
)
527 return tgsi_src
->Register
.SwizzleX
;
529 return tgsi_src
->Register
.SwizzleY
;
531 return tgsi_src
->Register
.SwizzleZ
;
533 return tgsi_src
->Register
.SwizzleW
;
539 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
541 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
542 struct r600_bc_alu alu
;
543 int i
, j
, k
, nconst
, r
;
545 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
546 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
549 r
= tgsi_src(ctx
, &inst
->Src
[i
], &r600_src
[i
]);
554 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
555 if (inst
->Src
[j
].Register
.File
== TGSI_FILE_CONSTANT
&& j
> 0) {
556 for (k
= 0; k
< 4; k
++) {
557 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
558 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
559 alu
.src
[0].sel
= r600_src
[0].sel
;
561 alu
.dst
.sel
= ctx
->temp_reg
+ j
;
566 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
570 r600_src
[0].sel
= ctx
->temp_reg
+ j
;
577 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
579 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
580 struct r600_bc_alu_src r600_src
[3];
581 struct r600_bc_alu alu
;
584 r
= tgsi_split_constant(ctx
, r600_src
);
587 for (i
= 0; i
< 4; i
++) {
588 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
589 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
590 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
;
593 alu
.inst
= ctx
->inst_info
->r600_opcode
;
594 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
595 alu
.src
[j
] = r600_src
[j
];
596 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
598 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
602 /* handle some special cases */
603 switch (ctx
->inst_info
->tgsi_opcode
) {
604 case TGSI_OPCODE_SUB
:
607 case TGSI_OPCODE_ABS
:
616 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
623 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
625 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
626 struct r600_bc_alu alu
;
629 for (i
= 0; i
< 4; i
++) {
630 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
631 alu
.inst
= ctx
->inst_info
->r600_opcode
;
633 alu
.src
[0].sel
= 248;
634 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
637 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
641 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
648 static int tgsi_slt(struct r600_shader_ctx
*ctx
)
650 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
651 struct r600_bc_alu_src r600_src
[3];
652 struct r600_bc_alu alu
;
655 r
= tgsi_split_constant(ctx
, r600_src
);
658 for (i
= 0; i
< 4; i
++) {
659 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
660 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
661 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
;
664 alu
.inst
= ctx
->inst_info
->r600_opcode
;
665 alu
.src
[1] = r600_src
[0];
666 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
667 alu
.src
[0] = r600_src
[1];
668 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], i
);
669 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
676 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
683 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
685 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
686 struct r600_bc_alu alu
;
690 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
691 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
692 alu
.src
[0].sel
= 249; /*1.0*/
694 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
697 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
698 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
702 /* dst.y = max(src.x, 0.0) */
703 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
704 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
;
705 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
708 alu
.src
[1].sel
= 248; /*0.0*/
709 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], 0);
710 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
713 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
714 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
718 /* dst.z = NOP - fill Z slot */
719 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
720 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
;
722 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
727 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
728 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
729 alu
.src
[0].sel
= 249;
731 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
734 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
736 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
740 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
745 /* dst.z = log(src.y) */
746 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
747 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
;
748 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
751 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
752 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
756 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
763 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
764 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
765 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
;
766 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
769 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
770 alu
.src
[1].sel
= sel
;
771 alu
.src
[1].chan
= chan
;
772 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[2]);
775 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], 0);
776 alu
.dst
.sel
= ctx
->temp_reg
;
781 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
785 /* dst.z = exp(tmp.x) */
786 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
787 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
;
788 alu
.src
[0].sel
= ctx
->temp_reg
;
790 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
794 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
801 static int tgsi_trans(struct r600_shader_ctx
*ctx
)
803 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
804 struct r600_bc_alu alu
;
807 for (i
= 0; i
< 4; i
++) {
808 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
809 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
810 alu
.inst
= ctx
->inst_info
->r600_opcode
;
811 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
812 r
= tgsi_src(ctx
, &inst
->Src
[j
], &alu
.src
[j
]);
815 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
817 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
821 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
829 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
831 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
832 struct r600_bc_alu alu
;
835 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
836 alu
.inst
= ctx
->inst_info
->r600_opcode
;
837 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
838 r
= tgsi_src(ctx
, &inst
->Src
[j
], &alu
.src
[j
]);
841 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], 0);
843 alu
.dst
.sel
= ctx
->temp_reg
;
846 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
849 /* replicate result */
850 for (i
= 0; i
< 4; i
++) {
851 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
852 alu
.src
[0].sel
= ctx
->temp_reg
;
853 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
855 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
858 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
861 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
868 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
870 struct r600_bc_alu alu
;
873 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
876 for (i
= 0; i
< 4; i
++) {
877 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
878 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
879 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
;
882 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
883 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
886 alu
.src
[0].sel
= ctx
->temp_reg
;
892 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
899 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
901 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
902 struct r600_bc_alu_src r600_src
[3];
903 struct r600_bc_alu alu
;
906 r
= tgsi_split_constant(ctx
, r600_src
);
909 /* do it in 2 step as op3 doesn't support writemask */
910 for (i
= 0; i
< 4; i
++) {
911 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
912 alu
.inst
= ctx
->inst_info
->r600_opcode
;
913 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
914 alu
.src
[j
] = r600_src
[j
];
915 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
917 alu
.dst
.sel
= ctx
->temp_reg
;
924 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
928 return tgsi_helper_copy(ctx
, inst
);
931 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
933 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
934 struct r600_bc_alu_src r600_src
[3];
935 struct r600_bc_alu alu
;
938 r
= tgsi_split_constant(ctx
, r600_src
);
941 for (i
= 0; i
< 4; i
++) {
942 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
943 alu
.inst
= ctx
->inst_info
->r600_opcode
;
944 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
945 alu
.src
[j
] = r600_src
[j
];
946 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
948 alu
.dst
.sel
= ctx
->temp_reg
;
951 /* handle some special cases */
952 switch (ctx
->inst_info
->tgsi_opcode
) {
953 case TGSI_OPCODE_DP2
:
955 alu
.src
[0].sel
= alu
.src
[1].sel
= 248;
956 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
959 case TGSI_OPCODE_DP3
:
961 alu
.src
[0].sel
= alu
.src
[1].sel
= 248;
962 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
971 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
975 return tgsi_helper_copy(ctx
, inst
);
978 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
980 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
981 struct r600_bc_tex tex
;
982 struct r600_bc_alu alu
;
986 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
988 /* Add perspective divide */
989 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
990 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
;
991 alu
.src
[0].sel
= src_gpr
;
992 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
993 alu
.dst
.sel
= ctx
->temp_reg
;
997 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1001 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1002 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
;
1003 alu
.src
[0].sel
= ctx
->temp_reg
;
1004 alu
.src
[0].chan
= 3;
1005 alu
.src
[1].sel
= src_gpr
;
1006 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], 0);
1007 alu
.dst
.sel
= ctx
->temp_reg
;
1010 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1013 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1014 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
;
1015 alu
.src
[0].sel
= ctx
->temp_reg
;
1016 alu
.src
[0].chan
= 3;
1017 alu
.src
[1].sel
= src_gpr
;
1018 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], 1);
1019 alu
.dst
.sel
= ctx
->temp_reg
;
1022 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1025 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1026 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
;
1027 alu
.src
[0].sel
= ctx
->temp_reg
;
1028 alu
.src
[0].chan
= 3;
1029 alu
.src
[1].sel
= src_gpr
;
1030 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], 2);
1031 alu
.dst
.sel
= ctx
->temp_reg
;
1034 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1037 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1038 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
1039 alu
.src
[0].sel
= 249;
1040 alu
.src
[0].chan
= 0;
1041 alu
.dst
.sel
= ctx
->temp_reg
;
1045 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1048 src_gpr
= ctx
->temp_reg
;
1050 /* TODO use temp if src_gpr is not a temporary reg (File != TEMPORARY) */
1051 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
1052 tex
.inst
= ctx
->inst_info
->r600_opcode
;
1053 tex
.resource_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
1054 tex
.sampler_id
= tex
.resource_id
;
1055 tex
.src_gpr
= src_gpr
;
1056 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
1066 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
1067 tex
.coord_type_x
= 1;
1068 tex
.coord_type_y
= 1;
1069 tex
.coord_type_z
= 1;
1070 tex
.coord_type_w
= 1;
1072 return r600_bc_add_tex(ctx
->bc
, &tex
);
1075 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
1077 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1078 struct r600_bc_alu_src r600_src
[3];
1079 struct r600_bc_alu alu
;
1083 r
= tgsi_split_constant(ctx
, r600_src
);
1087 for (i
= 0; i
< 4; i
++) {
1088 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1089 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
;
1090 alu
.src
[0].sel
= 249;
1091 alu
.src
[0].chan
= 0;
1092 alu
.src
[1] = r600_src
[0];
1093 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1095 alu
.dst
.sel
= ctx
->temp_reg
;
1101 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1105 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1109 /* (1 - src0) * src2 */
1110 for (i
= 0; i
< 4; i
++) {
1111 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1112 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
;
1113 alu
.src
[0].sel
= ctx
->temp_reg
;
1114 alu
.src
[0].chan
= i
;
1115 alu
.src
[1] = r600_src
[2];
1116 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1117 alu
.dst
.sel
= ctx
->temp_reg
;
1123 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1127 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1131 /* src0 * src1 + (1 - src0) * src2 */
1132 for (i
= 0; i
< 4; i
++) {
1133 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1134 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
;
1136 alu
.src
[0] = r600_src
[0];
1137 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1138 alu
.src
[1] = r600_src
[1];
1139 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
1140 alu
.src
[2].sel
= ctx
->temp_reg
;
1141 alu
.src
[2].chan
= i
;
1142 alu
.dst
.sel
= ctx
->temp_reg
;
1147 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1151 return tgsi_helper_copy(ctx
, inst
);
1154 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
1155 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1156 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
1157 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
1158 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
1159 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
1160 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1161 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1162 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
1163 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
1164 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
1165 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
1166 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1167 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
1168 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
1169 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_slt
},
1170 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1171 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
1172 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
1173 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
1174 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1176 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1177 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1179 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1180 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1181 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1182 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1183 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1184 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1185 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
1186 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1187 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1188 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1190 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1191 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
1192 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1193 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1194 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1195 {TGSI_OPCODE_DDX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1196 {TGSI_OPCODE_DDY
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1197 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
}, /* predicated kill */
1198 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1199 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1200 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1201 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1202 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1203 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1204 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1205 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1206 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1207 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1208 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1209 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1210 {TGSI_OPCODE_TEX
, 0, 0x10, tgsi_tex
},
1211 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1212 {TGSI_OPCODE_TXP
, 0, 0x10, tgsi_tex
},
1213 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1214 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1215 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1216 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1217 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1218 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1219 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1220 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1221 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1222 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1223 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
}, /* SGN */
1224 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1225 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1226 {TGSI_OPCODE_TXB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1227 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1228 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1229 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
1230 {TGSI_OPCODE_TXL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1231 {TGSI_OPCODE_BRK
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1232 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1234 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1235 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1236 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1237 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1239 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1240 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1241 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1242 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1243 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1244 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1245 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1246 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1247 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1249 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1250 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1251 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1252 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1253 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1254 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1255 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1256 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1257 {TGSI_OPCODE_CONT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1258 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1259 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1260 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1261 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1262 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1263 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1265 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1266 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1267 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1268 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1269 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1271 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1272 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1273 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1274 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1275 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1276 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1277 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1278 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1279 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
1280 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
1282 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1283 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1284 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1285 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1286 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1287 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1288 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1289 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1290 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1291 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1292 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1293 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1294 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1295 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1296 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1297 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1298 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1299 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1300 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1301 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1302 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1303 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1304 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1305 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1306 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1307 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1308 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1309 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},