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 for (i
= 0; i
< 10; i
++) {
50 for (i
= 0; i
< 32; i
++) {
51 tmp
= i
<< ((i
& 3) * 8);
52 spi_vs_out_id
[i
/ 4] |= tmp
;
54 for (i
= 0; i
< 10; i
++) {
55 r600_pipe_state_add_reg(rstate
,
56 R_028614_SPI_VS_OUT_ID_0
+ i
* 4,
57 spi_vs_out_id
[i
], 0xFFFFFFFF, NULL
);
60 r600_pipe_state_add_reg(rstate
,
61 R_0286C4_SPI_VS_OUT_CONFIG
,
62 S_0286C4_VS_EXPORT_COUNT(rshader
->noutput
- 2),
64 r600_pipe_state_add_reg(rstate
,
65 R_028868_SQ_PGM_RESOURCES_VS
,
66 S_028868_NUM_GPRS(rshader
->bc
.ngpr
) |
67 S_028868_STACK_SIZE(rshader
->bc
.nstack
),
69 r600_pipe_state_add_reg(rstate
,
70 R_0288A4_SQ_PGM_RESOURCES_FS
,
71 0x00000000, 0xFFFFFFFF, NULL
);
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_0288DC_SQ_PGM_CF_OFFSET_FS
,
77 0x00000000, 0xFFFFFFFF, NULL
);
78 r600_pipe_state_add_reg(rstate
,
79 R_028858_SQ_PGM_START_VS
,
80 r600_bo_offset(shader
->bo
) >> 8, 0xFFFFFFFF, shader
->bo
);
81 r600_pipe_state_add_reg(rstate
,
82 R_028894_SQ_PGM_START_FS
,
83 r600_bo_offset(shader
->bo
) >> 8, 0xFFFFFFFF, shader
->bo
);
85 r600_pipe_state_add_reg(rstate
,
86 R_03E200_SQ_LOOP_CONST_0
+ (32 * 4), 0x01000FFF,
91 int r600_find_vs_semantic_index(struct r600_shader
*vs
,
92 struct r600_shader
*ps
, int id
)
94 struct r600_shader_io
*input
= &ps
->input
[id
];
96 for (int i
= 0; i
< vs
->noutput
; i
++) {
97 if (input
->name
== vs
->output
[i
].name
&&
98 input
->sid
== vs
->output
[i
].sid
) {
105 static void r600_pipe_shader_ps(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
107 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
108 struct r600_pipe_state
*rstate
= &shader
->rstate
;
109 struct r600_shader
*rshader
= &shader
->shader
;
110 unsigned i
, tmp
, exports_ps
, num_cout
, spi_ps_in_control_0
, spi_input_z
, spi_ps_in_control_1
;
111 int pos_index
= -1, face_index
= -1;
113 /* clear previous register */
116 for (i
= 0; i
< rshader
->ninput
; i
++) {
117 tmp
= S_028644_SEMANTIC(r600_find_vs_semantic_index(&rctx
->vs_shader
->shader
, rshader
, i
));
118 if (rshader
->input
[i
].centroid
)
119 tmp
|= S_028644_SEL_CENTROID(1);
120 if (rshader
->input
[i
].interpolate
== TGSI_INTERPOLATE_LINEAR
)
121 tmp
|= S_028644_SEL_LINEAR(1);
123 if (rshader
->input
[i
].name
== TGSI_SEMANTIC_POSITION
)
125 if (rshader
->input
[i
].name
== TGSI_SEMANTIC_COLOR
||
126 rshader
->input
[i
].name
== TGSI_SEMANTIC_BCOLOR
||
127 rshader
->input
[i
].name
== TGSI_SEMANTIC_POSITION
) {
128 tmp
|= S_028644_FLAT_SHADE(rshader
->flat_shade
);
130 if (rshader
->input
[i
].name
== TGSI_SEMANTIC_FACE
)
132 if (rshader
->input
[i
].name
== TGSI_SEMANTIC_GENERIC
&&
133 rctx
->sprite_coord_enable
& (1 << rshader
->input
[i
].sid
)) {
134 tmp
|= S_028644_PT_SPRITE_TEX(1);
136 r600_pipe_state_add_reg(rstate
, R_028644_SPI_PS_INPUT_CNTL_0
+ i
* 4, tmp
, 0xFFFFFFFF, NULL
);
138 for (i
= 0; i
< rshader
->noutput
; i
++) {
139 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
)
140 r600_pipe_state_add_reg(rstate
,
141 R_02880C_DB_SHADER_CONTROL
,
142 S_02880C_Z_EXPORT_ENABLE(1),
143 S_02880C_Z_EXPORT_ENABLE(1), NULL
);
144 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
)
145 r600_pipe_state_add_reg(rstate
,
146 R_02880C_DB_SHADER_CONTROL
,
147 S_02880C_STENCIL_REF_EXPORT_ENABLE(1),
148 S_02880C_STENCIL_REF_EXPORT_ENABLE(1), NULL
);
153 for (i
= 0; i
< rshader
->noutput
; i
++) {
154 if (rshader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
|| rshader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
)
156 else if (rshader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
160 exports_ps
|= S_028854_EXPORT_COLORS(num_cout
);
162 /* always at least export 1 component per pixel */
166 spi_ps_in_control_0
= S_0286CC_NUM_INTERP(rshader
->ninput
) |
167 S_0286CC_PERSP_GRADIENT_ENA(1);
169 if (pos_index
!= -1) {
170 spi_ps_in_control_0
|= (S_0286CC_POSITION_ENA(1) |
171 S_0286CC_POSITION_CENTROID(rshader
->input
[pos_index
].centroid
) |
172 S_0286CC_POSITION_ADDR(rshader
->input
[pos_index
].gpr
) |
173 S_0286CC_BARYC_SAMPLE_CNTL(1));
177 spi_ps_in_control_1
= 0;
178 if (face_index
!= -1) {
179 spi_ps_in_control_1
|= S_0286D0_FRONT_FACE_ENA(1) |
180 S_0286D0_FRONT_FACE_ADDR(rshader
->input
[face_index
].gpr
);
183 r600_pipe_state_add_reg(rstate
, R_0286CC_SPI_PS_IN_CONTROL_0
, spi_ps_in_control_0
, 0xFFFFFFFF, NULL
);
184 r600_pipe_state_add_reg(rstate
, R_0286D0_SPI_PS_IN_CONTROL_1
, spi_ps_in_control_1
, 0xFFFFFFFF, NULL
);
185 r600_pipe_state_add_reg(rstate
, R_0286D8_SPI_INPUT_Z
, spi_input_z
, 0xFFFFFFFF, NULL
);
186 r600_pipe_state_add_reg(rstate
,
187 R_028840_SQ_PGM_START_PS
,
188 r600_bo_offset(shader
->bo
) >> 8, 0xFFFFFFFF, shader
->bo
);
189 r600_pipe_state_add_reg(rstate
,
190 R_028850_SQ_PGM_RESOURCES_PS
,
191 S_028868_NUM_GPRS(rshader
->bc
.ngpr
) |
192 S_028868_STACK_SIZE(rshader
->bc
.nstack
),
194 r600_pipe_state_add_reg(rstate
,
195 R_028854_SQ_PGM_EXPORTS_PS
,
196 exports_ps
, 0xFFFFFFFF, NULL
);
197 r600_pipe_state_add_reg(rstate
,
198 R_0288CC_SQ_PGM_CF_OFFSET_PS
,
199 0x00000000, 0xFFFFFFFF, NULL
);
201 if (rshader
->uses_kill
) {
202 /* only set some bits here, the other bits are set in the dsa state */
203 r600_pipe_state_add_reg(rstate
,
204 R_02880C_DB_SHADER_CONTROL
,
205 S_02880C_KILL_ENABLE(1),
206 S_02880C_KILL_ENABLE(1), NULL
);
208 r600_pipe_state_add_reg(rstate
,
209 R_03E200_SQ_LOOP_CONST_0
, 0x01000FFF,
213 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
215 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
216 struct r600_shader
*rshader
= &shader
->shader
;
219 /* copy new shader */
220 if (shader
->bo
== NULL
) {
221 shader
->bo
= r600_bo(rctx
->radeon
, rshader
->bc
.ndw
* 4, 4096, 0);
222 if (shader
->bo
== NULL
) {
225 ptr
= r600_bo_map(rctx
->radeon
, shader
->bo
, 0, NULL
);
226 memcpy(ptr
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* 4);
227 r600_bo_unmap(rctx
->radeon
, shader
->bo
);
230 rshader
->flat_shade
= rctx
->flatshade
;
231 switch (rshader
->processor_type
) {
232 case TGSI_PROCESSOR_VERTEX
:
233 if (rshader
->family
>= CHIP_CEDAR
) {
234 evergreen_pipe_shader_vs(ctx
, shader
);
236 r600_pipe_shader_vs(ctx
, shader
);
239 case TGSI_PROCESSOR_FRAGMENT
:
240 if (rshader
->family
>= CHIP_CEDAR
) {
241 evergreen_pipe_shader_ps(ctx
, shader
);
243 r600_pipe_shader_ps(ctx
, shader
);
249 r600_context_pipe_state_set(&rctx
->ctx
, &shader
->rstate
);
253 static int r600_shader_update(struct pipe_context
*ctx
, struct r600_pipe_shader
*rshader
)
255 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
256 struct r600_shader
*shader
= &rshader
->shader
;
257 const struct util_format_description
*desc
;
258 enum pipe_format resource_format
[160];
259 unsigned i
, nresources
= 0;
260 struct r600_bc
*bc
= &shader
->bc
;
261 struct r600_bc_cf
*cf
;
262 struct r600_bc_vtx
*vtx
;
264 if (shader
->processor_type
!= TGSI_PROCESSOR_VERTEX
)
266 /* doing a full memcmp fell over the refcount */
267 if ((rshader
->vertex_elements
.count
== rctx
->vertex_elements
->count
) &&
268 (!memcmp(&rshader
->vertex_elements
.elements
, &rctx
->vertex_elements
->elements
, 32 * sizeof(struct pipe_vertex_element
)))) {
271 rshader
->vertex_elements
= *rctx
->vertex_elements
;
272 for (i
= 0; i
< rctx
->vertex_elements
->count
; i
++) {
273 resource_format
[nresources
++] = rctx
->vertex_elements
->elements
[i
].src_format
;
275 r600_bo_reference(rctx
->radeon
, &rshader
->bo
, NULL
);
276 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
278 case V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
279 case V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC
:
280 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
281 desc
= util_format_description(resource_format
[vtx
->buffer_id
]);
283 R600_ERR("unknown format %d\n", resource_format
[vtx
->buffer_id
]);
286 vtx
->dst_sel_x
= desc
->swizzle
[0];
287 vtx
->dst_sel_y
= desc
->swizzle
[1];
288 vtx
->dst_sel_z
= desc
->swizzle
[2];
289 vtx
->dst_sel_w
= desc
->swizzle
[3];
296 return r600_bc_build(&shader
->bc
);
299 int r600_pipe_shader_update(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
301 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
306 /* there should be enough input */
307 if (rctx
->vertex_elements
->count
< shader
->shader
.bc
.nresource
) {
308 R600_ERR("%d resources provided, expecting %d\n",
309 rctx
->vertex_elements
->count
, shader
->shader
.bc
.nresource
);
312 r
= r600_shader_update(ctx
, shader
);
315 return r600_pipe_shader(ctx
, shader
);
318 int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
);
319 int r600_pipe_shader_create(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
, const struct tgsi_token
*tokens
)
321 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
324 //fprintf(stderr, "--------------------------------------------------------------\n");
325 //tgsi_dump(tokens, 0);
326 shader
->shader
.family
= r600_get_family(rctx
->radeon
);
327 r
= r600_shader_from_tgsi(tokens
, &shader
->shader
);
329 R600_ERR("translation from TGSI failed !\n");
332 r
= r600_bc_build(&shader
->shader
.bc
);
334 R600_ERR("building bytecode failed !\n");
337 //fprintf(stderr, "______________________________________________________________\n");
342 * tgsi -> r600 shader
344 struct r600_shader_tgsi_instruction
;
346 struct r600_shader_ctx
{
347 struct tgsi_shader_info info
;
348 struct tgsi_parse_context parse
;
349 const struct tgsi_token
*tokens
;
351 unsigned file_offset
[TGSI_FILE_COUNT
];
353 struct r600_shader_tgsi_instruction
*inst_info
;
355 struct r600_shader
*shader
;
359 u32 max_driver_temp_used
;
360 /* needed for evergreen interpolation */
361 boolean input_centroid
;
362 boolean input_linear
;
363 boolean input_perspective
;
367 struct r600_shader_tgsi_instruction
{
368 unsigned tgsi_opcode
;
370 unsigned r600_opcode
;
371 int (*process
)(struct r600_shader_ctx
*ctx
);
374 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[], eg_shader_tgsi_instruction
[];
375 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
377 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
379 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
382 if (i
->Instruction
.NumDstRegs
> 1) {
383 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
386 if (i
->Instruction
.Predicate
) {
387 R600_ERR("predicate unsupported\n");
391 if (i
->Instruction
.Label
) {
392 R600_ERR("label unsupported\n");
396 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
397 if (i
->Src
[j
].Register
.Dimension
) {
398 R600_ERR("unsupported src %d (dimension %d)\n", j
,
399 i
->Src
[j
].Register
.Dimension
);
403 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
404 if (i
->Dst
[j
].Register
.Dimension
) {
405 R600_ERR("unsupported dst (dimension)\n");
412 static int evergreen_interp_alu(struct r600_shader_ctx
*ctx
, int input
)
415 struct r600_bc_alu alu
;
416 int gpr
= 0, base_chan
= 0;
419 if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_PERSPECTIVE
) {
421 if (ctx
->shader
->input
[input
].centroid
)
423 } else if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_LINEAR
) {
425 /* if we have perspective add one */
426 if (ctx
->input_perspective
) {
428 /* if we have perspective centroid */
429 if (ctx
->input_centroid
)
432 if (ctx
->shader
->input
[input
].centroid
)
436 /* work out gpr and base_chan from index */
438 base_chan
= (2 * (ij_index
% 2)) + 1;
440 for (i
= 0; i
< 8; i
++) {
441 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
444 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW
;
446 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_XY
;
448 if ((i
> 1) && (i
< 6)) {
449 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
453 alu
.dst
.chan
= i
% 4;
455 alu
.src
[0].sel
= gpr
;
456 alu
.src
[0].chan
= (base_chan
- (i
% 2));
458 alu
.src
[1].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
460 alu
.bank_swizzle_force
= SQ_ALU_VEC_210
;
463 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
471 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
473 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
474 struct r600_bc_vtx vtx
;
478 switch (d
->Declaration
.File
) {
479 case TGSI_FILE_INPUT
:
480 i
= ctx
->shader
->ninput
++;
481 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
482 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
483 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
484 ctx
->shader
->input
[i
].centroid
= d
->Declaration
.Centroid
;
485 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + i
;
486 if (ctx
->type
== TGSI_PROCESSOR_VERTEX
) {
487 /* turn input into fetch */
488 memset(&vtx
, 0, sizeof(struct r600_bc_vtx
));
492 /* register containing the index into the buffer */
495 vtx
.mega_fetch_count
= 0x1F;
496 vtx
.dst_gpr
= ctx
->shader
->input
[i
].gpr
;
501 vtx
.use_const_fields
= 1;
502 r
= r600_bc_add_vtx(ctx
->bc
, &vtx
);
506 if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
->bc
->chiprev
== 2) {
507 /* turn input into interpolate on EG */
508 if (ctx
->shader
->input
[i
].name
!= TGSI_SEMANTIC_POSITION
) {
509 if (ctx
->shader
->input
[i
].interpolate
> 0) {
510 ctx
->shader
->input
[i
].lds_pos
= ctx
->shader
->nlds
++;
511 evergreen_interp_alu(ctx
, i
);
516 case TGSI_FILE_OUTPUT
:
517 i
= ctx
->shader
->noutput
++;
518 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
519 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
520 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + i
;
521 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
523 case TGSI_FILE_CONSTANT
:
524 case TGSI_FILE_TEMPORARY
:
525 case TGSI_FILE_SAMPLER
:
526 case TGSI_FILE_ADDRESS
:
529 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
535 static int r600_get_temp(struct r600_shader_ctx
*ctx
)
537 return ctx
->temp_reg
+ ctx
->max_driver_temp_used
++;
541 * for evergreen we need to scan the shader to find the number of GPRs we need to
542 * reserve for interpolation.
544 * we need to know if we are going to emit
545 * any centroid inputs
546 * if perspective and linear are required
548 static int evergreen_gpr_count(struct r600_shader_ctx
*ctx
)
553 ctx
->input_linear
= FALSE
;
554 ctx
->input_perspective
= FALSE
;
555 ctx
->input_centroid
= FALSE
;
556 ctx
->num_interp_gpr
= 1;
558 /* any centroid inputs */
559 for (i
= 0; i
< ctx
->info
.num_inputs
; i
++) {
560 /* skip position/face */
561 if (ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_POSITION
||
562 ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_FACE
)
564 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_LINEAR
)
565 ctx
->input_linear
= TRUE
;
566 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_PERSPECTIVE
)
567 ctx
->input_perspective
= TRUE
;
568 if (ctx
->info
.input_centroid
[i
])
569 ctx
->input_centroid
= TRUE
;
573 /* ignoring sample for now */
574 if (ctx
->input_perspective
)
576 if (ctx
->input_linear
)
578 if (ctx
->input_centroid
)
581 ctx
->num_interp_gpr
+= (num_baryc
+ 1) >> 1;
583 /* TODO PULL MODEL and LINE STIPPLE, FIXED PT POS */
584 return ctx
->num_interp_gpr
;
587 int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
)
589 struct tgsi_full_immediate
*immediate
;
590 struct r600_shader_ctx ctx
;
591 struct r600_bc_output output
[32];
592 unsigned output_done
, noutput
;
596 ctx
.bc
= &shader
->bc
;
598 r
= r600_bc_init(ctx
.bc
, shader
->family
);
602 tgsi_scan_shader(tokens
, &ctx
.info
);
603 tgsi_parse_init(&ctx
.parse
, tokens
);
604 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
605 shader
->processor_type
= ctx
.type
;
607 /* register allocations */
608 /* Values [0,127] correspond to GPR[0..127].
609 * Values [128,159] correspond to constant buffer bank 0
610 * Values [160,191] correspond to constant buffer bank 1
611 * Values [256,511] correspond to cfile constants c[0..255].
612 * Other special values are shown in the list below.
613 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
614 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
615 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
616 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
617 * 248 SQ_ALU_SRC_0: special constant 0.0.
618 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
619 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
620 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
621 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
622 * 253 SQ_ALU_SRC_LITERAL: literal constant.
623 * 254 SQ_ALU_SRC_PV: previous vector result.
624 * 255 SQ_ALU_SRC_PS: previous scalar result.
626 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
627 ctx
.file_offset
[i
] = 0;
629 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
630 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
632 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
.bc
->chiprev
== 2) {
633 ctx
.file_offset
[TGSI_FILE_INPUT
] = evergreen_gpr_count(&ctx
);
635 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
636 ctx
.info
.file_count
[TGSI_FILE_INPUT
];
637 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
638 ctx
.info
.file_count
[TGSI_FILE_OUTPUT
];
640 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 128;
642 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = 253;
643 ctx
.temp_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
644 ctx
.info
.file_count
[TGSI_FILE_TEMPORARY
];
649 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
650 tgsi_parse_token(&ctx
.parse
);
651 switch (ctx
.parse
.FullToken
.Token
.Type
) {
652 case TGSI_TOKEN_TYPE_IMMEDIATE
:
653 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
654 ctx
.literals
= realloc(ctx
.literals
, (ctx
.nliterals
+ 1) * 16);
655 if(ctx
.literals
== NULL
) {
659 ctx
.literals
[ctx
.nliterals
* 4 + 0] = immediate
->u
[0].Uint
;
660 ctx
.literals
[ctx
.nliterals
* 4 + 1] = immediate
->u
[1].Uint
;
661 ctx
.literals
[ctx
.nliterals
* 4 + 2] = immediate
->u
[2].Uint
;
662 ctx
.literals
[ctx
.nliterals
* 4 + 3] = immediate
->u
[3].Uint
;
665 case TGSI_TOKEN_TYPE_DECLARATION
:
666 r
= tgsi_declaration(&ctx
);
670 case TGSI_TOKEN_TYPE_INSTRUCTION
:
671 r
= tgsi_is_supported(&ctx
);
674 ctx
.max_driver_temp_used
= 0;
675 /* reserve first tmp for everyone */
677 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
678 if (ctx
.bc
->chiprev
== 2)
679 ctx
.inst_info
= &eg_shader_tgsi_instruction
[opcode
];
681 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
682 r
= ctx
.inst_info
->process(&ctx
);
685 r
= r600_bc_add_literal(ctx
.bc
, ctx
.value
);
690 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
696 noutput
= shader
->noutput
;
697 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
698 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
699 output
[i
].gpr
= shader
->output
[i
].gpr
;
700 output
[i
].elem_size
= 3;
701 output
[i
].swizzle_x
= 0;
702 output
[i
].swizzle_y
= 1;
703 output
[i
].swizzle_z
= 2;
704 output
[i
].swizzle_w
= 3;
705 output
[i
].barrier
= 1;
706 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
707 output
[i
].array_base
= i
- pos0
;
708 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
710 case TGSI_PROCESSOR_VERTEX
:
711 if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
712 output
[i
].array_base
= 60;
713 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
714 /* position doesn't count in array_base */
717 if (shader
->output
[i
].name
== TGSI_SEMANTIC_PSIZE
) {
718 output
[i
].array_base
= 61;
719 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
720 /* position doesn't count in array_base */
724 case TGSI_PROCESSOR_FRAGMENT
:
725 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
726 output
[i
].array_base
= shader
->output
[i
].sid
;
727 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
728 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
729 output
[i
].array_base
= 61;
730 output
[i
].swizzle_x
= 2;
731 output
[i
].swizzle_y
= 7;
732 output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
733 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
734 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
) {
735 output
[i
].array_base
= 61;
736 output
[i
].swizzle_x
= 7;
737 output
[i
].swizzle_y
= 1;
738 output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
739 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
741 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
747 R600_ERR("unsupported processor type %d\n", ctx
.type
);
752 /* add fake param output for vertex shader if no param is exported */
753 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
754 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
755 if (output
[i
].type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
) {
761 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
763 output
[i
].elem_size
= 3;
764 output
[i
].swizzle_x
= 0;
765 output
[i
].swizzle_y
= 1;
766 output
[i
].swizzle_z
= 2;
767 output
[i
].swizzle_w
= 3;
768 output
[i
].barrier
= 1;
769 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
770 output
[i
].array_base
= 0;
771 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
775 /* add fake pixel export */
776 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& !noutput
) {
777 memset(&output
[0], 0, sizeof(struct r600_bc_output
));
779 output
[0].elem_size
= 3;
780 output
[0].swizzle_x
= 7;
781 output
[0].swizzle_y
= 7;
782 output
[0].swizzle_z
= 7;
783 output
[0].swizzle_w
= 7;
784 output
[0].barrier
= 1;
785 output
[0].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
786 output
[0].array_base
= 0;
787 output
[0].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
790 /* set export done on last export of each type */
791 for (i
= noutput
- 1, output_done
= 0; i
>= 0; i
--) {
792 if (i
== (noutput
- 1)) {
793 output
[i
].end_of_program
= 1;
795 if (!(output_done
& (1 << output
[i
].type
))) {
796 output_done
|= (1 << output
[i
].type
);
797 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
);
800 /* add output to bytecode */
801 for (i
= 0; i
< noutput
; i
++) {
802 r
= r600_bc_add_output(ctx
.bc
, &output
[i
]);
807 tgsi_parse_free(&ctx
.parse
);
811 tgsi_parse_free(&ctx
.parse
);
815 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
817 R600_ERR("%d tgsi opcode unsupported\n", ctx
->inst_info
->tgsi_opcode
);
821 static int tgsi_end(struct r600_shader_ctx
*ctx
)
826 static int tgsi_src(struct r600_shader_ctx
*ctx
,
827 const struct tgsi_full_src_register
*tgsi_src
,
828 struct r600_bc_alu_src
*r600_src
)
831 memset(r600_src
, 0, sizeof(struct r600_bc_alu_src
));
832 r600_src
->sel
= tgsi_src
->Register
.Index
;
833 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
835 index
= tgsi_src
->Register
.Index
;
836 ctx
->value
[0] = ctx
->literals
[index
* 4 + 0];
837 ctx
->value
[1] = ctx
->literals
[index
* 4 + 1];
838 ctx
->value
[2] = ctx
->literals
[index
* 4 + 2];
839 ctx
->value
[3] = ctx
->literals
[index
* 4 + 3];
841 if (tgsi_src
->Register
.Indirect
)
842 r600_src
->rel
= V_SQ_REL_RELATIVE
;
843 r600_src
->neg
= tgsi_src
->Register
.Negate
;
844 r600_src
->abs
= tgsi_src
->Register
.Absolute
;
845 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
849 static int tgsi_dst(struct r600_shader_ctx
*ctx
,
850 const struct tgsi_full_dst_register
*tgsi_dst
,
852 struct r600_bc_alu_dst
*r600_dst
)
854 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
856 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
857 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
858 r600_dst
->chan
= swizzle
;
860 if (tgsi_dst
->Register
.Indirect
)
861 r600_dst
->rel
= V_SQ_REL_RELATIVE
;
862 if (inst
->Instruction
.Saturate
) {
868 static unsigned tgsi_chan(const struct tgsi_full_src_register
*tgsi_src
, unsigned swizzle
)
872 return tgsi_src
->Register
.SwizzleX
;
874 return tgsi_src
->Register
.SwizzleY
;
876 return tgsi_src
->Register
.SwizzleZ
;
878 return tgsi_src
->Register
.SwizzleW
;
884 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
886 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
887 struct r600_bc_alu alu
;
888 int i
, j
, k
, nconst
, r
;
890 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
891 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
894 r
= tgsi_src(ctx
, &inst
->Src
[i
], &r600_src
[i
]);
899 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
900 if (j
> 0 && inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
901 int treg
= r600_get_temp(ctx
);
902 for (k
= 0; k
< 4; k
++) {
903 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
904 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
905 alu
.src
[0].sel
= r600_src
[i
].sel
;
907 alu
.src
[0].rel
= r600_src
[i
].rel
;
913 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
917 r600_src
[i
].sel
= treg
;
925 /* need to move any immediate into a temp - for trig functions which use literal for PI stuff */
926 static int tgsi_split_literal_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
928 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
929 struct r600_bc_alu alu
;
930 int i
, j
, k
, nliteral
, r
;
932 for (i
= 0, nliteral
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
933 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_IMMEDIATE
) {
937 for (i
= 0, j
= nliteral
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
938 if (j
> 0 && inst
->Src
[i
].Register
.File
== TGSI_FILE_IMMEDIATE
) {
939 int treg
= r600_get_temp(ctx
);
940 for (k
= 0; k
< 4; k
++) {
941 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
942 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
943 alu
.src
[0].sel
= r600_src
[i
].sel
;
950 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
954 r
= r600_bc_add_literal(ctx
->bc
, &ctx
->literals
[inst
->Src
[i
].Register
.Index
* 4]);
957 r600_src
[i
].sel
= treg
;
964 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
)
966 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
967 struct r600_bc_alu_src r600_src
[3];
968 struct r600_bc_alu alu
;
972 for (i
= 0; i
< 4; i
++) {
973 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
978 r
= tgsi_split_constant(ctx
, r600_src
);
981 r
= tgsi_split_literal_constant(ctx
, r600_src
);
984 for (i
= 0; i
< lasti
+ 1; i
++) {
985 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
988 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
989 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
993 alu
.inst
= ctx
->inst_info
->r600_opcode
;
995 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
996 alu
.src
[j
] = r600_src
[j
];
997 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1000 alu
.src
[0] = r600_src
[1];
1001 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], i
);
1003 alu
.src
[1] = r600_src
[0];
1004 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1006 /* handle some special cases */
1007 switch (ctx
->inst_info
->tgsi_opcode
) {
1008 case TGSI_OPCODE_SUB
:
1011 case TGSI_OPCODE_ABS
:
1020 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1027 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
1029 return tgsi_op2_s(ctx
, 0);
1032 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
1034 return tgsi_op2_s(ctx
, 1);
1038 * r600 - trunc to -PI..PI range
1039 * r700 - normalize by dividing by 2PI
1042 static int tgsi_setup_trig(struct r600_shader_ctx
*ctx
,
1043 struct r600_bc_alu_src r600_src
[3])
1045 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1047 uint32_t lit_vals
[4];
1048 struct r600_bc_alu alu
;
1050 memset(lit_vals
, 0, 4*4);
1051 r
= tgsi_split_constant(ctx
, r600_src
);
1054 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1058 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1062 lit_vals
[0] = fui(1.0 /(3.1415926535 * 2));
1063 lit_vals
[1] = fui(0.5f
);
1065 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1066 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1070 alu
.dst
.sel
= ctx
->temp_reg
;
1073 alu
.src
[0] = r600_src
[0];
1074 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1076 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1077 alu
.src
[1].chan
= 0;
1078 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1079 alu
.src
[2].chan
= 1;
1081 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1084 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
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 if (ctx
->bc
->chiprev
== 0) {
1103 lit_vals
[0] = fui(3.1415926535897f
* 2.0f
);
1104 lit_vals
[1] = fui(-3.1415926535897f
);
1106 lit_vals
[0] = fui(1.0f
);
1107 lit_vals
[1] = fui(-0.5f
);
1110 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1111 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1115 alu
.dst
.sel
= ctx
->temp_reg
;
1118 alu
.src
[0].sel
= ctx
->temp_reg
;
1119 alu
.src
[0].chan
= 0;
1121 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1122 alu
.src
[1].chan
= 0;
1123 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1124 alu
.src
[2].chan
= 1;
1126 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1129 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
1135 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
1137 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1138 struct r600_bc_alu_src r600_src
[3];
1139 struct r600_bc_alu alu
;
1143 r
= tgsi_setup_trig(ctx
, r600_src
);
1147 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1148 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1150 alu
.dst
.sel
= ctx
->temp_reg
;
1153 alu
.src
[0].sel
= ctx
->temp_reg
;
1154 alu
.src
[0].chan
= 0;
1156 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1160 /* replicate result */
1161 for (i
= 0; i
< 4; i
++) {
1162 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
))
1165 for (i
= 0; i
< lasti
+ 1; i
++) {
1166 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1169 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1170 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1172 alu
.src
[0].sel
= ctx
->temp_reg
;
1173 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1178 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1185 static int tgsi_scs(struct r600_shader_ctx
*ctx
)
1187 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1188 struct r600_bc_alu_src r600_src
[3];
1189 struct r600_bc_alu alu
;
1192 /* We'll only need the trig stuff if we are going to write to the
1193 * X or Y components of the destination vector.
1195 if (likely(inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_XY
)) {
1196 r
= tgsi_setup_trig(ctx
, r600_src
);
1202 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_X
) {
1203 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1204 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
1205 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1209 alu
.src
[0].sel
= ctx
->temp_reg
;
1210 alu
.src
[0].chan
= 0;
1212 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1218 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Y
) {
1219 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1220 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
1221 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1225 alu
.src
[0].sel
= ctx
->temp_reg
;
1226 alu
.src
[0].chan
= 0;
1228 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1234 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Z
) {
1235 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1237 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1239 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1243 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1244 alu
.src
[0].chan
= 0;
1248 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1252 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1258 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
1259 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1261 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1263 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1267 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1268 alu
.src
[0].chan
= 0;
1272 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1276 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1284 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
1286 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1287 struct r600_bc_alu alu
;
1290 for (i
= 0; i
< 4; i
++) {
1291 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1292 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1296 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1298 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
1299 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1302 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1305 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1310 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1314 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1318 /* kill must be last in ALU */
1319 ctx
->bc
->force_add_cf
= 1;
1320 ctx
->shader
->uses_kill
= TRUE
;
1324 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
1326 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1327 struct r600_bc_alu alu
;
1328 struct r600_bc_alu_src r600_src
[3];
1331 r
= tgsi_split_constant(ctx
, r600_src
);
1334 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1339 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1340 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1341 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
1342 alu
.src
[0].chan
= 0;
1343 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1346 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
1347 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1351 /* dst.y = max(src.x, 0.0) */
1352 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1353 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1354 alu
.src
[0] = r600_src
[0];
1355 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1356 alu
.src
[1].chan
= 0;
1357 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1360 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
1361 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1366 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1367 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1368 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1369 alu
.src
[0].chan
= 0;
1370 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1373 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
1375 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1379 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1383 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
1388 /* dst.z = log(src.y) */
1389 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1390 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1391 alu
.src
[0] = r600_src
[0];
1392 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1393 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1397 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1401 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1405 chan
= alu
.dst
.chan
;
1408 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
1409 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1410 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
1411 alu
.src
[0] = r600_src
[0];
1412 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1413 alu
.src
[1].sel
= sel
;
1414 alu
.src
[1].chan
= chan
;
1416 alu
.src
[2] = r600_src
[0];
1417 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], 0);
1418 alu
.dst
.sel
= ctx
->temp_reg
;
1423 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1427 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1430 /* dst.z = exp(tmp.x) */
1431 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1432 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1433 alu
.src
[0].sel
= ctx
->temp_reg
;
1434 alu
.src
[0].chan
= 0;
1435 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1439 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1446 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
1448 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1449 struct r600_bc_alu alu
;
1452 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1455 * For state trackers other than OpenGL, we'll want to use
1456 * _RECIPSQRT_IEEE instead.
1458 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
1460 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1461 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1464 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1467 alu
.dst
.sel
= ctx
->temp_reg
;
1470 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1473 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1476 /* replicate result */
1477 return tgsi_helper_tempx_replicate(ctx
);
1480 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1482 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1483 struct r600_bc_alu alu
;
1486 for (i
= 0; i
< 4; i
++) {
1487 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1488 alu
.src
[0].sel
= ctx
->temp_reg
;
1489 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1491 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1494 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1497 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1504 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1506 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1507 struct r600_bc_alu alu
;
1510 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1511 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1512 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1513 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1516 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1518 alu
.dst
.sel
= ctx
->temp_reg
;
1521 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1524 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1527 /* replicate result */
1528 return tgsi_helper_tempx_replicate(ctx
);
1531 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1533 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1534 struct r600_bc_alu alu
;
1538 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1539 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1540 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1543 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1544 alu
.dst
.sel
= ctx
->temp_reg
;
1547 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1550 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1554 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1555 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL_IEEE
);
1556 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[0]);
1559 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], 0);
1560 alu
.src
[1].sel
= ctx
->temp_reg
;
1561 alu
.dst
.sel
= ctx
->temp_reg
;
1564 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1567 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1570 /* POW(a,b) = EXP2(b * LOG2(a))*/
1571 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1572 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1573 alu
.src
[0].sel
= ctx
->temp_reg
;
1574 alu
.dst
.sel
= ctx
->temp_reg
;
1577 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1580 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1583 return tgsi_helper_tempx_replicate(ctx
);
1586 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1588 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1589 struct r600_bc_alu alu
;
1590 struct r600_bc_alu_src r600_src
[3];
1593 r
= tgsi_split_constant(ctx
, r600_src
);
1596 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1600 /* tmp = (src > 0 ? 1 : src) */
1601 for (i
= 0; i
< 4; i
++) {
1602 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1603 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1606 alu
.dst
.sel
= ctx
->temp_reg
;
1609 alu
.src
[0] = r600_src
[0];
1610 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1612 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1614 alu
.src
[2] = r600_src
[0];
1615 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], i
);
1618 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1622 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1626 /* dst = (-tmp > 0 ? -1 : tmp) */
1627 for (i
= 0; i
< 4; i
++) {
1628 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1629 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1631 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1635 alu
.src
[0].sel
= ctx
->temp_reg
;
1636 alu
.src
[0].chan
= i
;
1639 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1642 alu
.src
[2].sel
= ctx
->temp_reg
;
1643 alu
.src
[2].chan
= i
;
1647 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1654 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1656 struct r600_bc_alu alu
;
1659 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1662 for (i
= 0; i
< 4; i
++) {
1663 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1664 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1665 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
1668 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1669 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1672 alu
.src
[0].sel
= ctx
->temp_reg
;
1673 alu
.src
[0].chan
= i
;
1678 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1685 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1687 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1688 struct r600_bc_alu_src r600_src
[3];
1689 struct r600_bc_alu alu
;
1692 r
= tgsi_split_constant(ctx
, r600_src
);
1695 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1698 /* do it in 2 step as op3 doesn't support writemask */
1699 for (i
= 0; i
< 4; i
++) {
1700 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1701 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1702 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1703 alu
.src
[j
] = r600_src
[j
];
1704 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1706 alu
.dst
.sel
= ctx
->temp_reg
;
1713 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1717 return tgsi_helper_copy(ctx
, inst
);
1720 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1722 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1723 struct r600_bc_alu_src r600_src
[3];
1724 struct r600_bc_alu alu
;
1727 r
= tgsi_split_constant(ctx
, r600_src
);
1730 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1733 for (i
= 0; i
< 4; i
++) {
1734 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1735 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1736 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1737 alu
.src
[j
] = r600_src
[j
];
1738 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1740 alu
.dst
.sel
= ctx
->temp_reg
;
1743 /* handle some special cases */
1744 switch (ctx
->inst_info
->tgsi_opcode
) {
1745 case TGSI_OPCODE_DP2
:
1747 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1748 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1751 case TGSI_OPCODE_DP3
:
1753 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1754 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1757 case TGSI_OPCODE_DPH
:
1759 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1760 alu
.src
[0].chan
= 0;
1770 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1774 return tgsi_helper_copy(ctx
, inst
);
1777 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1779 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1780 struct r600_bc_tex tex
;
1781 struct r600_bc_alu alu
;
1785 boolean src_not_temp
= inst
->Src
[0].Register
.File
!= TGSI_FILE_TEMPORARY
;
1786 uint32_t lit_vals
[4];
1788 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
1790 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1791 /* Add perspective divide */
1792 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1793 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1794 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1798 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1799 alu
.dst
.sel
= ctx
->temp_reg
;
1803 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1807 for (i
= 0; i
< 3; i
++) {
1808 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1809 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1810 alu
.src
[0].sel
= ctx
->temp_reg
;
1811 alu
.src
[0].chan
= 3;
1812 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1815 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1816 alu
.dst
.sel
= ctx
->temp_reg
;
1819 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1823 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1824 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1825 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1826 alu
.src
[0].chan
= 0;
1827 alu
.dst
.sel
= ctx
->temp_reg
;
1831 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1834 src_not_temp
= FALSE
;
1835 src_gpr
= ctx
->temp_reg
;
1838 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1839 int src_chan
, src2_chan
;
1841 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
1842 for (i
= 0; i
< 4; i
++) {
1843 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1844 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
1868 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1871 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], src_chan
);
1872 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1875 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], src2_chan
);
1876 alu
.dst
.sel
= ctx
->temp_reg
;
1881 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1886 /* tmp1.z = RCP_e(|tmp1.z|) */
1887 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1888 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1889 alu
.src
[0].sel
= ctx
->temp_reg
;
1890 alu
.src
[0].chan
= 2;
1892 alu
.dst
.sel
= ctx
->temp_reg
;
1896 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1900 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
1901 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
1902 * muladd has no writemask, have to use another temp
1904 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1905 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1908 alu
.src
[0].sel
= ctx
->temp_reg
;
1909 alu
.src
[0].chan
= 0;
1910 alu
.src
[1].sel
= ctx
->temp_reg
;
1911 alu
.src
[1].chan
= 2;
1913 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1914 alu
.src
[2].chan
= 0;
1916 alu
.dst
.sel
= ctx
->temp_reg
;
1920 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1924 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1925 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1928 alu
.src
[0].sel
= ctx
->temp_reg
;
1929 alu
.src
[0].chan
= 1;
1930 alu
.src
[1].sel
= ctx
->temp_reg
;
1931 alu
.src
[1].chan
= 2;
1933 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1934 alu
.src
[2].chan
= 0;
1936 alu
.dst
.sel
= ctx
->temp_reg
;
1941 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1945 lit_vals
[0] = fui(1.5f
);
1947 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
1950 src_not_temp
= FALSE
;
1951 src_gpr
= ctx
->temp_reg
;
1955 for (i
= 0; i
< 4; i
++) {
1956 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1957 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1958 alu
.src
[0].sel
= src_gpr
;
1959 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1960 alu
.dst
.sel
= ctx
->temp_reg
;
1965 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1969 src_gpr
= ctx
->temp_reg
;
1972 opcode
= ctx
->inst_info
->r600_opcode
;
1973 if (opcode
== SQ_TEX_INST_SAMPLE
&&
1974 (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
))
1975 opcode
= SQ_TEX_INST_SAMPLE_C
;
1977 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
1979 tex
.sampler_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
1980 tex
.resource_id
= tex
.sampler_id
;
1981 if (ctx
->shader
->processor_type
== TGSI_PROCESSOR_VERTEX
)
1982 tex
.resource_id
+= PIPE_MAX_ATTRIBS
;
1983 tex
.src_gpr
= src_gpr
;
1984 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
1985 tex
.dst_sel_x
= (inst
->Dst
[0].Register
.WriteMask
& 1) ? 0 : 7;
1986 tex
.dst_sel_y
= (inst
->Dst
[0].Register
.WriteMask
& 2) ? 1 : 7;
1987 tex
.dst_sel_z
= (inst
->Dst
[0].Register
.WriteMask
& 4) ? 2 : 7;
1988 tex
.dst_sel_w
= (inst
->Dst
[0].Register
.WriteMask
& 8) ? 3 : 7;
1994 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
2001 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
2002 tex
.coord_type_x
= 1;
2003 tex
.coord_type_y
= 1;
2004 tex
.coord_type_z
= 1;
2005 tex
.coord_type_w
= 1;
2008 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
)
2011 r
= r600_bc_add_tex(ctx
->bc
, &tex
);
2015 /* add shadow ambient support - gallium doesn't do it yet */
2020 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
2022 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2023 struct r600_bc_alu_src r600_src
[3];
2024 struct r600_bc_alu alu
;
2028 r
= tgsi_split_constant(ctx
, r600_src
);
2031 r
= tgsi_split_literal_constant(ctx
, r600_src
);
2035 for (i
= 0; i
< 4; i
++) {
2036 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2037 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
2038 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2039 alu
.src
[0].chan
= 0;
2040 alu
.src
[1] = r600_src
[0];
2041 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
2043 alu
.dst
.sel
= ctx
->temp_reg
;
2049 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2053 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2057 /* (1 - src0) * src2 */
2058 for (i
= 0; i
< 4; i
++) {
2059 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2060 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2061 alu
.src
[0].sel
= ctx
->temp_reg
;
2062 alu
.src
[0].chan
= i
;
2063 alu
.src
[1] = r600_src
[2];
2064 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
2065 alu
.dst
.sel
= ctx
->temp_reg
;
2071 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2075 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2079 /* src0 * src1 + (1 - src0) * src2 */
2080 for (i
= 0; i
< 4; i
++) {
2081 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2082 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2084 alu
.src
[0] = r600_src
[0];
2085 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2086 alu
.src
[1] = r600_src
[1];
2087 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
2088 alu
.src
[2].sel
= ctx
->temp_reg
;
2089 alu
.src
[2].chan
= i
;
2090 alu
.dst
.sel
= ctx
->temp_reg
;
2095 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2099 return tgsi_helper_copy(ctx
, inst
);
2102 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
2104 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2105 struct r600_bc_alu_src r600_src
[3];
2106 struct r600_bc_alu alu
;
2110 r
= tgsi_split_constant(ctx
, r600_src
);
2113 r
= tgsi_split_literal_constant(ctx
, r600_src
);
2117 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
2120 for (i
= 0; i
< 4; i
++) {
2121 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2122 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
2123 alu
.src
[0] = r600_src
[0];
2124 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2126 alu
.src
[1] = r600_src
[2];
2127 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
2129 alu
.src
[2] = r600_src
[1];
2130 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[1], i
);
2133 alu
.dst
.sel
= ctx
->temp_reg
;
2135 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2144 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2149 return tgsi_helper_copy(ctx
, inst
);
2153 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
2155 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2156 struct r600_bc_alu_src r600_src
[3];
2157 struct r600_bc_alu alu
;
2158 uint32_t use_temp
= 0;
2161 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
2164 r
= tgsi_split_constant(ctx
, r600_src
);
2167 r
= tgsi_split_literal_constant(ctx
, r600_src
);
2171 for (i
= 0; i
< 4; i
++) {
2172 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2173 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2175 alu
.src
[0] = r600_src
[0];
2178 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
2181 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2184 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
2187 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2188 alu
.src
[0].chan
= i
;
2191 alu
.src
[1] = r600_src
[1];
2194 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
2197 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
2200 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
2203 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2204 alu
.src
[1].chan
= i
;
2207 alu
.dst
.sel
= ctx
->temp_reg
;
2213 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2217 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2222 for (i
= 0; i
< 4; i
++) {
2223 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2224 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2226 alu
.src
[0] = r600_src
[0];
2229 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
2232 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
2235 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2238 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2239 alu
.src
[0].chan
= i
;
2242 alu
.src
[1] = r600_src
[1];
2245 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
2248 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
2251 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
2254 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2255 alu
.src
[1].chan
= i
;
2258 alu
.src
[2].sel
= ctx
->temp_reg
;
2260 alu
.src
[2].chan
= i
;
2263 alu
.dst
.sel
= ctx
->temp_reg
;
2265 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2274 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2278 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2283 return tgsi_helper_copy(ctx
, inst
);
2287 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
2289 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2290 struct r600_bc_alu_src r600_src
[3] = { { 0 } };
2291 struct r600_bc_alu alu
;
2294 /* result.x = 2^floor(src); */
2295 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2296 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2298 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2299 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2303 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2305 alu
.dst
.sel
= ctx
->temp_reg
;
2309 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2313 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2317 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2318 alu
.src
[0].sel
= ctx
->temp_reg
;
2319 alu
.src
[0].chan
= 0;
2321 alu
.dst
.sel
= ctx
->temp_reg
;
2325 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2329 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2334 /* result.y = tmp - floor(tmp); */
2335 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2336 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2338 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
2339 alu
.src
[0] = r600_src
[0];
2340 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2343 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2345 alu
.dst
.sel
= ctx
->temp_reg
;
2346 // r = tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
2354 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2357 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2362 /* result.z = RoughApprox2ToX(tmp);*/
2363 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
2364 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2365 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2366 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2369 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2371 alu
.dst
.sel
= ctx
->temp_reg
;
2377 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2380 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2385 /* result.w = 1.0;*/
2386 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
2387 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2389 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2390 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2391 alu
.src
[0].chan
= 0;
2393 alu
.dst
.sel
= ctx
->temp_reg
;
2397 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2400 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2404 return tgsi_helper_copy(ctx
, inst
);
2407 static int tgsi_log(struct r600_shader_ctx
*ctx
)
2409 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2410 struct r600_bc_alu alu
;
2413 /* result.x = floor(log2(src)); */
2414 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2415 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2417 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2418 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2422 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2424 alu
.dst
.sel
= ctx
->temp_reg
;
2428 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2432 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2436 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2437 alu
.src
[0].sel
= ctx
->temp_reg
;
2438 alu
.src
[0].chan
= 0;
2440 alu
.dst
.sel
= ctx
->temp_reg
;
2445 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2449 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2454 /* result.y = src.x / (2 ^ floor(log2(src.x))); */
2455 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2456 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2458 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2459 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2463 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2465 alu
.dst
.sel
= ctx
->temp_reg
;
2470 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2474 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2478 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2480 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2481 alu
.src
[0].sel
= ctx
->temp_reg
;
2482 alu
.src
[0].chan
= 1;
2484 alu
.dst
.sel
= ctx
->temp_reg
;
2489 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2493 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2497 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2499 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2500 alu
.src
[0].sel
= ctx
->temp_reg
;
2501 alu
.src
[0].chan
= 1;
2503 alu
.dst
.sel
= ctx
->temp_reg
;
2508 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2512 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2516 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2518 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2519 alu
.src
[0].sel
= ctx
->temp_reg
;
2520 alu
.src
[0].chan
= 1;
2522 alu
.dst
.sel
= ctx
->temp_reg
;
2527 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2531 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2535 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2537 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2539 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2543 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2545 alu
.src
[1].sel
= ctx
->temp_reg
;
2546 alu
.src
[1].chan
= 1;
2548 alu
.dst
.sel
= ctx
->temp_reg
;
2553 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2557 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2562 /* result.z = log2(src);*/
2563 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
2564 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2566 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2567 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2571 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2573 alu
.dst
.sel
= ctx
->temp_reg
;
2578 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2582 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2587 /* result.w = 1.0; */
2588 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
2589 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2591 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2592 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2593 alu
.src
[0].chan
= 0;
2595 alu
.dst
.sel
= ctx
->temp_reg
;
2600 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2604 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2609 return tgsi_helper_copy(ctx
, inst
);
2612 /* r6/7 only for now */
2613 static int tgsi_eg_arl(struct r600_shader_ctx
*ctx
)
2615 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2616 struct r600_bc_alu alu
;
2619 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2621 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR
;
2622 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2625 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2628 alu
.dst
.sel
= ctx
->temp_reg
;
2630 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2633 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2634 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
;
2635 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2638 alu
.src
[0].sel
= ctx
->temp_reg
;
2639 alu
.src
[0].chan
= 0;
2641 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2646 static int tgsi_r600_arl(struct r600_shader_ctx
*ctx
)
2648 /* TODO from r600c, ar values don't persist between clauses */
2649 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2650 struct r600_bc_alu alu
;
2652 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2654 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR
;
2656 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2659 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2663 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2666 ctx
->bc
->cf_last
->r6xx_uses_waterfall
= 1;
2670 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
2672 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2673 struct r600_bc_alu alu
;
2676 for (i
= 0; i
< 4; i
++) {
2677 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2679 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2680 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2684 if (i
== 0 || i
== 3) {
2685 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2687 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2690 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2693 if (i
== 0 || i
== 2) {
2694 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2696 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[1]);
2699 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
2703 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2710 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
2712 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2713 struct r600_bc_alu alu
;
2716 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2720 alu
.dst
.sel
= ctx
->temp_reg
;
2724 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2727 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2728 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2729 alu
.src
[1].chan
= 0;
2733 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
2739 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
2741 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
2742 ctx
->bc
->cf_last
->pop_count
= pops
;
2746 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
2750 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2754 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
2757 /* TOODO : for 16 vp asic should -= 2; */
2758 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2763 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
2765 if (check_max_only
) {
2778 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
2779 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2780 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2781 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
2787 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2791 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
2794 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2798 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
2799 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2800 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2801 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
2805 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
2807 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
2809 sp
->mid
= (struct r600_bc_cf
**)realloc((void *)sp
->mid
,
2810 sizeof(struct r600_bc_cf
*) * (sp
->num_mid
+ 1));
2811 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
2815 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
2818 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
2819 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
2822 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
2824 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
2836 static int emit_return(struct r600_shader_ctx
*ctx
)
2838 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
2842 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
2845 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_JUMP
);
2846 ctx
->bc
->cf_last
->pop_count
= pops
;
2847 /* TODO work out offset */
2851 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
2856 static void emit_testflag(struct r600_shader_ctx
*ctx
)
2861 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
2864 emit_jump_to_offset(ctx
, 1, 4);
2865 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
2866 pops(ctx
, ifidx
+ 1);
2870 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
2874 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2875 ctx
->bc
->cf_last
->pop_count
= 1;
2877 fc_set_mid(ctx
, fc_sp
);
2883 static int tgsi_if(struct r600_shader_ctx
*ctx
)
2885 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
2887 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
2889 fc_pushlevel(ctx
, FC_IF
);
2891 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
2895 static int tgsi_else(struct r600_shader_ctx
*ctx
)
2897 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
2898 ctx
->bc
->cf_last
->pop_count
= 1;
2900 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
2901 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
2905 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
2908 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
2909 R600_ERR("if/endif unbalanced in shader\n");
2913 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
2914 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2915 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
2917 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2921 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
2925 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
2927 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
2929 fc_pushlevel(ctx
, FC_LOOP
);
2931 /* check stack depth */
2932 callstack_check_depth(ctx
, FC_LOOP
, 0);
2936 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
2940 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
2942 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
2943 R600_ERR("loop/endloop in shader code are not paired.\n");
2947 /* fixup loop pointers - from r600isa
2948 LOOP END points to CF after LOOP START,
2949 LOOP START point to CF after LOOP END
2950 BRK/CONT point to LOOP END CF
2952 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
2954 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2956 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
2957 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
2959 /* TODO add LOOPRET support */
2961 callstack_decrease_current(ctx
, FC_LOOP
);
2965 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
2969 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
2971 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
2976 R600_ERR("Break not inside loop/endloop pair\n");
2980 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2981 ctx
->bc
->cf_last
->pop_count
= 1;
2983 fc_set_mid(ctx
, fscp
);
2986 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
2990 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
2991 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
2992 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
2993 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
2996 * For state trackers other than OpenGL, we'll want to use
2997 * _RECIP_IEEE instead.
2999 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
3001 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
3002 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
3003 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
3004 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
3005 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3006 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3007 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3008 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
3009 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
3010 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
3011 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
3012 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
3013 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
3014 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3015 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
3016 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3018 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3019 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3021 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3022 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3023 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
3024 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3025 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
3026 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3027 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
3028 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
3029 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
3030 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
3032 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3033 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3034 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3035 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3036 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
3037 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
3038 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
3039 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
3040 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3041 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3042 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3043 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3044 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3045 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
3046 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3047 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
3048 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
3049 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
3050 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
3051 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3052 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3053 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3054 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3055 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3056 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3057 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3058 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3059 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3060 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3061 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3062 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3063 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3064 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3065 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
3066 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
3067 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
3068 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3069 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3070 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3071 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3072 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3073 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
3074 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
3076 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3077 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3078 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
3079 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
3081 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3082 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3083 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3084 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3085 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3086 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3087 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3088 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
3089 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3091 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3092 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3093 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3094 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3095 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3096 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3097 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3098 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3099 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
3100 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3101 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3102 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
3103 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3104 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
3105 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3107 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3108 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3109 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3110 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3111 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3113 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3114 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3115 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3116 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3117 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3118 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3119 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3120 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3121 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
3122 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
3124 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3125 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3126 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3127 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3128 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3129 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3130 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3131 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3132 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3133 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3134 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3135 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3136 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3137 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3138 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3139 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3140 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3141 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3142 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3143 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3144 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3145 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3146 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3147 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3148 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3149 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3150 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3151 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3154 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
3155 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
3156 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3157 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
3158 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
3159 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
3160 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
3161 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3162 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
3163 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3164 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3165 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3166 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
3167 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
3168 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
3169 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
3170 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
3171 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
3172 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3173 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
3174 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3176 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3177 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3179 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3180 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3181 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
3182 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3183 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
3184 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3185 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
3186 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
3187 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
3188 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
3190 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3191 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3192 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3193 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3194 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
3195 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
3196 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
3197 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
3198 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3199 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3200 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3201 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3202 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3203 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
3204 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3205 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
3206 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
3207 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
3208 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
3209 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3210 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3211 {TGSI_OPCODE_TXD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3212 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3213 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3214 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3215 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3216 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3217 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3218 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3219 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3220 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3221 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3222 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3223 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
3224 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
3225 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
3226 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3227 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3228 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3229 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3230 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3231 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
3232 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
3234 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3235 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3236 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
3237 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
3239 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3240 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3241 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3242 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3243 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3244 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3245 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3246 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
3247 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3249 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3250 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3251 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3252 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3253 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3254 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3255 {TGSI_OPCODE_TXF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3256 {TGSI_OPCODE_TXQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3257 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
3258 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3259 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3260 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
3261 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3262 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
3263 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3265 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3266 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3267 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3268 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3269 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3271 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3272 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3273 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3274 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3275 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3276 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3277 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3278 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3279 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
3280 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
3282 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3283 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3284 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3285 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3286 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3287 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3288 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3289 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3290 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3291 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3292 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3293 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3294 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3295 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3296 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3297 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3298 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3299 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3300 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3301 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3302 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3303 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3304 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3305 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3306 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3307 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3308 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3309 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},