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
);
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 rpshader
->rstate
->placement
[2] = RADEON_GEM_DOMAIN_GTT
;
154 state
->reloc_pm4_id
[0] = R600_VS_SHADER__SQ_PGM_START_VS_BO_ID
;
155 state
->reloc_pm4_id
[1] = R600_VS_SHADER__SQ_PGM_START_FS_BO_ID
;
156 return radeon_state_pm4(state
);
159 static int r600_pipe_shader_ps(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
161 const struct pipe_rasterizer_state
*rasterizer
;
162 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
163 struct r600_shader
*rshader
= &rpshader
->shader
;
164 struct r600_context
*rctx
= r600_context(ctx
);
165 struct radeon_state
*state
;
166 unsigned i
, tmp
, exports_ps
, num_cout
;
168 rasterizer
= &rctx
->rasterizer
->state
.rasterizer
;
169 rpshader
->rstate
= radeon_state_decref(rpshader
->rstate
);
170 state
= radeon_state(rscreen
->rw
, R600_PS_SHADER
);
173 for (i
= 0; i
< rshader
->ninput
; i
++) {
174 tmp
= S_028644_SEMANTIC(i
);
175 tmp
|= S_028644_SEL_CENTROID(1);
176 if (rshader
->input
[i
].name
== TGSI_SEMANTIC_COLOR
||
177 rshader
->input
[i
].name
== TGSI_SEMANTIC_BCOLOR
) {
178 tmp
|= S_028644_FLAT_SHADE(rshader
->flat_shade
);
180 if (rasterizer
->sprite_coord_enable
& (1 << i
)) {
181 tmp
|= S_028644_PT_SPRITE_TEX(1);
183 state
->states
[R600_PS_SHADER__SPI_PS_INPUT_CNTL_0
+ i
] = tmp
;
188 for (i
= 0; i
< rshader
->noutput
; i
++) {
189 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
)
191 else if (rshader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
192 exports_ps
|= (1 << (num_cout
+1));
197 /* always at least export 1 component per pixel */
200 state
->states
[R600_PS_SHADER__SPI_PS_IN_CONTROL_0
] = S_0286CC_NUM_INTERP(rshader
->ninput
) |
201 S_0286CC_PERSP_GRADIENT_ENA(1);
202 state
->states
[R600_PS_SHADER__SPI_PS_IN_CONTROL_1
] = 0x00000000;
203 state
->states
[R600_PS_SHADER__SQ_PGM_RESOURCES_PS
] = S_028868_NUM_GPRS(rshader
->bc
.ngpr
);
204 state
->states
[R600_PS_SHADER__SQ_PGM_EXPORTS_PS
] = exports_ps
;
205 rpshader
->rstate
= state
;
206 rpshader
->rstate
->bo
[0] = radeon_bo_incref(rscreen
->rw
, rpshader
->bo
);
207 rpshader
->rstate
->nbo
= 1;
208 rpshader
->rstate
->placement
[0] = RADEON_GEM_DOMAIN_GTT
;
209 state
->reloc_pm4_id
[0] = R600_PS_SHADER__SQ_PGM_START_PS_BO_ID
;
210 return radeon_state_pm4(state
);
213 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
215 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
216 struct r600_context
*rctx
= r600_context(ctx
);
217 struct r600_shader
*rshader
= &rpshader
->shader
;
220 /* copy new shader */
221 radeon_bo_decref(rscreen
->rw
, rpshader
->bo
);
223 rpshader
->bo
= radeon_bo(rscreen
->rw
, 0, rshader
->bc
.ndw
* 4,
225 if (rpshader
->bo
== NULL
) {
228 radeon_bo_map(rscreen
->rw
, rpshader
->bo
);
229 memcpy(rpshader
->bo
->data
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* 4);
230 radeon_bo_unmap(rscreen
->rw
, rpshader
->bo
);
232 rshader
->flat_shade
= rctx
->flat_shade
;
233 switch (rshader
->processor_type
) {
234 case TGSI_PROCESSOR_VERTEX
:
235 r
= r600_pipe_shader_vs(ctx
, rpshader
);
237 case TGSI_PROCESSOR_FRAGMENT
:
238 r
= r600_pipe_shader_ps(ctx
, rpshader
);
247 int r600_pipe_shader_update(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
249 struct r600_context
*rctx
= r600_context(ctx
);
252 if (rpshader
== NULL
)
254 /* there should be enough input */
255 if (rctx
->vertex_elements
->count
< rpshader
->shader
.bc
.nresource
) {
256 R600_ERR("%d resources provided, expecting %d\n",
257 rctx
->vertex_elements
->count
, rpshader
->shader
.bc
.nresource
);
260 r
= r600_shader_update(ctx
, &rpshader
->shader
);
263 return r600_pipe_shader(ctx
, rpshader
);
266 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
268 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
271 if (i
->Instruction
.NumDstRegs
> 1) {
272 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
275 if (i
->Instruction
.Predicate
) {
276 R600_ERR("predicate unsupported\n");
279 if (i
->Instruction
.Label
) {
280 R600_ERR("label unsupported\n");
283 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
284 if (i
->Src
[j
].Register
.Indirect
||
285 i
->Src
[j
].Register
.Dimension
||
286 i
->Src
[j
].Register
.Absolute
) {
287 R600_ERR("unsupported src (indirect|dimension|absolute)\n");
291 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
292 if (i
->Dst
[j
].Register
.Indirect
|| i
->Dst
[j
].Register
.Dimension
) {
293 R600_ERR("unsupported dst (indirect|dimension)\n");
300 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
302 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
303 struct r600_bc_vtx vtx
;
307 switch (d
->Declaration
.File
) {
308 case TGSI_FILE_INPUT
:
309 i
= ctx
->shader
->ninput
++;
310 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
311 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
312 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
313 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + i
;
314 if (ctx
->type
== TGSI_PROCESSOR_VERTEX
) {
315 /* turn input into fetch */
316 memset(&vtx
, 0, sizeof(struct r600_bc_vtx
));
320 /* register containing the index into the buffer */
323 vtx
.mega_fetch_count
= 0x1F;
324 vtx
.dst_gpr
= ctx
->shader
->input
[i
].gpr
;
329 r
= r600_bc_add_vtx(ctx
->bc
, &vtx
);
334 case TGSI_FILE_OUTPUT
:
335 i
= ctx
->shader
->noutput
++;
336 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
337 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
338 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + i
;
339 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
341 case TGSI_FILE_CONSTANT
:
342 case TGSI_FILE_TEMPORARY
:
343 case TGSI_FILE_SAMPLER
:
346 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
352 int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
)
354 struct tgsi_full_immediate
*immediate
;
355 struct r600_shader_ctx ctx
;
356 struct r600_bc_output output
[32];
357 unsigned output_done
, noutput
;
361 ctx
.bc
= &shader
->bc
;
363 r
= r600_bc_init(ctx
.bc
, shader
->family
);
367 tgsi_scan_shader(tokens
, &ctx
.info
);
368 tgsi_parse_init(&ctx
.parse
, tokens
);
369 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
370 shader
->processor_type
= ctx
.type
;
372 /* register allocations */
373 /* Values [0,127] correspond to GPR[0..127].
374 * Values [128,159] correspond to constant buffer bank 0
375 * Values [160,191] correspond to constant buffer bank 1
376 * Values [256,511] correspond to cfile constants c[0..255].
377 * Other special values are shown in the list below.
378 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
379 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
380 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
381 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
382 * 248 SQ_ALU_SRC_0: special constant 0.0.
383 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
384 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
385 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
386 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
387 * 253 SQ_ALU_SRC_LITERAL: literal constant.
388 * 254 SQ_ALU_SRC_PV: previous vector result.
389 * 255 SQ_ALU_SRC_PS: previous scalar result.
391 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
392 ctx
.file_offset
[i
] = 0;
394 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
395 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
397 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
398 ctx
.info
.file_count
[TGSI_FILE_INPUT
];
399 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
400 ctx
.info
.file_count
[TGSI_FILE_OUTPUT
];
401 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 256;
402 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = 253;
403 ctx
.temp_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
404 ctx
.info
.file_count
[TGSI_FILE_TEMPORARY
];
406 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
407 tgsi_parse_token(&ctx
.parse
);
408 switch (ctx
.parse
.FullToken
.Token
.Type
) {
409 case TGSI_TOKEN_TYPE_IMMEDIATE
:
410 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
411 ctx
.value
[0] = immediate
->u
[0].Uint
;
412 ctx
.value
[1] = immediate
->u
[1].Uint
;
413 ctx
.value
[2] = immediate
->u
[2].Uint
;
414 ctx
.value
[3] = immediate
->u
[3].Uint
;
416 case TGSI_TOKEN_TYPE_DECLARATION
:
417 r
= tgsi_declaration(&ctx
);
421 case TGSI_TOKEN_TYPE_INSTRUCTION
:
422 r
= tgsi_is_supported(&ctx
);
425 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
426 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
427 r
= ctx
.inst_info
->process(&ctx
);
430 r
= r600_bc_add_literal(ctx
.bc
, ctx
.value
);
435 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
441 noutput
= shader
->noutput
;
442 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
443 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
444 output
[i
].gpr
= shader
->output
[i
].gpr
;
445 output
[i
].elem_size
= 3;
446 output
[i
].swizzle_x
= 0;
447 output
[i
].swizzle_y
= 1;
448 output
[i
].swizzle_z
= 2;
449 output
[i
].swizzle_w
= 3;
450 output
[i
].barrier
= 1;
451 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
452 output
[i
].array_base
= i
- pos0
;
453 output
[i
].inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
;
455 case TGSI_PROCESSOR_VERTEX
:
456 if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
457 output
[i
].array_base
= 60;
458 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
459 /* position doesn't count in array_base */
462 if (shader
->output
[i
].name
== TGSI_SEMANTIC_PSIZE
) {
463 output
[i
].array_base
= 61;
464 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
465 /* position doesn't count in array_base */
469 case TGSI_PROCESSOR_FRAGMENT
:
470 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
471 output
[i
].array_base
= shader
->output
[i
].sid
;
472 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
473 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
474 output
[i
].array_base
= 61;
475 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
477 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
483 R600_ERR("unsupported processor type %d\n", ctx
.type
);
488 /* add fake param output for vertex shader if no param is exported */
489 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
490 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
491 if (output
[i
].type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
) {
497 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
499 output
[i
].elem_size
= 3;
500 output
[i
].swizzle_x
= 0;
501 output
[i
].swizzle_y
= 1;
502 output
[i
].swizzle_z
= 2;
503 output
[i
].swizzle_w
= 3;
504 output
[i
].barrier
= 1;
505 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
506 output
[i
].array_base
= 0;
507 output
[i
].inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
;
511 /* add fake pixel export */
512 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& !noutput
) {
513 memset(&output
[0], 0, sizeof(struct r600_bc_output
));
515 output
[0].elem_size
= 3;
516 output
[0].swizzle_x
= 7;
517 output
[0].swizzle_y
= 7;
518 output
[0].swizzle_z
= 7;
519 output
[0].swizzle_w
= 7;
520 output
[0].barrier
= 1;
521 output
[0].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
522 output
[0].array_base
= 0;
523 output
[0].inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
;
526 /* set export done on last export of each type */
527 for (i
= noutput
- 1, output_done
= 0; i
>= 0; i
--) {
528 if (i
== (noutput
- 1)) {
529 output
[i
].end_of_program
= 1;
531 if (!(output_done
& (1 << output
[i
].type
))) {
532 output_done
|= (1 << output
[i
].type
);
533 output
[i
].inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
;
536 /* add output to bytecode */
537 for (i
= 0; i
< noutput
; i
++) {
538 r
= r600_bc_add_output(ctx
.bc
, &output
[i
]);
542 tgsi_parse_free(&ctx
.parse
);
545 tgsi_parse_free(&ctx
.parse
);
549 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
551 R600_ERR("%d tgsi opcode unsupported\n", ctx
->inst_info
->tgsi_opcode
);
555 static int tgsi_end(struct r600_shader_ctx
*ctx
)
560 static int tgsi_src(struct r600_shader_ctx
*ctx
,
561 const struct tgsi_full_src_register
*tgsi_src
,
562 struct r600_bc_alu_src
*r600_src
)
564 memset(r600_src
, 0, sizeof(struct r600_bc_alu_src
));
565 r600_src
->sel
= tgsi_src
->Register
.Index
;
566 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
569 r600_src
->neg
= tgsi_src
->Register
.Negate
;
570 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
574 static int tgsi_dst(struct r600_shader_ctx
*ctx
,
575 const struct tgsi_full_dst_register
*tgsi_dst
,
577 struct r600_bc_alu_dst
*r600_dst
)
579 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
581 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
582 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
583 r600_dst
->chan
= swizzle
;
585 if (inst
->Instruction
.Saturate
) {
591 static unsigned tgsi_chan(const struct tgsi_full_src_register
*tgsi_src
, unsigned swizzle
)
595 return tgsi_src
->Register
.SwizzleX
;
597 return tgsi_src
->Register
.SwizzleY
;
599 return tgsi_src
->Register
.SwizzleZ
;
601 return tgsi_src
->Register
.SwizzleW
;
607 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
609 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
610 struct r600_bc_alu alu
;
611 int i
, j
, k
, nconst
, r
;
613 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
614 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
617 r
= tgsi_src(ctx
, &inst
->Src
[i
], &r600_src
[i
]);
622 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
623 if (inst
->Src
[j
].Register
.File
== TGSI_FILE_CONSTANT
&& j
> 0) {
624 for (k
= 0; k
< 4; k
++) {
625 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
626 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
627 alu
.src
[0].sel
= r600_src
[0].sel
;
629 alu
.dst
.sel
= ctx
->temp_reg
+ j
;
634 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
638 r600_src
[0].sel
= ctx
->temp_reg
+ j
;
645 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
647 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
648 struct r600_bc_alu_src r600_src
[3];
649 struct r600_bc_alu alu
;
652 r
= tgsi_split_constant(ctx
, r600_src
);
655 for (i
= 0; i
< 4; i
++) {
656 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
657 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
658 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
;
661 alu
.inst
= ctx
->inst_info
->r600_opcode
;
662 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
663 alu
.src
[j
] = r600_src
[j
];
664 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
666 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
670 /* handle some special cases */
671 switch (ctx
->inst_info
->tgsi_opcode
) {
672 case TGSI_OPCODE_SUB
:
675 case TGSI_OPCODE_ABS
:
684 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
692 * r600 - trunc to -PI..PI range
693 * r700 - normalize by dividing by 2PI
696 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
698 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
699 struct r600_bc_alu_src r600_src
[3];
700 struct r600_bc_alu alu
;
702 uint32_t lit_vals
[4];
704 memset(lit_vals
, 0, 4*4);
705 r
= tgsi_split_constant(ctx
, r600_src
);
708 lit_vals
[0] = fui(1.0 /(3.1415926535 * 2));
709 lit_vals
[1] = fui(0.5f
);
711 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
712 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
;
716 alu
.dst
.sel
= ctx
->temp_reg
;
719 alu
.src
[0] = r600_src
[0];
720 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
722 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
724 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
727 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
730 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
734 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
735 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
;
738 alu
.dst
.sel
= ctx
->temp_reg
;
741 alu
.src
[0].sel
= ctx
->temp_reg
;
744 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
748 if (ctx
->bc
->chiprev
== 0) {
749 lit_vals
[0] = fui(3.1415926535897f
* 2.0f
);
750 lit_vals
[1] = fui(-3.1415926535897f
);
752 lit_vals
[0] = fui(1.0f
);
753 lit_vals
[1] = fui(-0.5f
);
756 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
757 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
;
761 alu
.dst
.sel
= ctx
->temp_reg
;
764 alu
.src
[0].sel
= ctx
->temp_reg
;
767 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
769 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
772 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
775 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
779 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
780 alu
.inst
= ctx
->inst_info
->r600_opcode
;
782 alu
.dst
.sel
= ctx
->temp_reg
;
785 alu
.src
[0].sel
= ctx
->temp_reg
;
788 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
792 /* replicate result */
793 for (i
= 0; i
< 4; i
++) {
794 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
795 alu
.src
[0].sel
= ctx
->temp_reg
;
796 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
798 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
801 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
804 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
811 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
813 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
814 struct r600_bc_alu alu
;
817 for (i
= 0; i
< 4; i
++) {
818 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
819 alu
.inst
= ctx
->inst_info
->r600_opcode
;
821 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
822 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
825 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
829 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
836 static int tgsi_slt(struct r600_shader_ctx
*ctx
)
838 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
839 struct r600_bc_alu_src r600_src
[3];
840 struct r600_bc_alu alu
;
843 r
= tgsi_split_constant(ctx
, r600_src
);
846 for (i
= 0; i
< 4; i
++) {
847 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
848 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
849 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
;
852 alu
.inst
= ctx
->inst_info
->r600_opcode
;
853 alu
.src
[1] = r600_src
[0];
854 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
855 alu
.src
[0] = r600_src
[1];
856 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], i
);
857 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
864 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
871 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
873 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
874 struct r600_bc_alu alu
;
878 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
879 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
880 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
882 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
885 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
886 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
890 /* dst.y = max(src.x, 0.0) */
891 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
892 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
;
893 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
896 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
897 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], 0);
898 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
901 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
902 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
906 /* dst.z = NOP - fill Z slot */
907 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
908 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
;
910 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
915 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
916 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
917 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
919 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
922 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
924 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
928 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
933 /* dst.z = log(src.y) */
934 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
935 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
;
936 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
939 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
940 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
944 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
951 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
952 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
953 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
;
954 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
957 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
958 alu
.src
[1].sel
= sel
;
959 alu
.src
[1].chan
= chan
;
960 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[2]);
963 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], 0);
964 alu
.dst
.sel
= ctx
->temp_reg
;
969 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
973 /* dst.z = exp(tmp.x) */
974 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
975 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
;
976 alu
.src
[0].sel
= ctx
->temp_reg
;
978 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
982 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
989 static int tgsi_trans(struct r600_shader_ctx
*ctx
)
991 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
992 struct r600_bc_alu alu
;
995 for (i
= 0; i
< 4; i
++) {
996 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
997 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
998 alu
.inst
= ctx
->inst_info
->r600_opcode
;
999 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1000 r
= tgsi_src(ctx
, &inst
->Src
[j
], &alu
.src
[j
]);
1003 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1005 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1009 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1017 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1019 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1020 struct r600_bc_alu alu
;
1023 for (i
= 0; i
< 4; i
++) {
1024 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1025 alu
.src
[0].sel
= ctx
->temp_reg
;
1026 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
1028 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1031 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1034 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1041 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1043 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1044 struct r600_bc_alu alu
;
1047 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1048 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1049 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1050 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1053 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1055 alu
.dst
.sel
= ctx
->temp_reg
;
1058 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1061 /* replicate result */
1062 return tgsi_helper_tempx_replicate(ctx
);
1065 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1067 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1068 struct r600_bc_alu alu
;
1072 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1073 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
;
1074 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1077 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1078 alu
.dst
.sel
= ctx
->temp_reg
;
1081 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1085 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1086 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL_IEEE
;
1087 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[0]);
1090 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], 0);
1091 alu
.src
[1].sel
= ctx
->temp_reg
;
1092 alu
.dst
.sel
= ctx
->temp_reg
;
1095 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1098 /* POW(a,b) = EXP2(b * LOG2(a))*/
1099 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1100 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
;
1101 alu
.src
[0].sel
= ctx
->temp_reg
;
1102 alu
.dst
.sel
= ctx
->temp_reg
;
1105 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1108 return tgsi_helper_tempx_replicate(ctx
);
1111 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1113 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1114 struct r600_bc_alu alu
;
1115 struct r600_bc_alu_src r600_src
[3];
1118 r
= tgsi_split_constant(ctx
, r600_src
);
1122 /* tmp = (src > 0 ? 1 : src) */
1123 for (i
= 0; i
< 4; i
++) {
1124 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1125 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
;
1127 alu
.dst
.sel
= ctx
->temp_reg
;
1130 alu
.src
[0] = r600_src
[0];
1131 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1133 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1135 alu
.src
[2] = r600_src
[0];
1136 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], i
);
1139 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1144 /* dst = (-tmp > 0 ? -1 : tmp) */
1145 for (i
= 0; i
< 4; i
++) {
1146 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1147 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
;
1149 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1153 alu
.src
[0].sel
= ctx
->temp_reg
;
1156 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1159 alu
.src
[2].sel
= ctx
->temp_reg
;
1164 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1171 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1173 struct r600_bc_alu alu
;
1176 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1179 for (i
= 0; i
< 4; i
++) {
1180 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1181 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1182 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
;
1185 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
1186 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1189 alu
.src
[0].sel
= ctx
->temp_reg
;
1190 alu
.src
[0].chan
= i
;
1195 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1202 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1204 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1205 struct r600_bc_alu_src r600_src
[3];
1206 struct r600_bc_alu alu
;
1209 r
= tgsi_split_constant(ctx
, r600_src
);
1212 /* do it in 2 step as op3 doesn't support writemask */
1213 for (i
= 0; i
< 4; i
++) {
1214 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1215 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1216 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1217 alu
.src
[j
] = r600_src
[j
];
1218 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1220 alu
.dst
.sel
= ctx
->temp_reg
;
1227 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1231 return tgsi_helper_copy(ctx
, inst
);
1234 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1236 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1237 struct r600_bc_alu_src r600_src
[3];
1238 struct r600_bc_alu alu
;
1241 r
= tgsi_split_constant(ctx
, r600_src
);
1244 for (i
= 0; i
< 4; i
++) {
1245 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1246 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1247 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1248 alu
.src
[j
] = r600_src
[j
];
1249 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1251 alu
.dst
.sel
= ctx
->temp_reg
;
1254 /* handle some special cases */
1255 switch (ctx
->inst_info
->tgsi_opcode
) {
1256 case TGSI_OPCODE_DP2
:
1258 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1259 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1262 case TGSI_OPCODE_DP3
:
1264 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1265 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1268 case TGSI_OPCODE_DPH
:
1270 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1271 alu
.src
[0].chan
= 0;
1281 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1285 return tgsi_helper_copy(ctx
, inst
);
1288 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1290 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1291 struct r600_bc_tex tex
;
1292 struct r600_bc_alu alu
;
1296 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
1298 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1299 /* Add perspective divide */
1300 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1301 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
;
1302 alu
.src
[0].sel
= src_gpr
;
1303 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1304 alu
.dst
.sel
= ctx
->temp_reg
;
1308 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1312 for (i
= 0; i
< 3; i
++) {
1313 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1314 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
;
1315 alu
.src
[0].sel
= ctx
->temp_reg
;
1316 alu
.src
[0].chan
= 3;
1317 alu
.src
[1].sel
= src_gpr
;
1318 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1319 alu
.dst
.sel
= ctx
->temp_reg
;
1322 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1326 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1327 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
1328 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1329 alu
.src
[0].chan
= 0;
1330 alu
.dst
.sel
= ctx
->temp_reg
;
1334 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1337 src_gpr
= ctx
->temp_reg
;
1338 } else if (inst
->Src
[0].Register
.File
!= TGSI_FILE_TEMPORARY
) {
1339 for (i
= 0; i
< 4; i
++) {
1340 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1341 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
1342 alu
.src
[0].sel
= src_gpr
;
1343 alu
.src
[0].chan
= i
;
1344 alu
.dst
.sel
= ctx
->temp_reg
;
1349 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1353 src_gpr
= ctx
->temp_reg
;
1356 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
1357 tex
.inst
= ctx
->inst_info
->r600_opcode
;
1358 tex
.resource_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
1359 tex
.sampler_id
= tex
.resource_id
;
1360 tex
.src_gpr
= src_gpr
;
1361 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
1371 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
1372 tex
.coord_type_x
= 1;
1373 tex
.coord_type_y
= 1;
1374 tex
.coord_type_z
= 1;
1375 tex
.coord_type_w
= 1;
1377 return r600_bc_add_tex(ctx
->bc
, &tex
);
1380 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
1382 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1383 struct r600_bc_alu_src r600_src
[3];
1384 struct r600_bc_alu alu
;
1388 r
= tgsi_split_constant(ctx
, r600_src
);
1392 for (i
= 0; i
< 4; i
++) {
1393 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1394 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
;
1395 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1396 alu
.src
[0].chan
= 0;
1397 alu
.src
[1] = r600_src
[0];
1398 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1400 alu
.dst
.sel
= ctx
->temp_reg
;
1406 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1410 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1414 /* (1 - src0) * src2 */
1415 for (i
= 0; i
< 4; i
++) {
1416 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1417 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
;
1418 alu
.src
[0].sel
= ctx
->temp_reg
;
1419 alu
.src
[0].chan
= i
;
1420 alu
.src
[1] = r600_src
[2];
1421 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1422 alu
.dst
.sel
= ctx
->temp_reg
;
1428 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1432 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1436 /* src0 * src1 + (1 - src0) * src2 */
1437 for (i
= 0; i
< 4; i
++) {
1438 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1439 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
;
1441 alu
.src
[0] = r600_src
[0];
1442 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1443 alu
.src
[1] = r600_src
[1];
1444 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
1445 alu
.src
[2].sel
= ctx
->temp_reg
;
1446 alu
.src
[2].chan
= i
;
1447 alu
.dst
.sel
= ctx
->temp_reg
;
1452 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1456 return tgsi_helper_copy(ctx
, inst
);
1459 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
1461 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1462 struct r600_bc_alu_src r600_src
[3];
1463 struct r600_bc_alu alu
;
1467 r
= tgsi_split_constant(ctx
, r600_src
);
1471 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1474 for (i
= 0; i
< 4; i
++) {
1475 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1476 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
;
1477 alu
.src
[0] = r600_src
[0];
1478 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1480 alu
.src
[1] = r600_src
[2];
1481 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1483 alu
.src
[2] = r600_src
[1];
1484 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[1], i
);
1487 alu
.dst
.sel
= ctx
->temp_reg
;
1489 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1498 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1503 return tgsi_helper_copy(ctx
, inst
);
1507 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
1509 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1510 struct r600_bc_alu_src r600_src
[3];
1511 struct r600_bc_alu alu
;
1512 uint32_t use_temp
= 0;
1515 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1518 r
= tgsi_split_constant(ctx
, r600_src
);
1522 for (i
= 0; i
< 4; i
++) {
1523 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1524 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
;
1526 alu
.src
[0] = r600_src
[0];
1529 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1532 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1535 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1538 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1539 alu
.src
[0].chan
= i
;
1542 alu
.src
[1] = r600_src
[1];
1545 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1548 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1551 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1554 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1555 alu
.src
[1].chan
= i
;
1558 alu
.dst
.sel
= ctx
->temp_reg
;
1564 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1569 for (i
= 0; i
< 4; i
++) {
1570 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1571 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
;
1573 alu
.src
[0] = r600_src
[0];
1576 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1579 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1582 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1585 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1586 alu
.src
[0].chan
= i
;
1589 alu
.src
[1] = r600_src
[1];
1592 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1595 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1598 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1601 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1602 alu
.src
[1].chan
= i
;
1605 alu
.src
[2].sel
= ctx
->temp_reg
;
1607 alu
.src
[2].chan
= i
;
1610 alu
.dst
.sel
= ctx
->temp_reg
;
1612 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1621 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1626 return tgsi_helper_copy(ctx
, inst
);
1631 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
1632 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1633 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
1634 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
1635 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
1636 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
1637 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1638 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1639 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
1640 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
1641 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
1642 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
1643 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1644 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
1645 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
1646 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_slt
},
1647 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
1648 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
1649 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
1650 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
1651 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1653 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1654 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1656 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1657 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1658 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
1659 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1660 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
1661 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1662 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
1663 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
1664 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
1665 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
1667 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1668 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
1669 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1670 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
1671 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
1672 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
1673 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
1674 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
}, /* predicated kill */
1675 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1676 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1677 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1678 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1679 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1680 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
1681 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1682 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
1683 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
1684 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_slt
},
1685 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
1686 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1687 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
1688 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1689 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
1690 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1691 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1692 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1693 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1694 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1695 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1696 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1697 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1698 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1699 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1700 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
1701 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
1702 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1703 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
1704 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1705 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1706 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
1707 {TGSI_OPCODE_TXL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1708 {TGSI_OPCODE_BRK
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1709 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1711 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1712 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1713 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1714 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1716 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1717 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1718 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1719 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1720 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1721 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1722 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1723 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
1724 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1726 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1727 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1728 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1729 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1730 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1731 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1732 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1733 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1734 {TGSI_OPCODE_CONT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1735 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1736 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1737 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1738 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1739 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1740 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1742 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1743 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1744 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1745 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1746 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1748 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1749 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1750 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1751 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1752 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1753 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1754 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1755 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1756 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
1757 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
1759 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1760 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1761 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1762 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1763 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1764 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1765 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1766 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1767 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1768 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1769 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1770 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1771 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1772 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1773 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1774 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1775 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1776 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1777 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1778 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1779 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1780 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1781 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1782 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1783 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1784 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1785 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1786 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},