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 S_028868_STACK_SIZE(rshader
->bc
.nstack
);
149 rpshader
->rstate
= state
;
150 rpshader
->rstate
->bo
[0] = radeon_bo_incref(rscreen
->rw
, rpshader
->bo
);
151 rpshader
->rstate
->bo
[1] = radeon_bo_incref(rscreen
->rw
, rpshader
->bo
);
152 rpshader
->rstate
->nbo
= 2;
153 rpshader
->rstate
->placement
[0] = RADEON_GEM_DOMAIN_GTT
;
154 rpshader
->rstate
->placement
[2] = RADEON_GEM_DOMAIN_GTT
;
155 state
->reloc_pm4_id
[0] = R600_VS_SHADER__SQ_PGM_START_VS_BO_ID
;
156 state
->reloc_pm4_id
[1] = R600_VS_SHADER__SQ_PGM_START_FS_BO_ID
;
157 return radeon_state_pm4(state
);
160 static int r600_pipe_shader_ps(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
162 const struct pipe_rasterizer_state
*rasterizer
;
163 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
164 struct r600_shader
*rshader
= &rpshader
->shader
;
165 struct r600_context
*rctx
= r600_context(ctx
);
166 struct radeon_state
*state
;
167 unsigned i
, tmp
, exports_ps
, num_cout
;
169 rasterizer
= &rctx
->rasterizer
->state
.rasterizer
;
170 rpshader
->rstate
= radeon_state_decref(rpshader
->rstate
);
171 state
= radeon_state(rscreen
->rw
, R600_PS_SHADER
);
174 for (i
= 0; i
< rshader
->ninput
; i
++) {
175 tmp
= S_028644_SEMANTIC(i
);
176 tmp
|= S_028644_SEL_CENTROID(1);
177 if (rshader
->input
[i
].name
== TGSI_SEMANTIC_COLOR
||
178 rshader
->input
[i
].name
== TGSI_SEMANTIC_BCOLOR
) {
179 tmp
|= S_028644_FLAT_SHADE(rshader
->flat_shade
);
181 if (rasterizer
->sprite_coord_enable
& (1 << i
)) {
182 tmp
|= S_028644_PT_SPRITE_TEX(1);
184 state
->states
[R600_PS_SHADER__SPI_PS_INPUT_CNTL_0
+ i
] = tmp
;
189 for (i
= 0; i
< rshader
->noutput
; i
++) {
190 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
)
192 else if (rshader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
193 exports_ps
|= (1 << (num_cout
+1));
198 /* always at least export 1 component per pixel */
201 state
->states
[R600_PS_SHADER__SPI_PS_IN_CONTROL_0
] = S_0286CC_NUM_INTERP(rshader
->ninput
) |
202 S_0286CC_PERSP_GRADIENT_ENA(1);
203 state
->states
[R600_PS_SHADER__SPI_PS_IN_CONTROL_1
] = 0x00000000;
204 state
->states
[R600_PS_SHADER__SQ_PGM_RESOURCES_PS
] = S_028868_NUM_GPRS(rshader
->bc
.ngpr
) |
205 S_028868_STACK_SIZE(rshader
->bc
.nstack
);
206 state
->states
[R600_PS_SHADER__SQ_PGM_EXPORTS_PS
] = exports_ps
;
207 rpshader
->rstate
= state
;
208 rpshader
->rstate
->bo
[0] = radeon_bo_incref(rscreen
->rw
, rpshader
->bo
);
209 rpshader
->rstate
->nbo
= 1;
210 rpshader
->rstate
->placement
[0] = RADEON_GEM_DOMAIN_GTT
;
211 state
->reloc_pm4_id
[0] = R600_PS_SHADER__SQ_PGM_START_PS_BO_ID
;
212 return radeon_state_pm4(state
);
215 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
217 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
218 struct r600_context
*rctx
= r600_context(ctx
);
219 struct r600_shader
*rshader
= &rpshader
->shader
;
222 /* copy new shader */
223 radeon_bo_decref(rscreen
->rw
, rpshader
->bo
);
225 rpshader
->bo
= radeon_bo(rscreen
->rw
, 0, rshader
->bc
.ndw
* 4,
227 if (rpshader
->bo
== NULL
) {
230 radeon_bo_map(rscreen
->rw
, rpshader
->bo
);
231 memcpy(rpshader
->bo
->data
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* 4);
232 radeon_bo_unmap(rscreen
->rw
, rpshader
->bo
);
234 rshader
->flat_shade
= rctx
->flat_shade
;
235 switch (rshader
->processor_type
) {
236 case TGSI_PROCESSOR_VERTEX
:
237 r
= r600_pipe_shader_vs(ctx
, rpshader
);
239 case TGSI_PROCESSOR_FRAGMENT
:
240 r
= r600_pipe_shader_ps(ctx
, rpshader
);
249 int r600_pipe_shader_update(struct pipe_context
*ctx
, struct r600_context_state
*rpshader
)
251 struct r600_context
*rctx
= r600_context(ctx
);
254 if (rpshader
== NULL
)
256 /* there should be enough input */
257 if (rctx
->vertex_elements
->count
< rpshader
->shader
.bc
.nresource
) {
258 R600_ERR("%d resources provided, expecting %d\n",
259 rctx
->vertex_elements
->count
, rpshader
->shader
.bc
.nresource
);
262 r
= r600_shader_update(ctx
, &rpshader
->shader
);
265 return r600_pipe_shader(ctx
, rpshader
);
268 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
270 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
273 if (i
->Instruction
.NumDstRegs
> 1) {
274 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
277 if (i
->Instruction
.Predicate
) {
278 R600_ERR("predicate unsupported\n");
282 if (i
->Instruction
.Label
) {
283 R600_ERR("label unsupported\n");
287 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
288 if (i
->Src
[j
].Register
.Indirect
||
289 i
->Src
[j
].Register
.Dimension
||
290 i
->Src
[j
].Register
.Absolute
) {
291 R600_ERR("unsupported src (indirect|dimension|absolute)\n");
295 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
296 if (i
->Dst
[j
].Register
.Indirect
|| i
->Dst
[j
].Register
.Dimension
) {
297 R600_ERR("unsupported dst (indirect|dimension)\n");
304 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
306 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
307 struct r600_bc_vtx vtx
;
311 switch (d
->Declaration
.File
) {
312 case TGSI_FILE_INPUT
:
313 i
= ctx
->shader
->ninput
++;
314 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
315 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
316 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
317 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + i
;
318 if (ctx
->type
== TGSI_PROCESSOR_VERTEX
) {
319 /* turn input into fetch */
320 memset(&vtx
, 0, sizeof(struct r600_bc_vtx
));
324 /* register containing the index into the buffer */
327 vtx
.mega_fetch_count
= 0x1F;
328 vtx
.dst_gpr
= ctx
->shader
->input
[i
].gpr
;
333 r
= r600_bc_add_vtx(ctx
->bc
, &vtx
);
338 case TGSI_FILE_OUTPUT
:
339 i
= ctx
->shader
->noutput
++;
340 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
341 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
342 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + i
;
343 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
345 case TGSI_FILE_CONSTANT
:
346 case TGSI_FILE_TEMPORARY
:
347 case TGSI_FILE_SAMPLER
:
350 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
356 int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
)
358 struct tgsi_full_immediate
*immediate
;
359 struct r600_shader_ctx ctx
;
360 struct r600_bc_output output
[32];
361 unsigned output_done
, noutput
;
365 ctx
.bc
= &shader
->bc
;
367 r
= r600_bc_init(ctx
.bc
, shader
->family
);
371 tgsi_scan_shader(tokens
, &ctx
.info
);
372 tgsi_parse_init(&ctx
.parse
, tokens
);
373 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
374 shader
->processor_type
= ctx
.type
;
376 /* register allocations */
377 /* Values [0,127] correspond to GPR[0..127].
378 * Values [128,159] correspond to constant buffer bank 0
379 * Values [160,191] correspond to constant buffer bank 1
380 * Values [256,511] correspond to cfile constants c[0..255].
381 * Other special values are shown in the list below.
382 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
383 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
384 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
385 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
386 * 248 SQ_ALU_SRC_0: special constant 0.0.
387 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
388 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
389 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
390 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
391 * 253 SQ_ALU_SRC_LITERAL: literal constant.
392 * 254 SQ_ALU_SRC_PV: previous vector result.
393 * 255 SQ_ALU_SRC_PS: previous scalar result.
395 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
396 ctx
.file_offset
[i
] = 0;
398 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
399 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
401 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
402 ctx
.info
.file_count
[TGSI_FILE_INPUT
];
403 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
404 ctx
.info
.file_count
[TGSI_FILE_OUTPUT
];
405 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 256;
406 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = 253;
407 ctx
.temp_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
408 ctx
.info
.file_count
[TGSI_FILE_TEMPORARY
];
410 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
411 tgsi_parse_token(&ctx
.parse
);
412 switch (ctx
.parse
.FullToken
.Token
.Type
) {
413 case TGSI_TOKEN_TYPE_IMMEDIATE
:
414 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
415 ctx
.value
[0] = immediate
->u
[0].Uint
;
416 ctx
.value
[1] = immediate
->u
[1].Uint
;
417 ctx
.value
[2] = immediate
->u
[2].Uint
;
418 ctx
.value
[3] = immediate
->u
[3].Uint
;
420 case TGSI_TOKEN_TYPE_DECLARATION
:
421 r
= tgsi_declaration(&ctx
);
425 case TGSI_TOKEN_TYPE_INSTRUCTION
:
426 r
= tgsi_is_supported(&ctx
);
429 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
430 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
431 r
= ctx
.inst_info
->process(&ctx
);
434 r
= r600_bc_add_literal(ctx
.bc
, ctx
.value
);
439 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
445 noutput
= shader
->noutput
;
446 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
447 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
448 output
[i
].gpr
= shader
->output
[i
].gpr
;
449 output
[i
].elem_size
= 3;
450 output
[i
].swizzle_x
= 0;
451 output
[i
].swizzle_y
= 1;
452 output
[i
].swizzle_z
= 2;
453 output
[i
].swizzle_w
= 3;
454 output
[i
].barrier
= 1;
455 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
456 output
[i
].array_base
= i
- pos0
;
457 output
[i
].inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
;
459 case TGSI_PROCESSOR_VERTEX
:
460 if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
461 output
[i
].array_base
= 60;
462 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
463 /* position doesn't count in array_base */
466 if (shader
->output
[i
].name
== TGSI_SEMANTIC_PSIZE
) {
467 output
[i
].array_base
= 61;
468 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
469 /* position doesn't count in array_base */
473 case TGSI_PROCESSOR_FRAGMENT
:
474 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
475 output
[i
].array_base
= shader
->output
[i
].sid
;
476 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
477 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
478 output
[i
].array_base
= 61;
479 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
481 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
487 R600_ERR("unsupported processor type %d\n", ctx
.type
);
492 /* add fake param output for vertex shader if no param is exported */
493 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
494 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
495 if (output
[i
].type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
) {
501 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
503 output
[i
].elem_size
= 3;
504 output
[i
].swizzle_x
= 0;
505 output
[i
].swizzle_y
= 1;
506 output
[i
].swizzle_z
= 2;
507 output
[i
].swizzle_w
= 3;
508 output
[i
].barrier
= 1;
509 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
510 output
[i
].array_base
= 0;
511 output
[i
].inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
;
515 /* add fake pixel export */
516 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& !noutput
) {
517 memset(&output
[0], 0, sizeof(struct r600_bc_output
));
519 output
[0].elem_size
= 3;
520 output
[0].swizzle_x
= 7;
521 output
[0].swizzle_y
= 7;
522 output
[0].swizzle_z
= 7;
523 output
[0].swizzle_w
= 7;
524 output
[0].barrier
= 1;
525 output
[0].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
526 output
[0].array_base
= 0;
527 output
[0].inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
;
530 /* set export done on last export of each type */
531 for (i
= noutput
- 1, output_done
= 0; i
>= 0; i
--) {
532 if (i
== (noutput
- 1)) {
533 output
[i
].end_of_program
= 1;
535 if (!(output_done
& (1 << output
[i
].type
))) {
536 output_done
|= (1 << output
[i
].type
);
537 output
[i
].inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
;
540 /* add output to bytecode */
541 for (i
= 0; i
< noutput
; i
++) {
542 r
= r600_bc_add_output(ctx
.bc
, &output
[i
]);
546 tgsi_parse_free(&ctx
.parse
);
549 tgsi_parse_free(&ctx
.parse
);
553 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
555 R600_ERR("%d tgsi opcode unsupported\n", ctx
->inst_info
->tgsi_opcode
);
559 static int tgsi_end(struct r600_shader_ctx
*ctx
)
564 static int tgsi_src(struct r600_shader_ctx
*ctx
,
565 const struct tgsi_full_src_register
*tgsi_src
,
566 struct r600_bc_alu_src
*r600_src
)
568 memset(r600_src
, 0, sizeof(struct r600_bc_alu_src
));
569 r600_src
->sel
= tgsi_src
->Register
.Index
;
570 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
573 r600_src
->neg
= tgsi_src
->Register
.Negate
;
574 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
578 static int tgsi_dst(struct r600_shader_ctx
*ctx
,
579 const struct tgsi_full_dst_register
*tgsi_dst
,
581 struct r600_bc_alu_dst
*r600_dst
)
583 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
585 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
586 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
587 r600_dst
->chan
= swizzle
;
589 if (inst
->Instruction
.Saturate
) {
595 static unsigned tgsi_chan(const struct tgsi_full_src_register
*tgsi_src
, unsigned swizzle
)
599 return tgsi_src
->Register
.SwizzleX
;
601 return tgsi_src
->Register
.SwizzleY
;
603 return tgsi_src
->Register
.SwizzleZ
;
605 return tgsi_src
->Register
.SwizzleW
;
611 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
613 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
614 struct r600_bc_alu alu
;
615 int i
, j
, k
, nconst
, r
;
617 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
618 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
621 r
= tgsi_src(ctx
, &inst
->Src
[i
], &r600_src
[i
]);
626 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
627 if (inst
->Src
[j
].Register
.File
== TGSI_FILE_CONSTANT
&& j
> 0) {
628 for (k
= 0; k
< 4; k
++) {
629 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
630 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
631 alu
.src
[0].sel
= r600_src
[0].sel
;
633 alu
.dst
.sel
= ctx
->temp_reg
+ j
;
638 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
642 r600_src
[0].sel
= ctx
->temp_reg
+ j
;
649 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
)
651 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
652 struct r600_bc_alu_src r600_src
[3];
653 struct r600_bc_alu alu
;
657 for (i
= 0; i
< 4; i
++) {
658 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
663 r
= tgsi_split_constant(ctx
, r600_src
);
666 for (i
= 0; i
< lasti
+ 1; i
++) {
667 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
670 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
671 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
675 alu
.inst
= ctx
->inst_info
->r600_opcode
;
677 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
678 alu
.src
[j
] = r600_src
[j
];
679 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
682 alu
.src
[0] = r600_src
[1];
683 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], i
);
685 alu
.src
[1] = r600_src
[0];
686 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
688 /* handle some special cases */
689 switch (ctx
->inst_info
->tgsi_opcode
) {
690 case TGSI_OPCODE_SUB
:
693 case TGSI_OPCODE_ABS
:
702 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
709 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
711 return tgsi_op2_s(ctx
, 0);
714 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
716 return tgsi_op2_s(ctx
, 1);
720 * r600 - trunc to -PI..PI range
721 * r700 - normalize by dividing by 2PI
724 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
726 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
727 struct r600_bc_alu_src r600_src
[3];
728 struct r600_bc_alu alu
;
730 uint32_t lit_vals
[4];
732 memset(lit_vals
, 0, 4*4);
733 r
= tgsi_split_constant(ctx
, r600_src
);
736 lit_vals
[0] = fui(1.0 /(3.1415926535 * 2));
737 lit_vals
[1] = fui(0.5f
);
739 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
740 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
;
744 alu
.dst
.sel
= ctx
->temp_reg
;
747 alu
.src
[0] = r600_src
[0];
748 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
750 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
752 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
755 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
758 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
762 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
763 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
;
766 alu
.dst
.sel
= ctx
->temp_reg
;
769 alu
.src
[0].sel
= ctx
->temp_reg
;
772 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
776 if (ctx
->bc
->chiprev
== 0) {
777 lit_vals
[0] = fui(3.1415926535897f
* 2.0f
);
778 lit_vals
[1] = fui(-3.1415926535897f
);
780 lit_vals
[0] = fui(1.0f
);
781 lit_vals
[1] = fui(-0.5f
);
784 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
785 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
;
789 alu
.dst
.sel
= ctx
->temp_reg
;
792 alu
.src
[0].sel
= ctx
->temp_reg
;
795 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
797 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
800 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
803 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
807 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
808 alu
.inst
= ctx
->inst_info
->r600_opcode
;
810 alu
.dst
.sel
= ctx
->temp_reg
;
813 alu
.src
[0].sel
= ctx
->temp_reg
;
816 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
820 /* replicate result */
821 for (i
= 0; i
< 4; i
++) {
822 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
823 alu
.src
[0].sel
= ctx
->temp_reg
;
824 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
826 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
829 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
832 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
839 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
841 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
842 struct r600_bc_alu alu
;
845 for (i
= 0; i
< 4; i
++) {
846 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
847 alu
.inst
= ctx
->inst_info
->r600_opcode
;
849 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
850 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
853 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
857 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
864 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
866 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
867 struct r600_bc_alu alu
;
871 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
872 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
873 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
875 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
878 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
879 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
883 /* dst.y = max(src.x, 0.0) */
884 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
885 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
;
886 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
889 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
890 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], 0);
891 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
894 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
895 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
899 /* dst.z = NOP - fill Z slot */
900 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
901 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
;
903 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
908 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
909 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
910 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
912 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
915 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
917 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
921 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
926 /* dst.z = log(src.y) */
927 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
928 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
;
929 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
932 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
933 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
937 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
944 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
945 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
946 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
;
947 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
950 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
951 alu
.src
[1].sel
= sel
;
952 alu
.src
[1].chan
= chan
;
953 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[2]);
956 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], 0);
957 alu
.dst
.sel
= ctx
->temp_reg
;
962 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
966 /* dst.z = exp(tmp.x) */
967 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
968 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
;
969 alu
.src
[0].sel
= ctx
->temp_reg
;
971 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
975 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
982 static int tgsi_trans(struct r600_shader_ctx
*ctx
)
984 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
985 struct r600_bc_alu alu
;
988 for (i
= 0; i
< 4; i
++) {
989 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
990 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
991 alu
.inst
= ctx
->inst_info
->r600_opcode
;
992 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
993 r
= tgsi_src(ctx
, &inst
->Src
[j
], &alu
.src
[j
]);
996 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
998 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1002 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1010 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1012 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1013 struct r600_bc_alu alu
;
1016 for (i
= 0; i
< 4; i
++) {
1017 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1018 alu
.src
[0].sel
= ctx
->temp_reg
;
1019 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
1021 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1024 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1027 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1034 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1036 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1037 struct r600_bc_alu alu
;
1040 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1041 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1042 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1043 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1046 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1048 alu
.dst
.sel
= ctx
->temp_reg
;
1051 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1054 /* replicate result */
1055 return tgsi_helper_tempx_replicate(ctx
);
1058 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1060 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1061 struct r600_bc_alu alu
;
1065 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1066 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
;
1067 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1070 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1071 alu
.dst
.sel
= ctx
->temp_reg
;
1074 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1078 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1079 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL_IEEE
;
1080 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[0]);
1083 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], 0);
1084 alu
.src
[1].sel
= ctx
->temp_reg
;
1085 alu
.dst
.sel
= ctx
->temp_reg
;
1088 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1091 /* POW(a,b) = EXP2(b * LOG2(a))*/
1092 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1093 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
;
1094 alu
.src
[0].sel
= ctx
->temp_reg
;
1095 alu
.dst
.sel
= ctx
->temp_reg
;
1098 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1101 return tgsi_helper_tempx_replicate(ctx
);
1104 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1106 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1107 struct r600_bc_alu alu
;
1108 struct r600_bc_alu_src r600_src
[3];
1111 r
= tgsi_split_constant(ctx
, r600_src
);
1115 /* tmp = (src > 0 ? 1 : src) */
1116 for (i
= 0; i
< 4; i
++) {
1117 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1118 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
;
1120 alu
.dst
.sel
= ctx
->temp_reg
;
1123 alu
.src
[0] = r600_src
[0];
1124 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1126 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1128 alu
.src
[2] = r600_src
[0];
1129 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], i
);
1132 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1137 /* dst = (-tmp > 0 ? -1 : tmp) */
1138 for (i
= 0; i
< 4; i
++) {
1139 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1140 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
;
1142 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1146 alu
.src
[0].sel
= ctx
->temp_reg
;
1149 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1152 alu
.src
[2].sel
= ctx
->temp_reg
;
1157 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1164 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1166 struct r600_bc_alu alu
;
1169 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1172 for (i
= 0; i
< 4; i
++) {
1173 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1174 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1175 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
;
1178 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
1179 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1182 alu
.src
[0].sel
= ctx
->temp_reg
;
1183 alu
.src
[0].chan
= i
;
1188 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1195 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1197 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1198 struct r600_bc_alu_src r600_src
[3];
1199 struct r600_bc_alu alu
;
1202 r
= tgsi_split_constant(ctx
, r600_src
);
1205 /* do it in 2 step as op3 doesn't support writemask */
1206 for (i
= 0; i
< 4; i
++) {
1207 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1208 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1209 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1210 alu
.src
[j
] = r600_src
[j
];
1211 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1213 alu
.dst
.sel
= ctx
->temp_reg
;
1220 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1224 return tgsi_helper_copy(ctx
, inst
);
1227 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1229 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1230 struct r600_bc_alu_src r600_src
[3];
1231 struct r600_bc_alu alu
;
1234 r
= tgsi_split_constant(ctx
, r600_src
);
1237 for (i
= 0; i
< 4; i
++) {
1238 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1239 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1240 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1241 alu
.src
[j
] = r600_src
[j
];
1242 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1244 alu
.dst
.sel
= ctx
->temp_reg
;
1247 /* handle some special cases */
1248 switch (ctx
->inst_info
->tgsi_opcode
) {
1249 case TGSI_OPCODE_DP2
:
1251 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1252 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1255 case TGSI_OPCODE_DP3
:
1257 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1258 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1261 case TGSI_OPCODE_DPH
:
1263 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1264 alu
.src
[0].chan
= 0;
1274 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1278 return tgsi_helper_copy(ctx
, inst
);
1281 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1283 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1284 struct r600_bc_tex tex
;
1285 struct r600_bc_alu alu
;
1289 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
1291 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1292 /* Add perspective divide */
1293 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1294 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
;
1295 alu
.src
[0].sel
= src_gpr
;
1296 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1297 alu
.dst
.sel
= ctx
->temp_reg
;
1301 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1305 for (i
= 0; i
< 3; i
++) {
1306 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1307 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
;
1308 alu
.src
[0].sel
= ctx
->temp_reg
;
1309 alu
.src
[0].chan
= 3;
1310 alu
.src
[1].sel
= src_gpr
;
1311 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1312 alu
.dst
.sel
= ctx
->temp_reg
;
1315 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1319 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1320 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
1321 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1322 alu
.src
[0].chan
= 0;
1323 alu
.dst
.sel
= ctx
->temp_reg
;
1327 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1330 src_gpr
= ctx
->temp_reg
;
1331 } else if (inst
->Src
[0].Register
.File
!= TGSI_FILE_TEMPORARY
) {
1332 for (i
= 0; i
< 4; i
++) {
1333 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1334 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
1335 alu
.src
[0].sel
= src_gpr
;
1336 alu
.src
[0].chan
= i
;
1337 alu
.dst
.sel
= ctx
->temp_reg
;
1342 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1346 src_gpr
= ctx
->temp_reg
;
1349 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
1350 tex
.inst
= ctx
->inst_info
->r600_opcode
;
1351 tex
.resource_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
1352 tex
.sampler_id
= tex
.resource_id
;
1353 tex
.src_gpr
= src_gpr
;
1354 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
1364 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
1365 tex
.coord_type_x
= 1;
1366 tex
.coord_type_y
= 1;
1367 tex
.coord_type_z
= 1;
1368 tex
.coord_type_w
= 1;
1370 return r600_bc_add_tex(ctx
->bc
, &tex
);
1373 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
1375 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1376 struct r600_bc_alu_src r600_src
[3];
1377 struct r600_bc_alu alu
;
1381 r
= tgsi_split_constant(ctx
, r600_src
);
1385 for (i
= 0; i
< 4; i
++) {
1386 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1387 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
;
1388 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1389 alu
.src
[0].chan
= 0;
1390 alu
.src
[1] = r600_src
[0];
1391 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1393 alu
.dst
.sel
= ctx
->temp_reg
;
1399 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1403 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1407 /* (1 - src0) * src2 */
1408 for (i
= 0; i
< 4; i
++) {
1409 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1410 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
;
1411 alu
.src
[0].sel
= ctx
->temp_reg
;
1412 alu
.src
[0].chan
= i
;
1413 alu
.src
[1] = r600_src
[2];
1414 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1415 alu
.dst
.sel
= ctx
->temp_reg
;
1421 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1425 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1429 /* src0 * src1 + (1 - src0) * src2 */
1430 for (i
= 0; i
< 4; i
++) {
1431 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1432 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
;
1434 alu
.src
[0] = r600_src
[0];
1435 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1436 alu
.src
[1] = r600_src
[1];
1437 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
1438 alu
.src
[2].sel
= ctx
->temp_reg
;
1439 alu
.src
[2].chan
= i
;
1440 alu
.dst
.sel
= ctx
->temp_reg
;
1445 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1449 return tgsi_helper_copy(ctx
, inst
);
1452 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
1454 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1455 struct r600_bc_alu_src r600_src
[3];
1456 struct r600_bc_alu alu
;
1460 r
= tgsi_split_constant(ctx
, r600_src
);
1464 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1467 for (i
= 0; i
< 4; i
++) {
1468 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1469 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
;
1470 alu
.src
[0] = r600_src
[0];
1471 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1473 alu
.src
[1] = r600_src
[2];
1474 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
1476 alu
.src
[2] = r600_src
[1];
1477 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[1], i
);
1480 alu
.dst
.sel
= ctx
->temp_reg
;
1482 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1491 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1496 return tgsi_helper_copy(ctx
, inst
);
1500 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
1502 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1503 struct r600_bc_alu_src r600_src
[3];
1504 struct r600_bc_alu alu
;
1505 uint32_t use_temp
= 0;
1508 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
1511 r
= tgsi_split_constant(ctx
, r600_src
);
1515 for (i
= 0; i
< 4; i
++) {
1516 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1517 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
;
1519 alu
.src
[0] = r600_src
[0];
1522 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1525 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1528 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1531 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1532 alu
.src
[0].chan
= i
;
1535 alu
.src
[1] = r600_src
[1];
1538 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1541 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1544 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1547 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1548 alu
.src
[1].chan
= i
;
1551 alu
.dst
.sel
= ctx
->temp_reg
;
1557 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1562 for (i
= 0; i
< 4; i
++) {
1563 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1564 alu
.inst
= V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
;
1566 alu
.src
[0] = r600_src
[0];
1569 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1572 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
1575 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1578 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1579 alu
.src
[0].chan
= i
;
1582 alu
.src
[1] = r600_src
[1];
1585 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
1588 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
1591 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
1594 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1595 alu
.src
[1].chan
= i
;
1598 alu
.src
[2].sel
= ctx
->temp_reg
;
1600 alu
.src
[2].chan
= i
;
1603 alu
.dst
.sel
= ctx
->temp_reg
;
1605 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1614 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1619 return tgsi_helper_copy(ctx
, inst
);
1623 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
1625 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1626 struct r600_bc_alu_src r600_src
[3];
1627 struct r600_bc_alu alu
;
1628 uint32_t use_temp
= 0;
1631 /* result.x = 2^floor(src); */
1632 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
1633 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1635 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
;
1636 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1640 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1642 alu
.dst
.sel
= ctx
->temp_reg
;
1646 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1650 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
;
1651 alu
.src
[0].sel
= ctx
->temp_reg
;
1652 alu
.src
[0].chan
= 0;
1654 alu
.dst
.sel
= ctx
->temp_reg
;
1658 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1663 /* result.y = tmp - floor(tmp); */
1664 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
1665 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1667 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
;
1668 alu
.src
[0] = r600_src
[0];
1669 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1672 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1674 alu
.dst
.sel
= ctx
->temp_reg
;
1675 // r = tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
1683 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1688 /* result.z = RoughApprox2ToX(tmp);*/
1689 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
1690 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1691 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
;
1692 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1695 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1697 alu
.dst
.sel
= ctx
->temp_reg
;
1703 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1709 /* result.w = 1.0;*/
1710 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
1711 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1713 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
1714 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1715 alu
.src
[0].chan
= 0;
1717 alu
.dst
.sel
= ctx
->temp_reg
;
1721 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1725 return tgsi_helper_copy(ctx
, inst
);
1728 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
1730 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1731 struct r600_bc_alu alu
, *lalu
;
1732 struct r600_bc_cf
*last
;
1735 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1739 alu
.dst
.sel
= ctx
->temp_reg
;
1743 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1746 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1747 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1748 alu
.src
[1].chan
= 0;
1752 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
);
1759 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
1761 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_POP
);
1762 ctx
->bc
->cf_last
->pop_count
= pops
;
1766 static int tgsi_if(struct r600_shader_ctx
*ctx
)
1768 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1770 emit_logic_pred(ctx
, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
);
1773 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= FC_IF
;
1774 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
= NULL
;
1775 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_JUMP
);
1777 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
1781 static int tgsi_else(struct r600_shader_ctx
*ctx
)
1783 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1784 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_ELSE
);
1785 ctx
->bc
->cf_last
->pop_count
= 1;
1788 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
= ctx
->bc
->cf_last
;
1789 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
1793 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
1796 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
1797 R600_ERR("if/endif unbalanced in shader\n");
1801 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
1802 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
1803 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
1805 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
1812 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
1813 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1814 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
1815 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
1816 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
1817 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
1818 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
1819 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1820 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
1821 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
1822 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
1823 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
1824 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1825 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
1826 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
1827 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
1828 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
1829 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
1830 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
1831 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
1832 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1834 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1835 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1837 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1838 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1839 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
1840 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1841 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
1842 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1843 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
1844 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
1845 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
1846 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
1848 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1849 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
1850 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1851 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
1852 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
1853 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
1854 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
1855 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
}, /* predicated kill */
1856 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1857 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1858 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1859 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1860 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1861 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
1862 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1863 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
1864 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
1865 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
1866 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
1867 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1868 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
1869 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1870 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
1871 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1872 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1873 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1874 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1875 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1876 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1877 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1878 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1879 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1880 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1881 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
1882 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
1883 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1884 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
1885 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1886 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1887 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
1888 {TGSI_OPCODE_TXL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1889 {TGSI_OPCODE_BRK
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1890 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
1892 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1893 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1894 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
1895 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
1897 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1898 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1899 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1900 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1901 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1902 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1903 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1904 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
1905 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1907 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1908 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1909 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1910 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1911 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1912 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1913 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1914 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1915 {TGSI_OPCODE_CONT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1916 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1917 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1918 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1919 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1920 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1921 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1923 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1924 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1925 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1926 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1927 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1929 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1930 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1931 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1932 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1933 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1934 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1935 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1936 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1937 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
1938 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
1940 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1941 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1942 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1943 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1944 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1945 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1946 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1947 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1948 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1949 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1950 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1951 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1952 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1953 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1954 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1955 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1956 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1957 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1958 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1959 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1960 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1961 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1962 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1963 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1964 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1965 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1966 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
1967 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},