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_formats.h"
32 #include "r600_opcodes.h"
37 static void r600_pipe_shader_vs(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
39 struct r600_pipe_state
*rstate
= &shader
->rstate
;
40 struct r600_shader
*rshader
= &shader
->shader
;
41 unsigned spi_vs_out_id
[10];
44 /* clear previous register */
47 /* so far never got proper semantic id from tgsi */
48 /* FIXME better to move this in config things so they get emited
49 * only one time per cs
51 for (i
= 0; i
< 10; i
++) {
54 for (i
= 0; i
< 32; i
++) {
55 tmp
= i
<< ((i
& 3) * 8);
56 spi_vs_out_id
[i
/ 4] |= tmp
;
58 for (i
= 0; i
< 10; i
++) {
59 r600_pipe_state_add_reg(rstate
,
60 R_028614_SPI_VS_OUT_ID_0
+ i
* 4,
61 spi_vs_out_id
[i
], 0xFFFFFFFF, NULL
);
64 r600_pipe_state_add_reg(rstate
,
65 R_0286C4_SPI_VS_OUT_CONFIG
,
66 S_0286C4_VS_EXPORT_COUNT(rshader
->noutput
- 2),
68 r600_pipe_state_add_reg(rstate
,
69 R_028868_SQ_PGM_RESOURCES_VS
,
70 S_028868_NUM_GPRS(rshader
->bc
.ngpr
) |
71 S_028868_STACK_SIZE(rshader
->bc
.nstack
),
73 r600_pipe_state_add_reg(rstate
,
74 R_0288D0_SQ_PGM_CF_OFFSET_VS
,
75 0x00000000, 0xFFFFFFFF, NULL
);
76 r600_pipe_state_add_reg(rstate
,
77 R_028858_SQ_PGM_START_VS
,
78 r600_bo_offset(shader
->bo
) >> 8, 0xFFFFFFFF, shader
->bo
);
80 r600_pipe_state_add_reg(rstate
,
81 R_03E200_SQ_LOOP_CONST_0
+ (32 * 4), 0x01000FFF,
86 int r600_find_vs_semantic_index(struct r600_shader
*vs
,
87 struct r600_shader
*ps
, int id
)
89 struct r600_shader_io
*input
= &ps
->input
[id
];
91 for (int i
= 0; i
< vs
->noutput
; i
++) {
92 if (input
->name
== vs
->output
[i
].name
&&
93 input
->sid
== vs
->output
[i
].sid
) {
100 static void r600_pipe_shader_ps(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
102 struct r600_pipe_state
*rstate
= &shader
->rstate
;
103 struct r600_shader
*rshader
= &shader
->shader
;
104 unsigned i
, exports_ps
, num_cout
, spi_ps_in_control_0
, spi_input_z
, spi_ps_in_control_1
;
105 int pos_index
= -1, face_index
= -1;
109 for (i
= 0; i
< rshader
->ninput
; i
++) {
110 if (rshader
->input
[i
].name
== TGSI_SEMANTIC_POSITION
)
112 if (rshader
->input
[i
].name
== TGSI_SEMANTIC_FACE
)
116 for (i
= 0; i
< rshader
->noutput
; i
++) {
117 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
)
118 r600_pipe_state_add_reg(rstate
,
119 R_02880C_DB_SHADER_CONTROL
,
120 S_02880C_Z_EXPORT_ENABLE(1),
121 S_02880C_Z_EXPORT_ENABLE(1), NULL
);
122 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
)
123 r600_pipe_state_add_reg(rstate
,
124 R_02880C_DB_SHADER_CONTROL
,
125 S_02880C_STENCIL_REF_EXPORT_ENABLE(1),
126 S_02880C_STENCIL_REF_EXPORT_ENABLE(1), NULL
);
131 for (i
= 0; i
< rshader
->noutput
; i
++) {
132 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
|| rshader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
)
134 else if (rshader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
138 exports_ps
|= S_028854_EXPORT_COLORS(num_cout
);
140 /* always at least export 1 component per pixel */
144 spi_ps_in_control_0
= S_0286CC_NUM_INTERP(rshader
->ninput
) |
145 S_0286CC_PERSP_GRADIENT_ENA(1);
147 if (pos_index
!= -1) {
148 spi_ps_in_control_0
|= (S_0286CC_POSITION_ENA(1) |
149 S_0286CC_POSITION_CENTROID(rshader
->input
[pos_index
].centroid
) |
150 S_0286CC_POSITION_ADDR(rshader
->input
[pos_index
].gpr
) |
151 S_0286CC_BARYC_SAMPLE_CNTL(1));
155 spi_ps_in_control_1
= 0;
156 if (face_index
!= -1) {
157 spi_ps_in_control_1
|= S_0286D0_FRONT_FACE_ENA(1) |
158 S_0286D0_FRONT_FACE_ADDR(rshader
->input
[face_index
].gpr
);
161 r600_pipe_state_add_reg(rstate
, R_0286CC_SPI_PS_IN_CONTROL_0
, spi_ps_in_control_0
, 0xFFFFFFFF, NULL
);
162 r600_pipe_state_add_reg(rstate
, R_0286D0_SPI_PS_IN_CONTROL_1
, spi_ps_in_control_1
, 0xFFFFFFFF, NULL
);
163 r600_pipe_state_add_reg(rstate
, R_0286D8_SPI_INPUT_Z
, spi_input_z
, 0xFFFFFFFF, NULL
);
164 r600_pipe_state_add_reg(rstate
,
165 R_028840_SQ_PGM_START_PS
,
166 r600_bo_offset(shader
->bo
) >> 8, 0xFFFFFFFF, shader
->bo
);
167 r600_pipe_state_add_reg(rstate
,
168 R_028850_SQ_PGM_RESOURCES_PS
,
169 S_028868_NUM_GPRS(rshader
->bc
.ngpr
) |
170 S_028868_STACK_SIZE(rshader
->bc
.nstack
),
172 r600_pipe_state_add_reg(rstate
,
173 R_028854_SQ_PGM_EXPORTS_PS
,
174 exports_ps
, 0xFFFFFFFF, NULL
);
175 r600_pipe_state_add_reg(rstate
,
176 R_0288CC_SQ_PGM_CF_OFFSET_PS
,
177 0x00000000, 0xFFFFFFFF, NULL
);
179 if (rshader
->fs_write_all
) {
180 r600_pipe_state_add_reg(rstate
, R_028808_CB_COLOR_CONTROL
,
181 S_028808_MULTIWRITE_ENABLE(1),
182 S_028808_MULTIWRITE_ENABLE(1),
186 if (rshader
->uses_kill
) {
187 /* only set some bits here, the other bits are set in the dsa state */
188 r600_pipe_state_add_reg(rstate
,
189 R_02880C_DB_SHADER_CONTROL
,
190 S_02880C_KILL_ENABLE(1),
191 S_02880C_KILL_ENABLE(1), NULL
);
193 r600_pipe_state_add_reg(rstate
,
194 R_03E200_SQ_LOOP_CONST_0
, 0x01000FFF,
198 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
200 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
201 struct r600_shader
*rshader
= &shader
->shader
;
204 /* copy new shader */
205 if (shader
->bo
== NULL
) {
206 shader
->bo
= r600_bo(rctx
->radeon
, rshader
->bc
.ndw
* 4, 4096, 0, 0);
207 if (shader
->bo
== NULL
) {
210 ptr
= r600_bo_map(rctx
->radeon
, shader
->bo
, 0, NULL
);
211 memcpy(ptr
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* 4);
212 r600_bo_unmap(rctx
->radeon
, shader
->bo
);
215 switch (rshader
->processor_type
) {
216 case TGSI_PROCESSOR_VERTEX
:
217 if (rshader
->family
>= CHIP_CEDAR
) {
218 evergreen_pipe_shader_vs(ctx
, shader
);
220 r600_pipe_shader_vs(ctx
, shader
);
223 case TGSI_PROCESSOR_FRAGMENT
:
224 if (rshader
->family
>= CHIP_CEDAR
) {
225 evergreen_pipe_shader_ps(ctx
, shader
);
227 r600_pipe_shader_ps(ctx
, shader
);
236 static int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
);
238 int r600_pipe_shader_create(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
, const struct tgsi_token
*tokens
)
240 static int dump_shaders
= -1;
241 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
244 /* Would like some magic "get_bool_option_once" routine.
246 if (dump_shaders
== -1)
247 dump_shaders
= debug_get_bool_option("R600_DUMP_SHADERS", FALSE
);
250 fprintf(stderr
, "--------------------------------------------------------------\n");
251 tgsi_dump(tokens
, 0);
253 shader
->shader
.family
= r600_get_family(rctx
->radeon
);
254 r
= r600_shader_from_tgsi(tokens
, &shader
->shader
);
256 R600_ERR("translation from TGSI failed !\n");
259 r
= r600_bc_build(&shader
->shader
.bc
);
261 R600_ERR("building bytecode failed !\n");
265 r600_bc_dump(&shader
->shader
.bc
);
266 fprintf(stderr
, "______________________________________________________________\n");
268 return r600_pipe_shader(ctx
, shader
);
271 void r600_pipe_shader_destroy(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
273 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
275 r600_bo_reference(rctx
->radeon
, &shader
->bo
, NULL
);
276 r600_bc_clear(&shader
->shader
.bc
);
280 * tgsi -> r600 shader
282 struct r600_shader_tgsi_instruction
;
284 struct r600_shader_src
{
293 struct r600_shader_ctx
{
294 struct tgsi_shader_info info
;
295 struct tgsi_parse_context parse
;
296 const struct tgsi_token
*tokens
;
298 unsigned file_offset
[TGSI_FILE_COUNT
];
301 struct r600_shader_tgsi_instruction
*inst_info
;
303 struct r600_shader
*shader
;
304 struct r600_shader_src src
[3];
307 u32 max_driver_temp_used
;
308 /* needed for evergreen interpolation */
309 boolean input_centroid
;
310 boolean input_linear
;
311 boolean input_perspective
;
315 struct r600_shader_tgsi_instruction
{
316 unsigned tgsi_opcode
;
318 unsigned r600_opcode
;
319 int (*process
)(struct r600_shader_ctx
*ctx
);
322 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[], eg_shader_tgsi_instruction
[];
323 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
325 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
327 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
330 if (i
->Instruction
.NumDstRegs
> 1) {
331 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
334 if (i
->Instruction
.Predicate
) {
335 R600_ERR("predicate unsupported\n");
339 if (i
->Instruction
.Label
) {
340 R600_ERR("label unsupported\n");
344 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
345 if (i
->Src
[j
].Register
.Dimension
) {
346 R600_ERR("unsupported src %d (dimension %d)\n", j
,
347 i
->Src
[j
].Register
.Dimension
);
351 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
352 if (i
->Dst
[j
].Register
.Dimension
) {
353 R600_ERR("unsupported dst (dimension)\n");
360 static int evergreen_interp_alu(struct r600_shader_ctx
*ctx
, int input
)
363 struct r600_bc_alu alu
;
364 int gpr
= 0, base_chan
= 0;
367 if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_PERSPECTIVE
) {
369 if (ctx
->shader
->input
[input
].centroid
)
371 } else if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_LINEAR
) {
373 /* if we have perspective add one */
374 if (ctx
->input_perspective
) {
376 /* if we have perspective centroid */
377 if (ctx
->input_centroid
)
380 if (ctx
->shader
->input
[input
].centroid
)
384 /* work out gpr and base_chan from index */
386 base_chan
= (2 * (ij_index
% 2)) + 1;
388 for (i
= 0; i
< 8; i
++) {
389 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
392 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW
;
394 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_XY
;
396 if ((i
> 1) && (i
< 6)) {
397 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
401 alu
.dst
.chan
= i
% 4;
403 alu
.src
[0].sel
= gpr
;
404 alu
.src
[0].chan
= (base_chan
- (i
% 2));
406 alu
.src
[1].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
408 alu
.bank_swizzle_force
= SQ_ALU_VEC_210
;
411 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
419 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
421 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
425 switch (d
->Declaration
.File
) {
426 case TGSI_FILE_INPUT
:
427 i
= ctx
->shader
->ninput
++;
428 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
429 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
430 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
431 ctx
->shader
->input
[i
].centroid
= d
->Declaration
.Centroid
;
432 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + i
;
433 if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
->bc
->chiprev
== CHIPREV_EVERGREEN
) {
434 /* turn input into interpolate on EG */
435 if (ctx
->shader
->input
[i
].name
!= TGSI_SEMANTIC_POSITION
) {
436 if (ctx
->shader
->input
[i
].interpolate
> 0) {
437 ctx
->shader
->input
[i
].lds_pos
= ctx
->shader
->nlds
++;
438 evergreen_interp_alu(ctx
, i
);
443 case TGSI_FILE_OUTPUT
:
444 i
= ctx
->shader
->noutput
++;
445 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
446 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
447 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + i
;
448 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
450 case TGSI_FILE_CONSTANT
:
451 case TGSI_FILE_TEMPORARY
:
452 case TGSI_FILE_SAMPLER
:
453 case TGSI_FILE_ADDRESS
:
456 case TGSI_FILE_SYSTEM_VALUE
:
457 if (d
->Semantic
.Name
== TGSI_SEMANTIC_INSTANCEID
) {
458 struct r600_bc_alu alu
;
459 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
461 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
);
470 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
476 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
482 static int r600_get_temp(struct r600_shader_ctx
*ctx
)
484 return ctx
->temp_reg
+ ctx
->max_driver_temp_used
++;
488 * for evergreen we need to scan the shader to find the number of GPRs we need to
489 * reserve for interpolation.
491 * we need to know if we are going to emit
492 * any centroid inputs
493 * if perspective and linear are required
495 static int evergreen_gpr_count(struct r600_shader_ctx
*ctx
)
500 ctx
->input_linear
= FALSE
;
501 ctx
->input_perspective
= FALSE
;
502 ctx
->input_centroid
= FALSE
;
503 ctx
->num_interp_gpr
= 1;
505 /* any centroid inputs */
506 for (i
= 0; i
< ctx
->info
.num_inputs
; i
++) {
507 /* skip position/face */
508 if (ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_POSITION
||
509 ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_FACE
)
511 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_LINEAR
)
512 ctx
->input_linear
= TRUE
;
513 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_PERSPECTIVE
)
514 ctx
->input_perspective
= TRUE
;
515 if (ctx
->info
.input_centroid
[i
])
516 ctx
->input_centroid
= TRUE
;
520 /* ignoring sample for now */
521 if (ctx
->input_perspective
)
523 if (ctx
->input_linear
)
525 if (ctx
->input_centroid
)
528 ctx
->num_interp_gpr
+= (num_baryc
+ 1) >> 1;
530 /* TODO PULL MODEL and LINE STIPPLE, FIXED PT POS */
531 return ctx
->num_interp_gpr
;
534 static void tgsi_src(struct r600_shader_ctx
*ctx
,
535 const struct tgsi_full_src_register
*tgsi_src
,
536 struct r600_shader_src
*r600_src
)
538 memset(r600_src
, 0, sizeof(*r600_src
));
539 r600_src
->swizzle
[0] = tgsi_src
->Register
.SwizzleX
;
540 r600_src
->swizzle
[1] = tgsi_src
->Register
.SwizzleY
;
541 r600_src
->swizzle
[2] = tgsi_src
->Register
.SwizzleZ
;
542 r600_src
->swizzle
[3] = tgsi_src
->Register
.SwizzleW
;
543 r600_src
->neg
= tgsi_src
->Register
.Negate
;
544 r600_src
->abs
= tgsi_src
->Register
.Absolute
;
546 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
548 if ((tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleY
) &&
549 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleZ
) &&
550 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleW
)) {
552 index
= tgsi_src
->Register
.Index
* 4 + tgsi_src
->Register
.SwizzleX
;
553 r600_bc_special_constants(ctx
->literals
[index
], &r600_src
->sel
, &r600_src
->neg
);
554 if (r600_src
->sel
!= V_SQ_ALU_SRC_LITERAL
)
557 index
= tgsi_src
->Register
.Index
;
558 r600_src
->sel
= V_SQ_ALU_SRC_LITERAL
;
559 memcpy(r600_src
->value
, ctx
->literals
+ index
* 4, sizeof(r600_src
->value
));
560 } else if (tgsi_src
->Register
.File
== TGSI_FILE_SYSTEM_VALUE
) {
561 /* assume we wan't TGSI_SEMANTIC_INSTANCEID here */
562 r600_src
->swizzle
[0] = 3;
563 r600_src
->swizzle
[1] = 3;
564 r600_src
->swizzle
[2] = 3;
565 r600_src
->swizzle
[3] = 3;
568 if (tgsi_src
->Register
.Indirect
)
569 r600_src
->rel
= V_SQ_REL_RELATIVE
;
570 r600_src
->sel
= tgsi_src
->Register
.Index
;
571 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
575 static int tgsi_fetch_rel_const(struct r600_shader_ctx
*ctx
, unsigned int offset
, unsigned int dst_reg
)
577 struct r600_bc_vtx vtx
;
582 struct r600_bc_alu alu
;
584 memset(&alu
, 0, sizeof(alu
));
586 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
587 alu
.src
[0].sel
= ctx
->ar_reg
;
589 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
590 alu
.src
[1].value
= offset
;
592 alu
.dst
.sel
= dst_reg
;
596 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
601 ar_reg
= ctx
->ar_reg
;
604 memset(&vtx
, 0, sizeof(vtx
));
605 vtx
.fetch_type
= 2; /* VTX_FETCH_NO_INDEX_OFFSET */
606 vtx
.src_gpr
= ar_reg
;
607 vtx
.mega_fetch_count
= 16;
608 vtx
.dst_gpr
= dst_reg
;
609 vtx
.dst_sel_x
= 0; /* SEL_X */
610 vtx
.dst_sel_y
= 1; /* SEL_Y */
611 vtx
.dst_sel_z
= 2; /* SEL_Z */
612 vtx
.dst_sel_w
= 3; /* SEL_W */
613 vtx
.data_format
= FMT_32_32_32_32_FLOAT
;
614 vtx
.num_format_all
= 2; /* NUM_FORMAT_SCALED */
615 vtx
.format_comp_all
= 1; /* FORMAT_COMP_SIGNED */
616 vtx
.srf_mode_all
= 1; /* SRF_MODE_NO_ZERO */
618 if ((r
= r600_bc_add_vtx(ctx
->bc
, &vtx
)))
624 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
)
626 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
627 struct r600_bc_alu alu
;
628 int i
, j
, k
, nconst
, r
;
630 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
631 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
634 tgsi_src(ctx
, &inst
->Src
[i
], &ctx
->src
[i
]);
636 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
637 if (inst
->Src
[i
].Register
.File
!= TGSI_FILE_CONSTANT
) {
641 if (ctx
->src
[i
].rel
) {
642 int treg
= r600_get_temp(ctx
);
643 if ((r
= tgsi_fetch_rel_const(ctx
, ctx
->src
[i
].sel
- 512, treg
)))
646 ctx
->src
[i
].sel
= treg
;
650 int treg
= r600_get_temp(ctx
);
651 for (k
= 0; k
< 4; k
++) {
652 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
653 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
654 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
656 alu
.src
[0].rel
= ctx
->src
[i
].rel
;
662 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
666 ctx
->src
[i
].sel
= treg
;
674 /* need to move any immediate into a temp - for trig functions which use literal for PI stuff */
675 static int tgsi_split_literal_constant(struct r600_shader_ctx
*ctx
)
677 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
678 struct r600_bc_alu alu
;
679 int i
, j
, k
, nliteral
, r
;
681 for (i
= 0, nliteral
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
682 if (ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
686 for (i
= 0, j
= nliteral
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
687 if (j
> 0 && ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
688 int treg
= r600_get_temp(ctx
);
689 for (k
= 0; k
< 4; k
++) {
690 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
691 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
692 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
694 alu
.src
[0].value
= ctx
->src
[i
].value
[k
];
700 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
704 ctx
->src
[i
].sel
= treg
;
711 static int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
)
713 struct tgsi_full_immediate
*immediate
;
714 struct tgsi_full_property
*property
;
715 struct r600_shader_ctx ctx
;
716 struct r600_bc_output output
[32];
721 ctx
.bc
= &shader
->bc
;
723 r
= r600_bc_init(ctx
.bc
, shader
->family
);
727 tgsi_scan_shader(tokens
, &ctx
.info
);
728 tgsi_parse_init(&ctx
.parse
, tokens
);
729 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
730 shader
->processor_type
= ctx
.type
;
731 ctx
.bc
->type
= shader
->processor_type
;
733 /* register allocations */
734 /* Values [0,127] correspond to GPR[0..127].
735 * Values [128,159] correspond to constant buffer bank 0
736 * Values [160,191] correspond to constant buffer bank 1
737 * Values [256,511] correspond to cfile constants c[0..255]. (Gone on EG)
738 * Values [256,287] correspond to constant buffer bank 2 (EG)
739 * Values [288,319] correspond to constant buffer bank 3 (EG)
740 * Other special values are shown in the list below.
741 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
742 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
743 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
744 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
745 * 248 SQ_ALU_SRC_0: special constant 0.0.
746 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
747 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
748 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
749 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
750 * 253 SQ_ALU_SRC_LITERAL: literal constant.
751 * 254 SQ_ALU_SRC_PV: previous vector result.
752 * 255 SQ_ALU_SRC_PS: previous scalar result.
754 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
755 ctx
.file_offset
[i
] = 0;
757 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
758 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
759 if (ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
) {
760 r600_bc_add_cfinst(ctx
.bc
, EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
762 r600_bc_add_cfinst(ctx
.bc
, V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
765 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
) {
766 ctx
.file_offset
[TGSI_FILE_INPUT
] = evergreen_gpr_count(&ctx
);
768 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
769 ctx
.info
.file_count
[TGSI_FILE_INPUT
];
770 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
771 ctx
.info
.file_count
[TGSI_FILE_OUTPUT
];
773 /* Outside the GPR range. This will be translated to one of the
774 * kcache banks later. */
775 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 512;
777 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = V_SQ_ALU_SRC_LITERAL
;
778 ctx
.ar_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
779 ctx
.info
.file_count
[TGSI_FILE_TEMPORARY
];
780 ctx
.temp_reg
= ctx
.ar_reg
+ 1;
784 shader
->fs_write_all
= FALSE
;
785 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
786 tgsi_parse_token(&ctx
.parse
);
787 switch (ctx
.parse
.FullToken
.Token
.Type
) {
788 case TGSI_TOKEN_TYPE_IMMEDIATE
:
789 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
790 ctx
.literals
= realloc(ctx
.literals
, (ctx
.nliterals
+ 1) * 16);
791 if(ctx
.literals
== NULL
) {
795 ctx
.literals
[ctx
.nliterals
* 4 + 0] = immediate
->u
[0].Uint
;
796 ctx
.literals
[ctx
.nliterals
* 4 + 1] = immediate
->u
[1].Uint
;
797 ctx
.literals
[ctx
.nliterals
* 4 + 2] = immediate
->u
[2].Uint
;
798 ctx
.literals
[ctx
.nliterals
* 4 + 3] = immediate
->u
[3].Uint
;
801 case TGSI_TOKEN_TYPE_DECLARATION
:
802 r
= tgsi_declaration(&ctx
);
806 case TGSI_TOKEN_TYPE_INSTRUCTION
:
807 r
= tgsi_is_supported(&ctx
);
810 ctx
.max_driver_temp_used
= 0;
811 /* reserve first tmp for everyone */
814 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
815 if ((r
= tgsi_split_constant(&ctx
)))
817 if ((r
= tgsi_split_literal_constant(&ctx
)))
819 if (ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
)
820 ctx
.inst_info
= &eg_shader_tgsi_instruction
[opcode
];
822 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
823 r
= ctx
.inst_info
->process(&ctx
);
827 case TGSI_TOKEN_TYPE_PROPERTY
:
828 property
= &ctx
.parse
.FullToken
.FullProperty
;
829 if (property
->Property
.PropertyName
== TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS
) {
830 if (property
->u
[0].Data
== 1)
831 shader
->fs_write_all
= TRUE
;
835 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
841 noutput
= shader
->noutput
;
842 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
843 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
844 output
[i
].gpr
= shader
->output
[i
].gpr
;
845 output
[i
].elem_size
= 3;
846 output
[i
].swizzle_x
= 0;
847 output
[i
].swizzle_y
= 1;
848 output
[i
].swizzle_z
= 2;
849 output
[i
].swizzle_w
= 3;
850 output
[i
].burst_count
= 1;
851 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
852 output
[i
].array_base
= i
- pos0
;
854 case TGSI_PROCESSOR_VERTEX
:
855 if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
856 output
[i
].array_base
= 60;
857 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
858 /* position doesn't count in array_base */
861 if (shader
->output
[i
].name
== TGSI_SEMANTIC_PSIZE
) {
862 output
[i
].array_base
= 61;
863 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
864 /* position doesn't count in array_base */
868 case TGSI_PROCESSOR_FRAGMENT
:
869 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
870 output
[i
].array_base
= shader
->output
[i
].sid
;
871 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
872 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
873 output
[i
].array_base
= 61;
874 output
[i
].swizzle_x
= 2;
875 output
[i
].swizzle_y
= 7;
876 output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
877 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
878 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
) {
879 output
[i
].array_base
= 61;
880 output
[i
].swizzle_x
= 7;
881 output
[i
].swizzle_y
= 1;
882 output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
883 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
885 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
891 R600_ERR("unsupported processor type %d\n", ctx
.type
);
896 /* add fake param output for vertex shader if no param is exported */
897 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
898 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
899 if (output
[i
].type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
) {
905 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
907 output
[i
].elem_size
= 3;
908 output
[i
].swizzle_x
= 0;
909 output
[i
].swizzle_y
= 1;
910 output
[i
].swizzle_z
= 2;
911 output
[i
].swizzle_w
= 3;
912 output
[i
].burst_count
= 1;
913 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
914 output
[i
].array_base
= 0;
918 /* add fake pixel export */
919 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& !noutput
) {
920 memset(&output
[0], 0, sizeof(struct r600_bc_output
));
922 output
[0].elem_size
= 3;
923 output
[0].swizzle_x
= 7;
924 output
[0].swizzle_y
= 7;
925 output
[0].swizzle_z
= 7;
926 output
[0].swizzle_w
= 7;
927 output
[0].burst_count
= 1;
928 output
[0].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
929 output
[0].array_base
= 0;
932 /* add output to bytecode */
933 for (i
= 0; i
< noutput
; i
++) {
934 r
= r600_bc_add_output(ctx
.bc
, &output
[i
]);
939 tgsi_parse_free(&ctx
.parse
);
943 tgsi_parse_free(&ctx
.parse
);
947 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
949 R600_ERR("%d tgsi opcode unsupported\n", ctx
->inst_info
->tgsi_opcode
);
953 static int tgsi_end(struct r600_shader_ctx
*ctx
)
958 static void r600_bc_src(struct r600_bc_alu_src
*bc_src
,
959 const struct r600_shader_src
*shader_src
,
962 bc_src
->sel
= shader_src
->sel
;
963 bc_src
->chan
= shader_src
->swizzle
[chan
];
964 bc_src
->neg
= shader_src
->neg
;
965 bc_src
->abs
= shader_src
->abs
;
966 bc_src
->rel
= shader_src
->rel
;
967 bc_src
->value
= shader_src
->value
[bc_src
->chan
];
970 static void tgsi_dst(struct r600_shader_ctx
*ctx
,
971 const struct tgsi_full_dst_register
*tgsi_dst
,
973 struct r600_bc_alu_dst
*r600_dst
)
975 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
977 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
978 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
979 r600_dst
->chan
= swizzle
;
981 if (tgsi_dst
->Register
.Indirect
)
982 r600_dst
->rel
= V_SQ_REL_RELATIVE
;
983 if (inst
->Instruction
.Saturate
) {
988 static int tgsi_last_instruction(unsigned writemask
)
992 for (i
= 0; i
< 4; i
++) {
993 if (writemask
& (1 << i
)) {
1000 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
)
1002 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1003 struct r600_bc_alu alu
;
1005 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1007 for (i
= 0; i
< lasti
+ 1; i
++) {
1008 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1011 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1012 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1014 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1016 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1017 r600_bc_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
1020 r600_bc_src(&alu
.src
[0], &ctx
->src
[1], i
);
1021 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
1023 /* handle some special cases */
1024 switch (ctx
->inst_info
->tgsi_opcode
) {
1025 case TGSI_OPCODE_SUB
:
1028 case TGSI_OPCODE_ABS
:
1037 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1044 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
1046 return tgsi_op2_s(ctx
, 0);
1049 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
1051 return tgsi_op2_s(ctx
, 1);
1055 * r600 - trunc to -PI..PI range
1056 * r700 - normalize by dividing by 2PI
1059 static int tgsi_setup_trig(struct r600_shader_ctx
*ctx
)
1061 static float half_inv_pi
= 1.0 /(3.1415926535 * 2);
1062 static float double_pi
= 3.1415926535 * 2;
1063 static float neg_pi
= -3.1415926535;
1066 struct r600_bc_alu alu
;
1068 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1069 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1073 alu
.dst
.sel
= ctx
->temp_reg
;
1076 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1078 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1079 alu
.src
[1].chan
= 0;
1080 alu
.src
[1].value
= *(uint32_t *)&half_inv_pi
;
1081 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
1082 alu
.src
[2].chan
= 0;
1084 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1088 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1089 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
1092 alu
.dst
.sel
= ctx
->temp_reg
;
1095 alu
.src
[0].sel
= ctx
->temp_reg
;
1096 alu
.src
[0].chan
= 0;
1098 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1102 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1103 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1107 alu
.dst
.sel
= ctx
->temp_reg
;
1110 alu
.src
[0].sel
= ctx
->temp_reg
;
1111 alu
.src
[0].chan
= 0;
1113 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1114 alu
.src
[1].chan
= 0;
1115 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1116 alu
.src
[2].chan
= 0;
1118 if (ctx
->bc
->chiprev
== CHIPREV_R600
) {
1119 alu
.src
[1].value
= *(uint32_t *)&double_pi
;
1120 alu
.src
[2].value
= *(uint32_t *)&neg_pi
;
1122 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1123 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
1128 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1134 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
1136 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1137 struct r600_bc_alu alu
;
1139 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1141 r
= tgsi_setup_trig(ctx
);
1145 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1146 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1148 alu
.dst
.sel
= ctx
->temp_reg
;
1151 alu
.src
[0].sel
= ctx
->temp_reg
;
1152 alu
.src
[0].chan
= 0;
1154 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1158 /* replicate result */
1159 for (i
= 0; i
< lasti
+ 1; i
++) {
1160 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1163 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1164 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1166 alu
.src
[0].sel
= ctx
->temp_reg
;
1167 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1170 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1177 static int tgsi_scs(struct r600_shader_ctx
*ctx
)
1179 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1180 struct r600_bc_alu alu
;
1183 /* We'll only need the trig stuff if we are going to write to the
1184 * X or Y components of the destination vector.
1186 if (likely(inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_XY
)) {
1187 r
= tgsi_setup_trig(ctx
);
1193 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_X
) {
1194 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1195 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
1196 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1198 alu
.src
[0].sel
= ctx
->temp_reg
;
1199 alu
.src
[0].chan
= 0;
1201 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1207 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Y
) {
1208 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1209 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
1210 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1212 alu
.src
[0].sel
= ctx
->temp_reg
;
1213 alu
.src
[0].chan
= 0;
1215 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1221 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Z
) {
1222 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1224 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1226 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1228 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1229 alu
.src
[0].chan
= 0;
1233 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1239 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
1240 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1242 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1244 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1246 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1247 alu
.src
[0].chan
= 0;
1251 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1259 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
1261 struct r600_bc_alu alu
;
1264 for (i
= 0; i
< 4; i
++) {
1265 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1266 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1270 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1272 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
1273 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1276 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
1281 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1286 /* kill must be last in ALU */
1287 ctx
->bc
->force_add_cf
= 1;
1288 ctx
->shader
->uses_kill
= TRUE
;
1292 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
1294 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1295 struct r600_bc_alu alu
;
1299 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1300 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1301 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
1302 alu
.src
[0].chan
= 0;
1303 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1304 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
1305 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1309 /* dst.y = max(src.x, 0.0) */
1310 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1311 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1312 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1313 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1314 alu
.src
[1].chan
= 0;
1315 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1316 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
1317 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1322 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1323 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1324 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1325 alu
.src
[0].chan
= 0;
1326 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1327 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
1329 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1333 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
1338 /* dst.z = log(src.y) */
1339 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1340 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1341 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 1);
1342 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1344 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1348 chan
= alu
.dst
.chan
;
1351 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
1352 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1353 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
1354 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 3);
1355 alu
.src
[1].sel
= sel
;
1356 alu
.src
[1].chan
= chan
;
1358 r600_bc_src(&alu
.src
[2], &ctx
->src
[0], 0);
1359 alu
.dst
.sel
= ctx
->temp_reg
;
1364 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1368 /* dst.z = exp(tmp.x) */
1369 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1370 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1371 alu
.src
[0].sel
= ctx
->temp_reg
;
1372 alu
.src
[0].chan
= 0;
1373 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1375 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1382 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
1384 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1385 struct r600_bc_alu alu
;
1388 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1391 * For state trackers other than OpenGL, we'll want to use
1392 * _RECIPSQRT_IEEE instead.
1394 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
1396 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1397 r600_bc_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
1400 alu
.dst
.sel
= ctx
->temp_reg
;
1403 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1406 /* replicate result */
1407 return tgsi_helper_tempx_replicate(ctx
);
1410 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1412 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1413 struct r600_bc_alu alu
;
1416 for (i
= 0; i
< 4; i
++) {
1417 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1418 alu
.src
[0].sel
= ctx
->temp_reg
;
1419 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1421 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1422 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1425 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1432 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1434 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1435 struct r600_bc_alu alu
;
1438 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1439 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1440 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1441 r600_bc_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
1443 alu
.dst
.sel
= ctx
->temp_reg
;
1446 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1449 /* replicate result */
1450 return tgsi_helper_tempx_replicate(ctx
);
1453 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1455 struct r600_bc_alu alu
;
1459 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1460 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1461 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1462 alu
.dst
.sel
= ctx
->temp_reg
;
1465 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1469 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1470 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1471 r600_bc_src(&alu
.src
[0], &ctx
->src
[1], 0);
1472 alu
.src
[1].sel
= ctx
->temp_reg
;
1473 alu
.dst
.sel
= ctx
->temp_reg
;
1476 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1479 /* POW(a,b) = EXP2(b * LOG2(a))*/
1480 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1481 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1482 alu
.src
[0].sel
= ctx
->temp_reg
;
1483 alu
.dst
.sel
= ctx
->temp_reg
;
1486 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1489 return tgsi_helper_tempx_replicate(ctx
);
1492 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1494 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1495 struct r600_bc_alu alu
;
1498 /* tmp = (src > 0 ? 1 : src) */
1499 for (i
= 0; i
< 4; i
++) {
1500 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1501 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1504 alu
.dst
.sel
= ctx
->temp_reg
;
1507 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
1508 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1509 r600_bc_src(&alu
.src
[2], &ctx
->src
[0], i
);
1513 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1518 /* dst = (-tmp > 0 ? -1 : tmp) */
1519 for (i
= 0; i
< 4; i
++) {
1520 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1521 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1523 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1525 alu
.src
[0].sel
= ctx
->temp_reg
;
1526 alu
.src
[0].chan
= i
;
1529 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1532 alu
.src
[2].sel
= ctx
->temp_reg
;
1533 alu
.src
[2].chan
= i
;
1537 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1544 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1546 struct r600_bc_alu alu
;
1549 for (i
= 0; i
< 4; i
++) {
1550 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1551 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1552 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
1555 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1556 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1557 alu
.src
[0].sel
= ctx
->temp_reg
;
1558 alu
.src
[0].chan
= i
;
1563 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1570 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1572 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1573 struct r600_bc_alu alu
;
1575 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1577 for (i
= 0; i
< lasti
+ 1; i
++) {
1578 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1581 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1582 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1583 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1584 r600_bc_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
1587 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1594 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1601 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1603 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1604 struct r600_bc_alu alu
;
1607 for (i
= 0; i
< 4; i
++) {
1608 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1609 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1610 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1611 r600_bc_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
1614 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1616 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1617 /* handle some special cases */
1618 switch (ctx
->inst_info
->tgsi_opcode
) {
1619 case TGSI_OPCODE_DP2
:
1621 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1622 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1625 case TGSI_OPCODE_DP3
:
1627 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1628 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1631 case TGSI_OPCODE_DPH
:
1633 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1634 alu
.src
[0].chan
= 0;
1644 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1651 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1653 static float one_point_five
= 1.5f
;
1654 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1655 struct r600_bc_tex tex
;
1656 struct r600_bc_alu alu
;
1660 boolean src_not_temp
=
1661 inst
->Src
[0].Register
.File
!= TGSI_FILE_TEMPORARY
&&
1662 inst
->Src
[0].Register
.File
!= TGSI_FILE_INPUT
;
1664 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
1666 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1667 /* Add perspective divide */
1668 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1669 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1670 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 3);
1672 alu
.dst
.sel
= ctx
->temp_reg
;
1676 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1680 for (i
= 0; i
< 3; i
++) {
1681 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1682 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1683 alu
.src
[0].sel
= ctx
->temp_reg
;
1684 alu
.src
[0].chan
= 3;
1685 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
1686 alu
.dst
.sel
= ctx
->temp_reg
;
1689 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1693 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1694 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1695 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1696 alu
.src
[0].chan
= 0;
1697 alu
.dst
.sel
= ctx
->temp_reg
;
1701 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1704 src_not_temp
= FALSE
;
1705 src_gpr
= ctx
->temp_reg
;
1708 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1709 int src_chan
, src2_chan
;
1711 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
1712 for (i
= 0; i
< 4; i
++) {
1713 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1714 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
1738 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], src_chan
);
1739 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], src2_chan
);
1740 alu
.dst
.sel
= ctx
->temp_reg
;
1745 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1750 /* tmp1.z = RCP_e(|tmp1.z|) */
1751 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1752 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1753 alu
.src
[0].sel
= ctx
->temp_reg
;
1754 alu
.src
[0].chan
= 2;
1756 alu
.dst
.sel
= ctx
->temp_reg
;
1760 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1764 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
1765 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
1766 * muladd has no writemask, have to use another temp
1768 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1769 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1772 alu
.src
[0].sel
= ctx
->temp_reg
;
1773 alu
.src
[0].chan
= 0;
1774 alu
.src
[1].sel
= ctx
->temp_reg
;
1775 alu
.src
[1].chan
= 2;
1777 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1778 alu
.src
[2].chan
= 0;
1779 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
1781 alu
.dst
.sel
= ctx
->temp_reg
;
1785 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1789 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1790 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1793 alu
.src
[0].sel
= ctx
->temp_reg
;
1794 alu
.src
[0].chan
= 1;
1795 alu
.src
[1].sel
= ctx
->temp_reg
;
1796 alu
.src
[1].chan
= 2;
1798 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1799 alu
.src
[2].chan
= 0;
1800 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
1802 alu
.dst
.sel
= ctx
->temp_reg
;
1807 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1811 src_not_temp
= FALSE
;
1812 src_gpr
= ctx
->temp_reg
;
1816 for (i
= 0; i
< 4; i
++) {
1817 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1818 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1819 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
1820 alu
.dst
.sel
= ctx
->temp_reg
;
1825 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1829 src_gpr
= ctx
->temp_reg
;
1832 opcode
= ctx
->inst_info
->r600_opcode
;
1833 if (opcode
== SQ_TEX_INST_SAMPLE
&&
1834 (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
))
1835 opcode
= SQ_TEX_INST_SAMPLE_C
;
1837 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
1839 tex
.sampler_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
1840 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
1841 tex
.src_gpr
= src_gpr
;
1842 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
1843 tex
.dst_sel_x
= (inst
->Dst
[0].Register
.WriteMask
& 1) ? 0 : 7;
1844 tex
.dst_sel_y
= (inst
->Dst
[0].Register
.WriteMask
& 2) ? 1 : 7;
1845 tex
.dst_sel_z
= (inst
->Dst
[0].Register
.WriteMask
& 4) ? 2 : 7;
1846 tex
.dst_sel_w
= (inst
->Dst
[0].Register
.WriteMask
& 8) ? 3 : 7;
1852 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1859 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
1860 tex
.coord_type_x
= 1;
1861 tex
.coord_type_y
= 1;
1862 tex
.coord_type_z
= 1;
1863 tex
.coord_type_w
= 1;
1866 if (inst
->Texture
.Texture
== TGSI_TEXTURE_1D_ARRAY
) {
1867 tex
.coord_type_z
= 0;
1869 } else if (inst
->Texture
.Texture
== TGSI_TEXTURE_2D_ARRAY
)
1870 tex
.coord_type_z
= 0;
1872 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
)
1875 r
= r600_bc_add_tex(ctx
->bc
, &tex
);
1879 /* add shadow ambient support - gallium doesn't do it yet */
1883 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
1885 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1886 struct r600_bc_alu alu
;
1887 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1891 /* optimize if it's just an equal balance */
1892 if (ctx
->src
[0].sel
== V_SQ_ALU_SRC_0_5
) {
1893 for (i
= 0; i
< lasti
+ 1; i
++) {
1894 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1897 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1898 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
1899 r600_bc_src(&alu
.src
[0], &ctx
->src
[1], i
);
1900 r600_bc_src(&alu
.src
[1], &ctx
->src
[2], i
);
1902 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1907 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1915 for (i
= 0; i
< lasti
+ 1; i
++) {
1916 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1919 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1920 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
1921 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1922 alu
.src
[0].chan
= 0;
1923 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
1925 alu
.dst
.sel
= ctx
->temp_reg
;
1931 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1936 /* (1 - src0) * src2 */
1937 for (i
= 0; i
< lasti
+ 1; i
++) {
1938 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1941 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1942 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1943 alu
.src
[0].sel
= ctx
->temp_reg
;
1944 alu
.src
[0].chan
= i
;
1945 r600_bc_src(&alu
.src
[1], &ctx
->src
[2], i
);
1946 alu
.dst
.sel
= ctx
->temp_reg
;
1952 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1957 /* src0 * src1 + (1 - src0) * src2 */
1958 for (i
= 0; i
< lasti
+ 1; i
++) {
1959 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1962 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1963 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1965 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
1966 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], i
);
1967 alu
.src
[2].sel
= ctx
->temp_reg
;
1968 alu
.src
[2].chan
= i
;
1970 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1975 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1982 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
1984 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1985 struct r600_bc_alu alu
;
1987 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1989 for (i
= 0; i
< lasti
+ 1; i
++) {
1990 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1993 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1994 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
1995 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
1996 r600_bc_src(&alu
.src
[1], &ctx
->src
[2], i
);
1997 r600_bc_src(&alu
.src
[2], &ctx
->src
[1], i
);
1998 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2004 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2011 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
2013 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2014 struct r600_bc_alu alu
;
2015 uint32_t use_temp
= 0;
2018 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
2021 for (i
= 0; i
< 4; i
++) {
2022 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2023 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2027 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 2);
2030 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2033 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 1);
2036 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2037 alu
.src
[0].chan
= i
;
2042 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], 1);
2045 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], 2);
2048 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], 0);
2051 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2052 alu
.src
[1].chan
= i
;
2055 alu
.dst
.sel
= ctx
->temp_reg
;
2061 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2066 for (i
= 0; i
< 4; i
++) {
2067 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2068 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2072 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 1);
2075 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 2);
2078 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2081 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2082 alu
.src
[0].chan
= i
;
2087 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], 2);
2090 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], 0);
2093 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], 1);
2096 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2097 alu
.src
[1].chan
= i
;
2100 alu
.src
[2].sel
= ctx
->temp_reg
;
2102 alu
.src
[2].chan
= i
;
2105 alu
.dst
.sel
= ctx
->temp_reg
;
2107 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2113 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2118 return tgsi_helper_copy(ctx
, inst
);
2122 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
2124 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2125 struct r600_bc_alu alu
;
2128 /* result.x = 2^floor(src); */
2129 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2130 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2132 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2133 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2135 alu
.dst
.sel
= ctx
->temp_reg
;
2139 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2143 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2144 alu
.src
[0].sel
= ctx
->temp_reg
;
2145 alu
.src
[0].chan
= 0;
2147 alu
.dst
.sel
= ctx
->temp_reg
;
2151 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2156 /* result.y = tmp - floor(tmp); */
2157 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2158 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2160 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
2161 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2163 alu
.dst
.sel
= ctx
->temp_reg
;
2164 // r = tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
2172 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2177 /* result.z = RoughApprox2ToX(tmp);*/
2178 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
2179 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2180 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2181 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2183 alu
.dst
.sel
= ctx
->temp_reg
;
2189 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2194 /* result.w = 1.0;*/
2195 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
2196 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2198 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2199 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2200 alu
.src
[0].chan
= 0;
2202 alu
.dst
.sel
= ctx
->temp_reg
;
2206 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2210 return tgsi_helper_copy(ctx
, inst
);
2213 static int tgsi_log(struct r600_shader_ctx
*ctx
)
2215 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2216 struct r600_bc_alu alu
;
2219 /* result.x = floor(log2(src)); */
2220 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2221 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2223 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2224 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2226 alu
.dst
.sel
= ctx
->temp_reg
;
2230 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2234 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2235 alu
.src
[0].sel
= ctx
->temp_reg
;
2236 alu
.src
[0].chan
= 0;
2238 alu
.dst
.sel
= ctx
->temp_reg
;
2243 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2248 /* result.y = src.x / (2 ^ floor(log2(src.x))); */
2249 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2250 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2252 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2253 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2255 alu
.dst
.sel
= ctx
->temp_reg
;
2260 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2264 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2266 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2267 alu
.src
[0].sel
= ctx
->temp_reg
;
2268 alu
.src
[0].chan
= 1;
2270 alu
.dst
.sel
= ctx
->temp_reg
;
2275 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2279 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2281 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2282 alu
.src
[0].sel
= ctx
->temp_reg
;
2283 alu
.src
[0].chan
= 1;
2285 alu
.dst
.sel
= ctx
->temp_reg
;
2290 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2294 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2296 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2297 alu
.src
[0].sel
= ctx
->temp_reg
;
2298 alu
.src
[0].chan
= 1;
2300 alu
.dst
.sel
= ctx
->temp_reg
;
2305 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2309 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2311 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2313 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2315 alu
.src
[1].sel
= ctx
->temp_reg
;
2316 alu
.src
[1].chan
= 1;
2318 alu
.dst
.sel
= ctx
->temp_reg
;
2323 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2328 /* result.z = log2(src);*/
2329 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
2330 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2332 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2333 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2335 alu
.dst
.sel
= ctx
->temp_reg
;
2340 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2345 /* result.w = 1.0; */
2346 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
2347 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2349 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2350 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2351 alu
.src
[0].chan
= 0;
2353 alu
.dst
.sel
= ctx
->temp_reg
;
2358 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2363 return tgsi_helper_copy(ctx
, inst
);
2366 static int tgsi_eg_arl(struct r600_shader_ctx
*ctx
)
2368 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2369 struct r600_bc_alu alu
;
2372 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2374 switch (inst
->Instruction
.Opcode
) {
2375 case TGSI_OPCODE_ARL
:
2376 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR
;
2378 case TGSI_OPCODE_ARR
:
2379 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
2386 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2388 alu
.dst
.sel
= ctx
->ar_reg
;
2390 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2394 /* TODO: Note that the MOVA can be avoided if we never use AR for
2395 * indexing non-CB registers in the current ALU clause. Similarly, we
2396 * need to load AR from ar_reg again if we started a new clause
2397 * between ARL and AR usage. The easy way to do that is to remove
2398 * the MOVA here, and load it for the first AR access after ar_reg
2399 * has been modified in each clause. */
2400 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2401 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
;
2402 alu
.src
[0].sel
= ctx
->ar_reg
;
2403 alu
.src
[0].chan
= 0;
2405 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2410 static int tgsi_r600_arl(struct r600_shader_ctx
*ctx
)
2412 /* TODO from r600c, ar values don't persist between clauses */
2413 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2414 struct r600_bc_alu alu
;
2417 switch (inst
->Instruction
.Opcode
) {
2418 case TGSI_OPCODE_ARL
:
2419 memset(&alu
, 0, sizeof(alu
));
2420 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
;
2421 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2422 alu
.dst
.sel
= ctx
->ar_reg
;
2426 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
2429 memset(&alu
, 0, sizeof(alu
));
2430 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
2431 alu
.src
[0].sel
= ctx
->ar_reg
;
2432 alu
.dst
.sel
= ctx
->ar_reg
;
2436 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
2439 case TGSI_OPCODE_ARR
:
2440 memset(&alu
, 0, sizeof(alu
));
2441 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
2442 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2443 alu
.dst
.sel
= ctx
->ar_reg
;
2447 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
2455 memset(&alu
, 0, sizeof(alu
));
2456 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
;
2457 alu
.src
[0].sel
= ctx
->ar_reg
;
2460 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2463 ctx
->bc
->cf_last
->r6xx_uses_waterfall
= 1;
2467 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
2469 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2470 struct r600_bc_alu alu
;
2473 for (i
= 0; i
< 4; i
++) {
2474 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2476 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2477 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2479 if (i
== 0 || i
== 3) {
2480 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2482 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
2485 if (i
== 0 || i
== 2) {
2486 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2488 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], i
);
2492 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2499 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
2501 struct r600_bc_alu alu
;
2504 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2508 alu
.dst
.sel
= ctx
->temp_reg
;
2512 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2513 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2514 alu
.src
[1].chan
= 0;
2518 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
2524 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
2527 if (ctx
->bc
->cf_last
) {
2528 if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
) << 3)
2530 else if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
) << 3)
2535 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
) << 3;
2536 ctx
->bc
->force_add_cf
= 1;
2537 } else if (alu_pop
== 2) {
2538 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
) << 3;
2539 ctx
->bc
->force_add_cf
= 1;
2541 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
2542 ctx
->bc
->cf_last
->pop_count
= pops
;
2543 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2548 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
2552 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2556 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
2559 /* TOODO : for 16 vp asic should -= 2; */
2560 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2565 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
2567 if (check_max_only
) {
2580 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
2581 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2582 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2583 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
2589 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2593 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
2596 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2600 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
2601 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2602 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2603 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
2607 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
2609 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
2611 sp
->mid
= (struct r600_bc_cf
**)realloc((void *)sp
->mid
,
2612 sizeof(struct r600_bc_cf
*) * (sp
->num_mid
+ 1));
2613 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
2617 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
2620 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
2621 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
2624 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
2626 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
2638 static int emit_return(struct r600_shader_ctx
*ctx
)
2640 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
2644 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
2647 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_JUMP
);
2648 ctx
->bc
->cf_last
->pop_count
= pops
;
2649 /* TODO work out offset */
2653 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
2658 static void emit_testflag(struct r600_shader_ctx
*ctx
)
2663 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
2666 emit_jump_to_offset(ctx
, 1, 4);
2667 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
2668 pops(ctx
, ifidx
+ 1);
2672 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
2676 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2677 ctx
->bc
->cf_last
->pop_count
= 1;
2679 fc_set_mid(ctx
, fc_sp
);
2685 static int tgsi_if(struct r600_shader_ctx
*ctx
)
2687 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
2689 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
2691 fc_pushlevel(ctx
, FC_IF
);
2693 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
2697 static int tgsi_else(struct r600_shader_ctx
*ctx
)
2699 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
2700 ctx
->bc
->cf_last
->pop_count
= 1;
2702 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
2703 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
2707 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
2710 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
2711 R600_ERR("if/endif unbalanced in shader\n");
2715 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
2716 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2717 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
2719 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2723 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
2727 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
2729 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
2731 fc_pushlevel(ctx
, FC_LOOP
);
2733 /* check stack depth */
2734 callstack_check_depth(ctx
, FC_LOOP
, 0);
2738 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
2742 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
2744 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
2745 R600_ERR("loop/endloop in shader code are not paired.\n");
2749 /* fixup loop pointers - from r600isa
2750 LOOP END points to CF after LOOP START,
2751 LOOP START point to CF after LOOP END
2752 BRK/CONT point to LOOP END CF
2754 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
2756 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2758 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
2759 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
2761 /* TODO add LOOPRET support */
2763 callstack_decrease_current(ctx
, FC_LOOP
);
2767 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
2771 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
2773 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
2778 R600_ERR("Break not inside loop/endloop pair\n");
2782 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2783 ctx
->bc
->cf_last
->pop_count
= 1;
2785 fc_set_mid(ctx
, fscp
);
2788 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
2792 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
2793 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
2794 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2795 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2798 * For state trackers other than OpenGL, we'll want to use
2799 * _RECIP_IEEE instead.
2801 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
2803 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
2804 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2805 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
2806 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2807 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2808 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2809 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2810 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2811 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2812 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2813 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2814 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2815 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2816 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2817 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2818 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2820 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2821 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2823 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2824 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2825 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2826 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2827 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2828 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2829 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2830 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2831 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2832 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2834 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2835 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2836 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2837 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2838 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2839 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2840 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2841 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
2842 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2843 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2844 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2845 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2846 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2847 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
2848 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2849 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
2850 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
2851 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
2852 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
2853 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2854 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2855 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2856 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
2857 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2858 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2859 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2860 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2861 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2862 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2863 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
2864 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2865 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2866 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2867 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
2868 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
2869 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
2870 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2871 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2872 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2873 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2874 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
2875 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
2876 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
2878 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2879 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2880 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
2881 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
2883 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2884 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2885 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2886 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2887 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2888 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2889 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2890 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
2891 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2893 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2894 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2895 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2896 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2897 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2898 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2899 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2900 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2901 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
2902 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2903 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2904 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
2905 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2906 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
2907 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2909 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2910 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2911 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2912 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2913 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2915 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2916 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2917 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2918 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2919 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2920 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2921 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2922 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2923 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
2924 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
2926 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2927 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2928 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2929 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2930 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2931 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2932 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2933 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2934 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2935 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2936 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2937 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2938 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2939 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2940 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2941 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2942 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2943 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2944 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2945 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2946 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2947 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2948 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2949 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2950 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2951 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2952 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2953 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2956 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
2957 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
2958 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2959 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2960 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
2961 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
2962 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
2963 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2964 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
2965 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2966 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2967 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2968 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
2969 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
2970 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
2971 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
2972 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
2973 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
2974 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
2975 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
2976 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2978 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2979 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2981 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2982 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2983 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
2984 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2985 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
2986 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2987 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
2988 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
2989 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
2990 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
2992 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2993 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2994 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
2995 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
2996 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
2997 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
2998 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
2999 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
3000 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3001 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3002 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3003 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3004 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3005 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
3006 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3007 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
3008 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
3009 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
3010 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
3011 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3012 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3013 {TGSI_OPCODE_TXD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3014 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3015 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3016 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3017 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3018 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3019 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3020 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3021 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
3022 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3023 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3024 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3025 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
3026 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
3027 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
3028 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3029 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3030 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3031 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3032 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3033 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
3034 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
3036 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3037 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3038 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
3039 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
3041 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3042 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3043 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3044 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3045 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3046 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3047 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3048 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
3049 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3051 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3052 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3053 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3054 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3055 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3056 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3057 {TGSI_OPCODE_TXF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3058 {TGSI_OPCODE_TXQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3059 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
3060 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3061 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3062 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
3063 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3064 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
3065 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3067 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3068 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3069 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3070 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3071 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3073 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3074 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3075 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3076 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3077 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3078 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3079 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3080 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3081 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
3082 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
3084 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3085 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3086 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3087 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3088 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3089 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3090 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3091 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3092 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3093 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3094 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3095 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3096 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3097 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3098 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3099 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3100 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3101 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3102 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3103 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3104 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3105 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3106 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3107 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3108 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3109 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3110 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3111 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},