2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #include "pipe/p_shader_tokens.h"
24 #include "tgsi/tgsi_parse.h"
25 #include "tgsi/tgsi_scan.h"
26 #include "tgsi/tgsi_dump.h"
27 #include "util/u_format.h"
28 #include "r600_pipe.h"
31 #include "r600_opcodes.h"
36 static void r600_pipe_shader_vs(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
38 struct r600_pipe_state
*rstate
= &shader
->rstate
;
39 struct r600_shader
*rshader
= &shader
->shader
;
40 unsigned spi_vs_out_id
[10];
43 /* clear previous register */
46 /* so far never got proper semantic id from tgsi */
47 /* FIXME better to move this in config things so they get emited
48 * only one time per cs
50 for (i
= 0; i
< 10; i
++) {
53 for (i
= 0; i
< 32; i
++) {
54 tmp
= i
<< ((i
& 3) * 8);
55 spi_vs_out_id
[i
/ 4] |= tmp
;
57 for (i
= 0; i
< 10; i
++) {
58 r600_pipe_state_add_reg(rstate
,
59 R_028614_SPI_VS_OUT_ID_0
+ i
* 4,
60 spi_vs_out_id
[i
], 0xFFFFFFFF, NULL
);
63 r600_pipe_state_add_reg(rstate
,
64 R_0286C4_SPI_VS_OUT_CONFIG
,
65 S_0286C4_VS_EXPORT_COUNT(rshader
->noutput
- 2),
67 r600_pipe_state_add_reg(rstate
,
68 R_028868_SQ_PGM_RESOURCES_VS
,
69 S_028868_NUM_GPRS(rshader
->bc
.ngpr
) |
70 S_028868_STACK_SIZE(rshader
->bc
.nstack
),
72 r600_pipe_state_add_reg(rstate
,
73 R_0288D0_SQ_PGM_CF_OFFSET_VS
,
74 0x00000000, 0xFFFFFFFF, NULL
);
75 r600_pipe_state_add_reg(rstate
,
76 R_028858_SQ_PGM_START_VS
,
77 r600_bo_offset(shader
->bo
) >> 8, 0xFFFFFFFF, shader
->bo
);
80 r600_pipe_state_add_reg(rstate
,
81 R_0288A4_SQ_PGM_RESOURCES_FS
,
82 0x00000000, 0xFFFFFFFF, NULL
);
83 r600_pipe_state_add_reg(rstate
,
84 R_0288DC_SQ_PGM_CF_OFFSET_FS
,
85 0x00000000, 0xFFFFFFFF, NULL
);
86 r600_pipe_state_add_reg(rstate
,
87 R_028894_SQ_PGM_START_FS
,
88 r600_bo_offset(shader
->bo_fetch
) >> 8, 0xFFFFFFFF, shader
->bo_fetch
);
90 r600_pipe_state_add_reg(rstate
,
91 R_03E200_SQ_LOOP_CONST_0
+ (32 * 4), 0x01000FFF,
96 int r600_find_vs_semantic_index(struct r600_shader
*vs
,
97 struct r600_shader
*ps
, int id
)
99 struct r600_shader_io
*input
= &ps
->input
[id
];
101 for (int i
= 0; i
< vs
->noutput
; i
++) {
102 if (input
->name
== vs
->output
[i
].name
&&
103 input
->sid
== vs
->output
[i
].sid
) {
110 static void r600_pipe_shader_ps(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
112 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
113 struct r600_pipe_state
*rstate
= &shader
->rstate
;
114 struct r600_shader
*rshader
= &shader
->shader
;
115 unsigned i
, tmp
, exports_ps
, num_cout
, spi_ps_in_control_0
, spi_input_z
, spi_ps_in_control_1
;
116 int pos_index
= -1, face_index
= -1;
120 for (i
= 0; i
< rshader
->ninput
; i
++) {
121 if (rshader
->input
[i
].name
== TGSI_SEMANTIC_POSITION
)
123 if (rshader
->input
[i
].name
== TGSI_SEMANTIC_FACE
)
127 for (i
= 0; i
< rshader
->noutput
; i
++) {
128 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
)
129 r600_pipe_state_add_reg(rstate
,
130 R_02880C_DB_SHADER_CONTROL
,
131 S_02880C_Z_EXPORT_ENABLE(1),
132 S_02880C_Z_EXPORT_ENABLE(1), NULL
);
133 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
)
134 r600_pipe_state_add_reg(rstate
,
135 R_02880C_DB_SHADER_CONTROL
,
136 S_02880C_STENCIL_REF_EXPORT_ENABLE(1),
137 S_02880C_STENCIL_REF_EXPORT_ENABLE(1), NULL
);
142 for (i
= 0; i
< rshader
->noutput
; i
++) {
143 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
|| rshader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
)
145 else if (rshader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
149 exports_ps
|= S_028854_EXPORT_COLORS(num_cout
);
151 /* always at least export 1 component per pixel */
155 spi_ps_in_control_0
= S_0286CC_NUM_INTERP(rshader
->ninput
) |
156 S_0286CC_PERSP_GRADIENT_ENA(1);
158 if (pos_index
!= -1) {
159 spi_ps_in_control_0
|= (S_0286CC_POSITION_ENA(1) |
160 S_0286CC_POSITION_CENTROID(rshader
->input
[pos_index
].centroid
) |
161 S_0286CC_POSITION_ADDR(rshader
->input
[pos_index
].gpr
) |
162 S_0286CC_BARYC_SAMPLE_CNTL(1));
166 spi_ps_in_control_1
= 0;
167 if (face_index
!= -1) {
168 spi_ps_in_control_1
|= S_0286D0_FRONT_FACE_ENA(1) |
169 S_0286D0_FRONT_FACE_ADDR(rshader
->input
[face_index
].gpr
);
172 r600_pipe_state_add_reg(rstate
, R_0286CC_SPI_PS_IN_CONTROL_0
, spi_ps_in_control_0
, 0xFFFFFFFF, NULL
);
173 r600_pipe_state_add_reg(rstate
, R_0286D0_SPI_PS_IN_CONTROL_1
, spi_ps_in_control_1
, 0xFFFFFFFF, NULL
);
174 r600_pipe_state_add_reg(rstate
, R_0286D8_SPI_INPUT_Z
, spi_input_z
, 0xFFFFFFFF, NULL
);
175 r600_pipe_state_add_reg(rstate
,
176 R_028840_SQ_PGM_START_PS
,
177 r600_bo_offset(shader
->bo
) >> 8, 0xFFFFFFFF, shader
->bo
);
178 r600_pipe_state_add_reg(rstate
,
179 R_028850_SQ_PGM_RESOURCES_PS
,
180 S_028868_NUM_GPRS(rshader
->bc
.ngpr
) |
181 S_028868_STACK_SIZE(rshader
->bc
.nstack
),
183 r600_pipe_state_add_reg(rstate
,
184 R_028854_SQ_PGM_EXPORTS_PS
,
185 exports_ps
, 0xFFFFFFFF, NULL
);
186 r600_pipe_state_add_reg(rstate
,
187 R_0288CC_SQ_PGM_CF_OFFSET_PS
,
188 0x00000000, 0xFFFFFFFF, NULL
);
190 if (rshader
->uses_kill
) {
191 /* only set some bits here, the other bits are set in the dsa state */
192 r600_pipe_state_add_reg(rstate
,
193 R_02880C_DB_SHADER_CONTROL
,
194 S_02880C_KILL_ENABLE(1),
195 S_02880C_KILL_ENABLE(1), NULL
);
197 r600_pipe_state_add_reg(rstate
,
198 R_03E200_SQ_LOOP_CONST_0
, 0x01000FFF,
202 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
204 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
205 struct r600_shader
*rshader
= &shader
->shader
;
208 /* copy new shader */
209 if (rshader
->processor_type
== TGSI_PROCESSOR_VERTEX
&& shader
->bo_fetch
== NULL
) {
210 shader
->bo_fetch
= r600_bo(rctx
->radeon
, rshader
->bc_fetch
.ndw
* 4, 4096, 0, 0);
211 if (shader
->bo_fetch
== NULL
) {
214 ptr
= r600_bo_map(rctx
->radeon
, shader
->bo_fetch
, 0, NULL
);
215 memcpy(ptr
, rshader
->bc_fetch
.bytecode
, rshader
->bc_fetch
.ndw
* 4);
216 r600_bo_unmap(rctx
->radeon
, shader
->bo_fetch
);
218 if (shader
->bo
== NULL
) {
219 shader
->bo
= r600_bo(rctx
->radeon
, rshader
->bc
.ndw
* 4, 4096, 0, 0);
220 if (shader
->bo
== NULL
) {
223 ptr
= r600_bo_map(rctx
->radeon
, shader
->bo
, 0, NULL
);
224 memcpy(ptr
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* 4);
225 r600_bo_unmap(rctx
->radeon
, shader
->bo
);
228 switch (rshader
->processor_type
) {
229 case TGSI_PROCESSOR_VERTEX
:
230 if (rshader
->family
>= CHIP_CEDAR
) {
231 evergreen_pipe_shader_vs(ctx
, shader
);
233 r600_pipe_shader_vs(ctx
, shader
);
236 case TGSI_PROCESSOR_FRAGMENT
:
237 if (rshader
->family
>= CHIP_CEDAR
) {
238 evergreen_pipe_shader_ps(ctx
, shader
);
240 r600_pipe_shader_ps(ctx
, shader
);
249 static int r600_shader_update(struct pipe_context
*ctx
, struct r600_pipe_shader
*rshader
)
252 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
253 struct r600_shader
*shader
= &rshader
->shader
;
254 const struct util_format_description
*desc
;
255 enum pipe_format resource_format
[160];
256 unsigned i
, nresources
= 0;
257 struct r600_bc
*bc
= &shader
->bc_fetch
;
258 struct r600_bc_cf
*cf
;
259 struct r600_bc_vtx
*vtx
;
261 if (shader
->processor_type
!= TGSI_PROCESSOR_VERTEX
)
263 /* doing a full memcmp fell over the refcount */
264 if ((rshader
->vertex_elements
.count
== rctx
->vertex_elements
->count
) &&
265 (!memcmp(&rshader
->vertex_elements
.elements
, &rctx
->vertex_elements
->elements
,
266 rctx
->vertex_elements
->count
* sizeof(struct pipe_vertex_element
)))) {
269 rshader
->vertex_elements
= *rctx
->vertex_elements
;
270 for (i
= 0; i
< rctx
->vertex_elements
->count
; i
++) {
271 resource_format
[nresources
++] = rctx
->vertex_elements
->hw_format
[i
];
273 r600_bo_reference(rctx
->radeon
, &rshader
->bo_fetch
, NULL
);
274 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
276 case V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
277 case V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC
:
278 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
279 desc
= util_format_description(resource_format
[vtx
->buffer_id
]);
281 R600_ERR("unknown format %d\n", resource_format
[vtx
->buffer_id
]);
284 vtx
->dst_sel_x
= desc
->swizzle
[0];
285 vtx
->dst_sel_y
= desc
->swizzle
[1];
286 vtx
->dst_sel_z
= desc
->swizzle
[2];
287 vtx
->dst_sel_w
= desc
->swizzle
[3];
294 return r600_bc_build(&shader
->bc_fetch
);
300 int r600_pipe_shader_update(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
302 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
305 return r600_pipe_shader(ctx
, shader
);
308 int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
);
309 int r600_pipe_shader_create(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
, const struct tgsi_token
*tokens
)
311 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
314 //fprintf(stderr, "--------------------------------------------------------------\n");
315 //tgsi_dump(tokens, 0);
316 shader
->shader
.family
= r600_get_family(rctx
->radeon
);
317 r
= r600_shader_from_tgsi(tokens
, &shader
->shader
);
319 R600_ERR("translation from TGSI failed !\n");
322 r
= r600_bc_build(&shader
->shader
.bc
);
324 R600_ERR("building bytecode failed !\n");
327 if (shader
->shader
.processor_type
== TGSI_PROCESSOR_VERTEX
) {
328 r
= r600_bc_build(&shader
->shader
.bc_fetch
);
330 R600_ERR("building bytecode failed !\n");
334 //r600_bc_dump(&shader->shader.bc);
335 //fprintf(stderr, "______________________________________________________________\n");
336 return r600_pipe_shader(ctx
, shader
);
340 r600_pipe_shader_destroy(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
342 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
344 if (shader
->shader
.processor_type
== TGSI_PROCESSOR_VERTEX
) {
345 r600_bo_reference(rctx
->radeon
, &shader
->bo_fetch
, NULL
);
346 r600_bc_clear(&shader
->shader
.bc_fetch
);
349 r600_bo_reference(rctx
->radeon
, &shader
->bo
, NULL
);
351 r600_bc_clear(&shader
->shader
.bc
);
353 /* FIXME: is there more stuff to free? */
357 * tgsi -> r600 shader
359 struct r600_shader_tgsi_instruction
;
361 struct r600_shader_ctx
{
362 struct tgsi_shader_info info
;
363 struct tgsi_parse_context parse
;
364 const struct tgsi_token
*tokens
;
366 unsigned file_offset
[TGSI_FILE_COUNT
];
368 struct r600_shader_tgsi_instruction
*inst_info
;
370 struct r600_bc
*bc_fetch
;
371 struct r600_shader
*shader
;
375 u32 max_driver_temp_used
;
376 /* needed for evergreen interpolation */
377 boolean input_centroid
;
378 boolean input_linear
;
379 boolean input_perspective
;
383 struct r600_shader_tgsi_instruction
{
384 unsigned tgsi_opcode
;
386 unsigned r600_opcode
;
387 int (*process
)(struct r600_shader_ctx
*ctx
);
390 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[], eg_shader_tgsi_instruction
[];
391 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
393 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
395 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
398 if (i
->Instruction
.NumDstRegs
> 1) {
399 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
402 if (i
->Instruction
.Predicate
) {
403 R600_ERR("predicate unsupported\n");
407 if (i
->Instruction
.Label
) {
408 R600_ERR("label unsupported\n");
412 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
413 if (i
->Src
[j
].Register
.Dimension
) {
414 R600_ERR("unsupported src %d (dimension %d)\n", j
,
415 i
->Src
[j
].Register
.Dimension
);
419 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
420 if (i
->Dst
[j
].Register
.Dimension
) {
421 R600_ERR("unsupported dst (dimension)\n");
428 static int evergreen_interp_alu(struct r600_shader_ctx
*ctx
, int input
)
431 struct r600_bc_alu alu
;
432 int gpr
= 0, base_chan
= 0;
435 if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_PERSPECTIVE
) {
437 if (ctx
->shader
->input
[input
].centroid
)
439 } else if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_LINEAR
) {
441 /* if we have perspective add one */
442 if (ctx
->input_perspective
) {
444 /* if we have perspective centroid */
445 if (ctx
->input_centroid
)
448 if (ctx
->shader
->input
[input
].centroid
)
452 /* work out gpr and base_chan from index */
454 base_chan
= (2 * (ij_index
% 2)) + 1;
456 for (i
= 0; i
< 8; i
++) {
457 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
460 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW
;
462 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_XY
;
464 if ((i
> 1) && (i
< 6)) {
465 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
469 alu
.dst
.chan
= i
% 4;
471 alu
.src
[0].sel
= gpr
;
472 alu
.src
[0].chan
= (base_chan
- (i
% 2));
474 alu
.src
[1].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
476 alu
.bank_swizzle_force
= SQ_ALU_VEC_210
;
479 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
487 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
489 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
490 struct r600_bc_vtx vtx
;
494 switch (d
->Declaration
.File
) {
495 case TGSI_FILE_INPUT
:
496 i
= ctx
->shader
->ninput
++;
497 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
498 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
499 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
500 ctx
->shader
->input
[i
].centroid
= d
->Declaration
.Centroid
;
501 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + i
;
502 if (ctx
->type
== TGSI_PROCESSOR_VERTEX
) {
503 /* turn input into fetch */
504 memset(&vtx
, 0, sizeof(struct r600_bc_vtx
));
508 /* register containing the index into the buffer */
511 vtx
.mega_fetch_count
= 0x1F;
512 vtx
.dst_gpr
= ctx
->shader
->input
[i
].gpr
;
517 vtx
.use_const_fields
= 1;
518 r
= r600_bc_add_vtx(ctx
->bc_fetch
, &vtx
);
522 if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
->bc
->chiprev
== CHIPREV_EVERGREEN
) {
523 /* turn input into interpolate on EG */
524 if (ctx
->shader
->input
[i
].name
!= TGSI_SEMANTIC_POSITION
) {
525 if (ctx
->shader
->input
[i
].interpolate
> 0) {
526 ctx
->shader
->input
[i
].lds_pos
= ctx
->shader
->nlds
++;
527 evergreen_interp_alu(ctx
, i
);
532 case TGSI_FILE_OUTPUT
:
533 i
= ctx
->shader
->noutput
++;
534 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
535 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
536 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + i
;
537 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
539 case TGSI_FILE_CONSTANT
:
540 case TGSI_FILE_TEMPORARY
:
541 case TGSI_FILE_SAMPLER
:
542 case TGSI_FILE_ADDRESS
:
545 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
551 static int r600_get_temp(struct r600_shader_ctx
*ctx
)
553 return ctx
->temp_reg
+ ctx
->max_driver_temp_used
++;
557 * for evergreen we need to scan the shader to find the number of GPRs we need to
558 * reserve for interpolation.
560 * we need to know if we are going to emit
561 * any centroid inputs
562 * if perspective and linear are required
564 static int evergreen_gpr_count(struct r600_shader_ctx
*ctx
)
569 ctx
->input_linear
= FALSE
;
570 ctx
->input_perspective
= FALSE
;
571 ctx
->input_centroid
= FALSE
;
572 ctx
->num_interp_gpr
= 1;
574 /* any centroid inputs */
575 for (i
= 0; i
< ctx
->info
.num_inputs
; i
++) {
576 /* skip position/face */
577 if (ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_POSITION
||
578 ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_FACE
)
580 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_LINEAR
)
581 ctx
->input_linear
= TRUE
;
582 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_PERSPECTIVE
)
583 ctx
->input_perspective
= TRUE
;
584 if (ctx
->info
.input_centroid
[i
])
585 ctx
->input_centroid
= TRUE
;
589 /* ignoring sample for now */
590 if (ctx
->input_perspective
)
592 if (ctx
->input_linear
)
594 if (ctx
->input_centroid
)
597 ctx
->num_interp_gpr
+= (num_baryc
+ 1) >> 1;
599 /* TODO PULL MODEL and LINE STIPPLE, FIXED PT POS */
600 return ctx
->num_interp_gpr
;
603 int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
)
605 struct tgsi_full_immediate
*immediate
;
606 struct r600_shader_ctx ctx
;
607 struct r600_bc_output output
[32];
608 unsigned output_done
, noutput
;
612 ctx
.bc
= &shader
->bc
;
613 ctx
.bc_fetch
= &shader
->bc_fetch
;
615 r
= r600_bc_init(ctx
.bc
, shader
->family
);
619 tgsi_scan_shader(tokens
, &ctx
.info
);
620 tgsi_parse_init(&ctx
.parse
, tokens
);
621 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
622 shader
->processor_type
= ctx
.type
;
623 if (shader
->processor_type
== TGSI_PROCESSOR_VERTEX
) {
624 r
= r600_bc_init(ctx
.bc_fetch
, shader
->family
);
627 ctx
.bc_fetch
->type
= -1;
629 ctx
.bc
->type
= shader
->processor_type
;
631 /* register allocations */
632 /* Values [0,127] correspond to GPR[0..127].
633 * Values [128,159] correspond to constant buffer bank 0
634 * Values [160,191] correspond to constant buffer bank 1
635 * Values [256,511] correspond to cfile constants c[0..255].
636 * Other special values are shown in the list below.
637 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
638 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
639 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
640 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
641 * 248 SQ_ALU_SRC_0: special constant 0.0.
642 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
643 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
644 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
645 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
646 * 253 SQ_ALU_SRC_LITERAL: literal constant.
647 * 254 SQ_ALU_SRC_PV: previous vector result.
648 * 255 SQ_ALU_SRC_PS: previous scalar result.
650 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
651 ctx
.file_offset
[i
] = 0;
653 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
654 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
655 if (ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
) {
656 r600_bc_add_cfinst(ctx
.bc
, EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
658 r600_bc_add_cfinst(ctx
.bc
, V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
661 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
) {
662 ctx
.file_offset
[TGSI_FILE_INPUT
] = evergreen_gpr_count(&ctx
);
664 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
665 ctx
.info
.file_count
[TGSI_FILE_INPUT
];
666 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
667 ctx
.info
.file_count
[TGSI_FILE_OUTPUT
];
669 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 128;
671 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = 253;
672 ctx
.temp_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
673 ctx
.info
.file_count
[TGSI_FILE_TEMPORARY
];
678 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
679 tgsi_parse_token(&ctx
.parse
);
680 switch (ctx
.parse
.FullToken
.Token
.Type
) {
681 case TGSI_TOKEN_TYPE_IMMEDIATE
:
682 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
683 ctx
.literals
= realloc(ctx
.literals
, (ctx
.nliterals
+ 1) * 16);
684 if(ctx
.literals
== NULL
) {
688 ctx
.literals
[ctx
.nliterals
* 4 + 0] = immediate
->u
[0].Uint
;
689 ctx
.literals
[ctx
.nliterals
* 4 + 1] = immediate
->u
[1].Uint
;
690 ctx
.literals
[ctx
.nliterals
* 4 + 2] = immediate
->u
[2].Uint
;
691 ctx
.literals
[ctx
.nliterals
* 4 + 3] = immediate
->u
[3].Uint
;
694 case TGSI_TOKEN_TYPE_DECLARATION
:
695 r
= tgsi_declaration(&ctx
);
699 case TGSI_TOKEN_TYPE_INSTRUCTION
:
700 r
= tgsi_is_supported(&ctx
);
703 ctx
.max_driver_temp_used
= 0;
704 /* reserve first tmp for everyone */
706 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
707 if (ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
)
708 ctx
.inst_info
= &eg_shader_tgsi_instruction
[opcode
];
710 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
711 r
= ctx
.inst_info
->process(&ctx
);
714 r
= r600_bc_add_literal(ctx
.bc
, ctx
.value
);
719 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
725 noutput
= shader
->noutput
;
726 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
727 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
728 output
[i
].gpr
= shader
->output
[i
].gpr
;
729 output
[i
].elem_size
= 3;
730 output
[i
].swizzle_x
= 0;
731 output
[i
].swizzle_y
= 1;
732 output
[i
].swizzle_z
= 2;
733 output
[i
].swizzle_w
= 3;
734 output
[i
].barrier
= 1;
735 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
736 output
[i
].array_base
= i
- pos0
;
737 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
739 case TGSI_PROCESSOR_VERTEX
:
740 if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
741 output
[i
].array_base
= 60;
742 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
743 /* position doesn't count in array_base */
746 if (shader
->output
[i
].name
== TGSI_SEMANTIC_PSIZE
) {
747 output
[i
].array_base
= 61;
748 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
749 /* position doesn't count in array_base */
753 case TGSI_PROCESSOR_FRAGMENT
:
754 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
755 output
[i
].array_base
= shader
->output
[i
].sid
;
756 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
757 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
758 output
[i
].array_base
= 61;
759 output
[i
].swizzle_x
= 2;
760 output
[i
].swizzle_y
= 7;
761 output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
762 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
763 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
) {
764 output
[i
].array_base
= 61;
765 output
[i
].swizzle_x
= 7;
766 output
[i
].swizzle_y
= 1;
767 output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
768 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
770 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
776 R600_ERR("unsupported processor type %d\n", ctx
.type
);
781 /* add fake param output for vertex shader if no param is exported */
782 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
783 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
784 if (output
[i
].type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
) {
790 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
792 output
[i
].elem_size
= 3;
793 output
[i
].swizzle_x
= 0;
794 output
[i
].swizzle_y
= 1;
795 output
[i
].swizzle_z
= 2;
796 output
[i
].swizzle_w
= 3;
797 output
[i
].barrier
= 1;
798 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
799 output
[i
].array_base
= 0;
800 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
804 /* add fake pixel export */
805 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& !noutput
) {
806 memset(&output
[0], 0, sizeof(struct r600_bc_output
));
808 output
[0].elem_size
= 3;
809 output
[0].swizzle_x
= 7;
810 output
[0].swizzle_y
= 7;
811 output
[0].swizzle_z
= 7;
812 output
[0].swizzle_w
= 7;
813 output
[0].barrier
= 1;
814 output
[0].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
815 output
[0].array_base
= 0;
816 output
[0].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
819 /* set export done on last export of each type */
820 for (i
= noutput
- 1, output_done
= 0; i
>= 0; i
--) {
821 if (i
== (noutput
- 1)) {
822 output
[i
].end_of_program
= 1;
824 if (!(output_done
& (1 << output
[i
].type
))) {
825 output_done
|= (1 << output
[i
].type
);
826 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
);
829 /* add return to fetch shader */
830 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
831 if (ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
) {
832 r600_bc_add_cfinst(ctx
.bc_fetch
, EG_V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
834 r600_bc_add_cfinst(ctx
.bc_fetch
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
837 /* add output to bytecode */
838 for (i
= 0; i
< noutput
; i
++) {
839 r
= r600_bc_add_output(ctx
.bc
, &output
[i
]);
844 tgsi_parse_free(&ctx
.parse
);
848 tgsi_parse_free(&ctx
.parse
);
852 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
854 R600_ERR("%d tgsi opcode unsupported\n", ctx
->inst_info
->tgsi_opcode
);
858 static int tgsi_end(struct r600_shader_ctx
*ctx
)
863 static int tgsi_src(struct r600_shader_ctx
*ctx
,
864 const struct tgsi_full_src_register
*tgsi_src
,
865 struct r600_bc_alu_src
*r600_src
)
868 memset(r600_src
, 0, sizeof(struct r600_bc_alu_src
));
869 r600_src
->sel
= tgsi_src
->Register
.Index
;
870 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
872 index
= tgsi_src
->Register
.Index
;
873 ctx
->value
[0] = ctx
->literals
[index
* 4 + 0];
874 ctx
->value
[1] = ctx
->literals
[index
* 4 + 1];
875 ctx
->value
[2] = ctx
->literals
[index
* 4 + 2];
876 ctx
->value
[3] = ctx
->literals
[index
* 4 + 3];
878 if (tgsi_src
->Register
.Indirect
)
879 r600_src
->rel
= V_SQ_REL_RELATIVE
;
880 r600_src
->neg
= tgsi_src
->Register
.Negate
;
881 r600_src
->abs
= tgsi_src
->Register
.Absolute
;
882 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
886 static int tgsi_dst(struct r600_shader_ctx
*ctx
,
887 const struct tgsi_full_dst_register
*tgsi_dst
,
889 struct r600_bc_alu_dst
*r600_dst
)
891 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
893 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
894 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
895 r600_dst
->chan
= swizzle
;
897 if (tgsi_dst
->Register
.Indirect
)
898 r600_dst
->rel
= V_SQ_REL_RELATIVE
;
899 if (inst
->Instruction
.Saturate
) {
905 static unsigned tgsi_chan(const struct tgsi_full_src_register
*tgsi_src
, unsigned swizzle
)
909 return tgsi_src
->Register
.SwizzleX
;
911 return tgsi_src
->Register
.SwizzleY
;
913 return tgsi_src
->Register
.SwizzleZ
;
915 return tgsi_src
->Register
.SwizzleW
;
921 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
923 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
924 struct r600_bc_alu alu
;
925 int i
, j
, k
, nconst
, r
;
927 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
928 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
931 r
= tgsi_src(ctx
, &inst
->Src
[i
], &r600_src
[i
]);
936 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
937 if (j
> 0 && inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
938 int treg
= r600_get_temp(ctx
);
939 for (k
= 0; k
< 4; k
++) {
940 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
941 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
942 alu
.src
[0].sel
= r600_src
[i
].sel
;
944 alu
.src
[0].rel
= r600_src
[i
].rel
;
950 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
954 r600_src
[i
].sel
= treg
;
962 /* need to move any immediate into a temp - for trig functions which use literal for PI stuff */
963 static int tgsi_split_literal_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
965 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
966 struct r600_bc_alu alu
;
967 int i
, j
, k
, nliteral
, r
;
969 for (i
= 0, nliteral
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
970 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_IMMEDIATE
) {
974 for (i
= 0, j
= nliteral
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
975 if (j
> 0 && inst
->Src
[i
].Register
.File
== TGSI_FILE_IMMEDIATE
) {
976 int treg
= r600_get_temp(ctx
);
977 for (k
= 0; k
< 4; k
++) {
978 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
979 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
980 alu
.src
[0].sel
= r600_src
[i
].sel
;
987 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
991 r
= r600_bc_add_literal(ctx
->bc
, &ctx
->literals
[inst
->Src
[i
].Register
.Index
* 4]);
994 r600_src
[i
].sel
= treg
;
1001 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
)
1003 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1004 struct r600_bc_alu_src r600_src
[3];
1005 struct r600_bc_alu alu
;
1009 for (i
= 0; i
< 4; i
++) {
1010 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
1015 r
= tgsi_split_constant(ctx
, r600_src
);
1018 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1021 for (i
= 0; i
< lasti
+ 1; i
++) {
1022 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1025 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1026 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1030 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1032 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1033 alu
.src
[j
] = r600_src
[j
];
1034 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1037 alu
.src
[0] = r600_src
[1];
1038 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], i
);
1040 alu
.src
[1] = r600_src
[0];
1041 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1043 /* handle some special cases */
1044 switch (ctx
->inst_info
->tgsi_opcode
) {
1045 case TGSI_OPCODE_SUB
:
1048 case TGSI_OPCODE_ABS
:
1057 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1064 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
1066 return tgsi_op2_s(ctx
, 0);
1069 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
1071 return tgsi_op2_s(ctx
, 1);
1075 * r600 - trunc to -PI..PI range
1076 * r700 - normalize by dividing by 2PI
1079 static int tgsi_setup_trig(struct r600_shader_ctx
*ctx
,
1080 struct r600_bc_alu_src r600_src
[3])
1082 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1084 uint32_t lit_vals
[4];
1085 struct r600_bc_alu alu
;
1087 memset(lit_vals
, 0, 4*4);
1088 r
= tgsi_split_constant(ctx
, r600_src
);
1091 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1095 lit_vals
[0] = fui(1.0 /(3.1415926535 * 2));
1096 lit_vals
[1] = fui(0.5f
);
1098 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1099 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1103 alu
.dst
.sel
= ctx
->temp_reg
;
1106 alu
.src
[0] = r600_src
[0];
1107 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1109 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1110 alu
.src
[1].chan
= 0;
1111 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1112 alu
.src
[2].chan
= 1;
1114 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1117 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
1121 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1122 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
1125 alu
.dst
.sel
= ctx
->temp_reg
;
1128 alu
.src
[0].sel
= ctx
->temp_reg
;
1129 alu
.src
[0].chan
= 0;
1131 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1135 if (ctx
->bc
->chiprev
== CHIPREV_R600
) {
1136 lit_vals
[0] = fui(3.1415926535897f
* 2.0f
);
1137 lit_vals
[1] = fui(-3.1415926535897f
);
1139 lit_vals
[0] = fui(1.0f
);
1140 lit_vals
[1] = fui(-0.5f
);
1143 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1144 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1148 alu
.dst
.sel
= ctx
->temp_reg
;
1151 alu
.src
[0].sel
= ctx
->temp_reg
;
1152 alu
.src
[0].chan
= 0;
1154 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1155 alu
.src
[1].chan
= 0;
1156 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1157 alu
.src
[2].chan
= 1;
1159 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1162 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
1168 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
1170 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1171 struct r600_bc_alu_src r600_src
[3];
1172 struct r600_bc_alu alu
;
1176 r
= tgsi_setup_trig(ctx
, r600_src
);
1180 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1181 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1183 alu
.dst
.sel
= ctx
->temp_reg
;
1186 alu
.src
[0].sel
= ctx
->temp_reg
;
1187 alu
.src
[0].chan
= 0;
1189 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1193 /* replicate result */
1194 for (i
= 0; i
< 4; i
++) {
1195 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
))
1198 for (i
= 0; i
< lasti
+ 1; i
++) {
1199 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1202 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1203 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1205 alu
.src
[0].sel
= ctx
->temp_reg
;
1206 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1211 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1218 static int tgsi_scs(struct r600_shader_ctx
*ctx
)
1220 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1221 struct r600_bc_alu_src r600_src
[3];
1222 struct r600_bc_alu alu
;
1225 /* We'll only need the trig stuff if we are going to write to the
1226 * X or Y components of the destination vector.
1228 if (likely(inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_XY
)) {
1229 r
= tgsi_setup_trig(ctx
, r600_src
);
1235 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_X
) {
1236 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1237 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
1238 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1242 alu
.src
[0].sel
= ctx
->temp_reg
;
1243 alu
.src
[0].chan
= 0;
1245 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1251 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Y
) {
1252 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1253 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
1254 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1258 alu
.src
[0].sel
= ctx
->temp_reg
;
1259 alu
.src
[0].chan
= 0;
1261 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1267 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Z
) {
1268 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1270 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1272 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1276 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1277 alu
.src
[0].chan
= 0;
1281 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1285 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1291 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
1292 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1294 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1296 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1300 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1301 alu
.src
[0].chan
= 0;
1305 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1309 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1317 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
1319 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1320 struct r600_bc_alu alu
;
1323 for (i
= 0; i
< 4; i
++) {
1324 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1325 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1329 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1331 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
1332 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1335 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1338 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1343 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1347 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1351 /* kill must be last in ALU */
1352 ctx
->bc
->force_add_cf
= 1;
1353 ctx
->shader
->uses_kill
= TRUE
;
1357 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
1359 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1360 struct r600_bc_alu alu
;
1361 struct r600_bc_alu_src r600_src
[3];
1364 r
= tgsi_split_constant(ctx
, r600_src
);
1367 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1372 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1373 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1374 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
1375 alu
.src
[0].chan
= 0;
1376 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1379 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
1380 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1384 /* dst.y = max(src.x, 0.0) */
1385 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1386 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1387 alu
.src
[0] = r600_src
[0];
1388 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1389 alu
.src
[1].chan
= 0;
1390 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1393 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
1394 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1399 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1400 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1401 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1402 alu
.src
[0].chan
= 0;
1403 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1406 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
1408 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1412 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1416 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
1421 /* dst.z = log(src.y) */
1422 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1423 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1424 alu
.src
[0] = r600_src
[0];
1425 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1426 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1430 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1434 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1438 chan
= alu
.dst
.chan
;
1441 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
1442 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1443 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
1444 alu
.src
[0] = r600_src
[0];
1445 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1446 alu
.src
[1].sel
= sel
;
1447 alu
.src
[1].chan
= chan
;
1449 alu
.src
[2] = r600_src
[0];
1450 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], 0);
1451 alu
.dst
.sel
= ctx
->temp_reg
;
1456 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1460 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1463 /* dst.z = exp(tmp.x) */
1464 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1465 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1466 alu
.src
[0].sel
= ctx
->temp_reg
;
1467 alu
.src
[0].chan
= 0;
1468 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1472 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1479 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
1481 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1482 struct r600_bc_alu alu
;
1485 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1488 * For state trackers other than OpenGL, we'll want to use
1489 * _RECIPSQRT_IEEE instead.
1491 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
1493 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1494 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1497 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1500 alu
.dst
.sel
= ctx
->temp_reg
;
1503 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1506 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1509 /* replicate result */
1510 return tgsi_helper_tempx_replicate(ctx
);
1513 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1515 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1516 struct r600_bc_alu alu
;
1519 for (i
= 0; i
< 4; i
++) {
1520 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1521 alu
.src
[0].sel
= ctx
->temp_reg
;
1522 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1524 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1527 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1530 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1537 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1539 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1540 struct r600_bc_alu alu
;
1543 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1544 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1545 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1546 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1549 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1551 alu
.dst
.sel
= ctx
->temp_reg
;
1554 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1557 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1560 /* replicate result */
1561 return tgsi_helper_tempx_replicate(ctx
);
1564 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1566 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1567 struct r600_bc_alu alu
;
1571 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1572 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1573 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1576 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1577 alu
.dst
.sel
= ctx
->temp_reg
;
1580 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1583 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1587 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1588 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL_IEEE
);
1589 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[0]);
1592 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], 0);
1593 alu
.src
[1].sel
= ctx
->temp_reg
;
1594 alu
.dst
.sel
= ctx
->temp_reg
;
1597 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1600 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1603 /* POW(a,b) = EXP2(b * LOG2(a))*/
1604 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1605 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1606 alu
.src
[0].sel
= ctx
->temp_reg
;
1607 alu
.dst
.sel
= ctx
->temp_reg
;
1610 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1613 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1616 return tgsi_helper_tempx_replicate(ctx
);
1619 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1621 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1622 struct r600_bc_alu alu
;
1623 struct r600_bc_alu_src r600_src
[3];
1626 r
= tgsi_split_constant(ctx
, r600_src
);
1629 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1633 /* tmp = (src > 0 ? 1 : src) */
1634 for (i
= 0; i
< 4; i
++) {
1635 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1636 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1639 alu
.dst
.sel
= ctx
->temp_reg
;
1642 alu
.src
[0] = r600_src
[0];
1643 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1645 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1647 alu
.src
[2] = r600_src
[0];
1648 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], i
);
1651 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1655 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1659 /* dst = (-tmp > 0 ? -1 : tmp) */
1660 for (i
= 0; i
< 4; i
++) {
1661 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1662 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1664 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1668 alu
.src
[0].sel
= ctx
->temp_reg
;
1669 alu
.src
[0].chan
= i
;
1672 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1675 alu
.src
[2].sel
= ctx
->temp_reg
;
1676 alu
.src
[2].chan
= i
;
1680 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1687 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1689 struct r600_bc_alu alu
;
1692 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1695 for (i
= 0; i
< 4; i
++) {
1696 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1697 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1698 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
1701 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1702 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1705 alu
.src
[0].sel
= ctx
->temp_reg
;
1706 alu
.src
[0].chan
= i
;
1711 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1718 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1720 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1721 struct r600_bc_alu_src r600_src
[3];
1722 struct r600_bc_alu alu
;
1725 r
= tgsi_split_constant(ctx
, r600_src
);
1728 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1731 /* do it in 2 step as op3 doesn't support writemask */
1732 for (i
= 0; i
< 4; i
++) {
1733 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1734 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1735 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1736 alu
.src
[j
] = r600_src
[j
];
1737 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1739 alu
.dst
.sel
= ctx
->temp_reg
;
1746 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1750 return tgsi_helper_copy(ctx
, inst
);
1753 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1755 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1756 struct r600_bc_alu_src r600_src
[3];
1757 struct r600_bc_alu alu
;
1760 r
= tgsi_split_constant(ctx
, r600_src
);
1763 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1766 for (i
= 0; i
< 4; i
++) {
1767 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1768 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1769 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1770 alu
.src
[j
] = r600_src
[j
];
1771 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1773 alu
.dst
.sel
= ctx
->temp_reg
;
1776 /* handle some special cases */
1777 switch (ctx
->inst_info
->tgsi_opcode
) {
1778 case TGSI_OPCODE_DP2
:
1780 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1781 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1784 case TGSI_OPCODE_DP3
:
1786 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1787 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1790 case TGSI_OPCODE_DPH
:
1792 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1793 alu
.src
[0].chan
= 0;
1803 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1807 return tgsi_helper_copy(ctx
, inst
);
1810 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1812 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1813 struct r600_bc_tex tex
;
1814 struct r600_bc_alu alu
;
1818 boolean src_not_temp
= inst
->Src
[0].Register
.File
!= TGSI_FILE_TEMPORARY
;
1819 uint32_t lit_vals
[4];
1821 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
1823 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1824 /* Add perspective divide */
1825 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1826 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1827 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1831 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1832 alu
.dst
.sel
= ctx
->temp_reg
;
1836 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1840 for (i
= 0; i
< 3; i
++) {
1841 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1842 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1843 alu
.src
[0].sel
= ctx
->temp_reg
;
1844 alu
.src
[0].chan
= 3;
1845 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1848 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1849 alu
.dst
.sel
= ctx
->temp_reg
;
1852 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1856 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1857 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1858 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1859 alu
.src
[0].chan
= 0;
1860 alu
.dst
.sel
= ctx
->temp_reg
;
1864 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1867 src_not_temp
= FALSE
;
1868 src_gpr
= ctx
->temp_reg
;
1871 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1872 int src_chan
, src2_chan
;
1874 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
1875 for (i
= 0; i
< 4; i
++) {
1876 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1877 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
1901 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1904 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], src_chan
);
1905 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1908 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], src2_chan
);
1909 alu
.dst
.sel
= ctx
->temp_reg
;
1914 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1919 /* tmp1.z = RCP_e(|tmp1.z|) */
1920 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1921 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1922 alu
.src
[0].sel
= ctx
->temp_reg
;
1923 alu
.src
[0].chan
= 2;
1925 alu
.dst
.sel
= ctx
->temp_reg
;
1929 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1933 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
1934 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
1935 * muladd has no writemask, have to use another temp
1937 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1938 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1941 alu
.src
[0].sel
= ctx
->temp_reg
;
1942 alu
.src
[0].chan
= 0;
1943 alu
.src
[1].sel
= ctx
->temp_reg
;
1944 alu
.src
[1].chan
= 2;
1946 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1947 alu
.src
[2].chan
= 0;
1949 alu
.dst
.sel
= ctx
->temp_reg
;
1953 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1957 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1958 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1961 alu
.src
[0].sel
= ctx
->temp_reg
;
1962 alu
.src
[0].chan
= 1;
1963 alu
.src
[1].sel
= ctx
->temp_reg
;
1964 alu
.src
[1].chan
= 2;
1966 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1967 alu
.src
[2].chan
= 0;
1969 alu
.dst
.sel
= ctx
->temp_reg
;
1974 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1978 lit_vals
[0] = fui(1.5f
);
1980 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
1983 src_not_temp
= FALSE
;
1984 src_gpr
= ctx
->temp_reg
;
1988 for (i
= 0; i
< 4; i
++) {
1989 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1990 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1991 alu
.src
[0].sel
= src_gpr
;
1992 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1993 alu
.dst
.sel
= ctx
->temp_reg
;
1998 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2002 src_gpr
= ctx
->temp_reg
;
2005 opcode
= ctx
->inst_info
->r600_opcode
;
2006 if (opcode
== SQ_TEX_INST_SAMPLE
&&
2007 (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
))
2008 opcode
= SQ_TEX_INST_SAMPLE_C
;
2010 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
2012 tex
.sampler_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
2013 tex
.resource_id
= tex
.sampler_id
;
2014 tex
.src_gpr
= src_gpr
;
2015 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
2016 tex
.dst_sel_x
= (inst
->Dst
[0].Register
.WriteMask
& 1) ? 0 : 7;
2017 tex
.dst_sel_y
= (inst
->Dst
[0].Register
.WriteMask
& 2) ? 1 : 7;
2018 tex
.dst_sel_z
= (inst
->Dst
[0].Register
.WriteMask
& 4) ? 2 : 7;
2019 tex
.dst_sel_w
= (inst
->Dst
[0].Register
.WriteMask
& 8) ? 3 : 7;
2025 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
2032 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
2033 tex
.coord_type_x
= 1;
2034 tex
.coord_type_y
= 1;
2035 tex
.coord_type_z
= 1;
2036 tex
.coord_type_w
= 1;
2039 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
)
2042 r
= r600_bc_add_tex(ctx
->bc
, &tex
);
2046 /* add shadow ambient support - gallium doesn't do it yet */
2050 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
2052 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2053 struct r600_bc_alu_src r600_src
[3];
2054 struct r600_bc_alu alu
;
2058 r
= tgsi_split_constant(ctx
, r600_src
);
2061 r
= tgsi_split_literal_constant(ctx
, r600_src
);
2065 for (i
= 0; i
< 4; i
++) {
2066 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2067 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
2068 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2069 alu
.src
[0].chan
= 0;
2070 alu
.src
[1] = r600_src
[0];
2071 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
2073 alu
.dst
.sel
= ctx
->temp_reg
;
2079 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2083 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2087 /* (1 - src0) * src2 */
2088 for (i
= 0; i
< 4; i
++) {
2089 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2090 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2091 alu
.src
[0].sel
= ctx
->temp_reg
;
2092 alu
.src
[0].chan
= i
;
2093 alu
.src
[1] = r600_src
[2];
2094 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
2095 alu
.dst
.sel
= ctx
->temp_reg
;
2101 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2105 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2109 /* src0 * src1 + (1 - src0) * src2 */
2110 for (i
= 0; i
< 4; i
++) {
2111 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2112 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2114 alu
.src
[0] = r600_src
[0];
2115 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2116 alu
.src
[1] = r600_src
[1];
2117 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
2118 alu
.src
[2].sel
= ctx
->temp_reg
;
2119 alu
.src
[2].chan
= i
;
2120 alu
.dst
.sel
= ctx
->temp_reg
;
2125 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2129 return tgsi_helper_copy(ctx
, inst
);
2132 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
2134 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2135 struct r600_bc_alu_src r600_src
[3];
2136 struct r600_bc_alu alu
;
2140 r
= tgsi_split_constant(ctx
, r600_src
);
2143 r
= tgsi_split_literal_constant(ctx
, r600_src
);
2147 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
2150 for (i
= 0; i
< 4; i
++) {
2151 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2152 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
2153 alu
.src
[0] = r600_src
[0];
2154 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2156 alu
.src
[1] = r600_src
[2];
2157 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
2159 alu
.src
[2] = r600_src
[1];
2160 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[1], i
);
2163 alu
.dst
.sel
= ctx
->temp_reg
;
2165 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2174 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2179 return tgsi_helper_copy(ctx
, inst
);
2183 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
2185 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2186 struct r600_bc_alu_src r600_src
[3];
2187 struct r600_bc_alu alu
;
2188 uint32_t use_temp
= 0;
2191 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
2194 r
= tgsi_split_constant(ctx
, r600_src
);
2197 r
= tgsi_split_literal_constant(ctx
, r600_src
);
2201 for (i
= 0; i
< 4; i
++) {
2202 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2203 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2205 alu
.src
[0] = r600_src
[0];
2208 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
2211 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2214 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
2217 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2218 alu
.src
[0].chan
= i
;
2221 alu
.src
[1] = r600_src
[1];
2224 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
2227 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
2230 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
2233 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2234 alu
.src
[1].chan
= i
;
2237 alu
.dst
.sel
= ctx
->temp_reg
;
2243 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2247 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2252 for (i
= 0; i
< 4; i
++) {
2253 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2254 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2256 alu
.src
[0] = r600_src
[0];
2259 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
2262 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
2265 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2268 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2269 alu
.src
[0].chan
= i
;
2272 alu
.src
[1] = r600_src
[1];
2275 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
2278 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
2281 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
2284 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2285 alu
.src
[1].chan
= i
;
2288 alu
.src
[2].sel
= ctx
->temp_reg
;
2290 alu
.src
[2].chan
= i
;
2293 alu
.dst
.sel
= ctx
->temp_reg
;
2295 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2304 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2308 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2313 return tgsi_helper_copy(ctx
, inst
);
2317 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
2319 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2320 struct r600_bc_alu_src r600_src
[3] = { { 0 } };
2321 struct r600_bc_alu alu
;
2324 /* result.x = 2^floor(src); */
2325 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2326 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2328 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2329 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2333 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2335 alu
.dst
.sel
= ctx
->temp_reg
;
2339 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2343 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2347 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2348 alu
.src
[0].sel
= ctx
->temp_reg
;
2349 alu
.src
[0].chan
= 0;
2351 alu
.dst
.sel
= ctx
->temp_reg
;
2355 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2359 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2364 /* result.y = tmp - floor(tmp); */
2365 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2366 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2368 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
2369 alu
.src
[0] = r600_src
[0];
2370 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2373 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2375 alu
.dst
.sel
= ctx
->temp_reg
;
2376 // r = tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
2384 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2387 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2392 /* result.z = RoughApprox2ToX(tmp);*/
2393 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
2394 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2395 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2396 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2399 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2401 alu
.dst
.sel
= ctx
->temp_reg
;
2407 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2410 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2415 /* result.w = 1.0;*/
2416 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
2417 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2419 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2420 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2421 alu
.src
[0].chan
= 0;
2423 alu
.dst
.sel
= ctx
->temp_reg
;
2427 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2430 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2434 return tgsi_helper_copy(ctx
, inst
);
2437 static int tgsi_log(struct r600_shader_ctx
*ctx
)
2439 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2440 struct r600_bc_alu alu
;
2443 /* result.x = floor(log2(src)); */
2444 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2445 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2447 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2448 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2452 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2454 alu
.dst
.sel
= ctx
->temp_reg
;
2458 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2462 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2466 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2467 alu
.src
[0].sel
= ctx
->temp_reg
;
2468 alu
.src
[0].chan
= 0;
2470 alu
.dst
.sel
= ctx
->temp_reg
;
2475 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2479 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2484 /* result.y = src.x / (2 ^ floor(log2(src.x))); */
2485 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2486 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2488 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2489 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2493 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2495 alu
.dst
.sel
= ctx
->temp_reg
;
2500 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2504 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2508 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2510 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2511 alu
.src
[0].sel
= ctx
->temp_reg
;
2512 alu
.src
[0].chan
= 1;
2514 alu
.dst
.sel
= ctx
->temp_reg
;
2519 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2523 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2527 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2529 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2530 alu
.src
[0].sel
= ctx
->temp_reg
;
2531 alu
.src
[0].chan
= 1;
2533 alu
.dst
.sel
= ctx
->temp_reg
;
2538 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2542 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2546 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2548 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2549 alu
.src
[0].sel
= ctx
->temp_reg
;
2550 alu
.src
[0].chan
= 1;
2552 alu
.dst
.sel
= ctx
->temp_reg
;
2557 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2561 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2565 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2567 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2569 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2573 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2575 alu
.src
[1].sel
= ctx
->temp_reg
;
2576 alu
.src
[1].chan
= 1;
2578 alu
.dst
.sel
= ctx
->temp_reg
;
2583 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2587 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2592 /* result.z = log2(src);*/
2593 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
2594 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2596 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2597 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2601 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2603 alu
.dst
.sel
= ctx
->temp_reg
;
2608 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2612 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2617 /* result.w = 1.0; */
2618 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
2619 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2621 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2622 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2623 alu
.src
[0].chan
= 0;
2625 alu
.dst
.sel
= ctx
->temp_reg
;
2630 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2634 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2639 return tgsi_helper_copy(ctx
, inst
);
2642 static int tgsi_eg_arl(struct r600_shader_ctx
*ctx
)
2644 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2645 struct r600_bc_alu alu
;
2647 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2649 switch (inst
->Instruction
.Opcode
) {
2650 case TGSI_OPCODE_ARL
:
2651 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR
;
2653 case TGSI_OPCODE_ARR
:
2654 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
2661 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2664 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2667 alu
.dst
.sel
= ctx
->temp_reg
;
2669 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2672 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2673 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
;
2674 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2677 alu
.src
[0].sel
= ctx
->temp_reg
;
2678 alu
.src
[0].chan
= 0;
2680 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2685 static int tgsi_r600_arl(struct r600_shader_ctx
*ctx
)
2687 /* TODO from r600c, ar values don't persist between clauses */
2688 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2689 struct r600_bc_alu alu
;
2691 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2693 switch (inst
->Instruction
.Opcode
) {
2694 case TGSI_OPCODE_ARL
:
2695 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR
;
2697 case TGSI_OPCODE_ARR
:
2698 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA
;
2706 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2709 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2713 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2716 ctx
->bc
->cf_last
->r6xx_uses_waterfall
= 1;
2720 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
2722 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2723 struct r600_bc_alu alu
;
2726 for (i
= 0; i
< 4; i
++) {
2727 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2729 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2730 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2734 if (i
== 0 || i
== 3) {
2735 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2737 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2740 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2743 if (i
== 0 || i
== 2) {
2744 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2746 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[1]);
2749 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
2753 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2760 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
2762 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2763 struct r600_bc_alu alu
;
2766 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2770 alu
.dst
.sel
= ctx
->temp_reg
;
2774 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2777 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2778 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2779 alu
.src
[1].chan
= 0;
2783 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
2789 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
2791 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
2792 ctx
->bc
->cf_last
->pop_count
= pops
;
2793 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2797 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
2801 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2805 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
2808 /* TOODO : for 16 vp asic should -= 2; */
2809 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2814 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
2816 if (check_max_only
) {
2829 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
2830 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2831 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2832 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
2838 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2842 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
2845 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2849 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
2850 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2851 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2852 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
2856 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
2858 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
2860 sp
->mid
= (struct r600_bc_cf
**)realloc((void *)sp
->mid
,
2861 sizeof(struct r600_bc_cf
*) * (sp
->num_mid
+ 1));
2862 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
2866 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
2869 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
2870 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
2873 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
2875 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
2887 static int emit_return(struct r600_shader_ctx
*ctx
)
2889 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
2893 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
2896 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_JUMP
);
2897 ctx
->bc
->cf_last
->pop_count
= pops
;
2898 /* TODO work out offset */
2902 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
2907 static void emit_testflag(struct r600_shader_ctx
*ctx
)
2912 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
2915 emit_jump_to_offset(ctx
, 1, 4);
2916 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
2917 pops(ctx
, ifidx
+ 1);
2921 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
2925 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2926 ctx
->bc
->cf_last
->pop_count
= 1;
2928 fc_set_mid(ctx
, fc_sp
);
2934 static int tgsi_if(struct r600_shader_ctx
*ctx
)
2936 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
2938 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
2940 fc_pushlevel(ctx
, FC_IF
);
2942 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
2946 static int tgsi_else(struct r600_shader_ctx
*ctx
)
2948 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
2949 ctx
->bc
->cf_last
->pop_count
= 1;
2951 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
2952 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
2956 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
2959 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
2960 R600_ERR("if/endif unbalanced in shader\n");
2964 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
2965 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2966 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
2968 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2972 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
2976 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
2978 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
2980 fc_pushlevel(ctx
, FC_LOOP
);
2982 /* check stack depth */
2983 callstack_check_depth(ctx
, FC_LOOP
, 0);
2987 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
2991 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
2993 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
2994 R600_ERR("loop/endloop in shader code are not paired.\n");
2998 /* fixup loop pointers - from r600isa
2999 LOOP END points to CF after LOOP START,
3000 LOOP START point to CF after LOOP END
3001 BRK/CONT point to LOOP END CF
3003 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
3005 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
3007 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
3008 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
3010 /* TODO add LOOPRET support */
3012 callstack_decrease_current(ctx
, FC_LOOP
);
3016 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
3020 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
3022 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
3027 R600_ERR("Break not inside loop/endloop pair\n");
3031 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
3032 ctx
->bc
->cf_last
->pop_count
= 1;
3034 fc_set_mid(ctx
, fscp
);
3037 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
3041 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
3042 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
3043 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3044 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
3047 * For state trackers other than OpenGL, we'll want to use
3048 * _RECIP_IEEE instead.
3050 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
3052 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
3053 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
3054 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
3055 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
3056 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3057 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3058 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3059 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
3060 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
3061 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
3062 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
3063 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
3064 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
3065 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3066 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
3067 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3069 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3070 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3072 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3073 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3074 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
3075 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3076 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
3077 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3078 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
3079 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
3080 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
3081 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
3083 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3084 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3085 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3086 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3087 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
3088 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
3089 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
3090 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
3091 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3092 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3093 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3094 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3095 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3096 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
3097 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3098 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
3099 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
3100 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
3101 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
3102 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3103 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3104 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3105 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3106 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3107 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3108 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3109 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3110 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3111 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3112 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
3113 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3114 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3115 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3116 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
3117 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
3118 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
3119 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3120 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3121 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3122 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3123 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3124 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
3125 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
3127 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3128 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3129 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
3130 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
3132 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3133 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3134 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3135 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3136 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3137 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3138 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3139 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
3140 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3142 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3143 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3144 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3145 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3146 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3147 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3148 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3149 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3150 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
3151 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3152 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3153 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
3154 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3155 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
3156 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3158 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3159 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3160 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3161 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3162 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3164 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3165 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3166 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3167 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3168 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3169 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3170 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3171 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3172 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
3173 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
3175 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3176 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3177 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3178 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3179 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3180 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3181 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3182 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3183 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3184 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3185 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3186 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3187 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3188 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3189 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3190 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3191 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3192 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3193 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3194 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3195 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3196 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3197 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3198 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3199 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3200 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3201 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3202 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3205 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
3206 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
3207 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3208 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
3209 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
3210 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
3211 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
3212 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3213 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
3214 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3215 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3216 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3217 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
3218 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
3219 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
3220 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
3221 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
3222 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
3223 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3224 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
3225 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3227 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3228 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3230 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3231 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3232 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
3233 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3234 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
3235 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3236 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
3237 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
3238 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
3239 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
3241 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3242 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3243 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3244 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3245 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
3246 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
3247 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
3248 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
3249 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3250 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3251 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3252 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3253 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3254 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
3255 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3256 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
3257 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
3258 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
3259 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
3260 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3261 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3262 {TGSI_OPCODE_TXD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3263 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3264 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3265 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3266 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3267 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3268 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3269 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3270 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
3271 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3272 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3273 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3274 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
3275 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
3276 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
3277 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3278 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3279 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3280 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3281 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3282 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
3283 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
3285 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3286 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3287 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
3288 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
3290 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3291 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3292 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3293 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3294 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3295 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3296 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3297 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
3298 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3300 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3301 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3302 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3303 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3304 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3305 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3306 {TGSI_OPCODE_TXF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3307 {TGSI_OPCODE_TXQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3308 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
3309 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3310 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3311 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
3312 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3313 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
3314 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3316 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3317 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3318 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3319 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3320 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3322 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3323 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3324 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3325 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3326 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3327 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3328 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3329 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3330 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
3331 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
3333 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3334 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3335 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3336 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3337 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3338 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3339 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3340 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3341 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3342 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3343 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3344 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3345 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3346 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3347 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3348 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3349 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3350 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3351 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3352 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3353 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3354 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3355 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3356 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3357 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3358 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3359 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3360 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},