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_fetch
) >> 8, 0xFFFFFFFF, shader
->bo_fetch
);
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 (rshader
->processor_type
== TGSI_PROCESSOR_VERTEX
&& shader
->bo_fetch
== NULL
) {
221 shader
->bo_fetch
= r600_bo(rctx
->radeon
, rshader
->bc_fetch
.ndw
* 4, 4096, 0, 0);
222 if (shader
->bo_fetch
== NULL
) {
225 ptr
= r600_bo_map(rctx
->radeon
, shader
->bo_fetch
, 0, NULL
);
226 memcpy(ptr
, rshader
->bc_fetch
.bytecode
, rshader
->bc_fetch
.ndw
* 4);
227 r600_bo_unmap(rctx
->radeon
, shader
->bo_fetch
);
229 if (shader
->bo
== NULL
) {
230 shader
->bo
= r600_bo(rctx
->radeon
, rshader
->bc
.ndw
* 4, 4096, 0, 0);
231 if (shader
->bo
== NULL
) {
234 ptr
= r600_bo_map(rctx
->radeon
, shader
->bo
, 0, NULL
);
235 memcpy(ptr
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* 4);
236 r600_bo_unmap(rctx
->radeon
, shader
->bo
);
239 rshader
->flat_shade
= rctx
->flatshade
;
240 switch (rshader
->processor_type
) {
241 case TGSI_PROCESSOR_VERTEX
:
242 if (rshader
->family
>= CHIP_CEDAR
) {
243 evergreen_pipe_shader_vs(ctx
, shader
);
245 r600_pipe_shader_vs(ctx
, shader
);
248 case TGSI_PROCESSOR_FRAGMENT
:
249 if (rshader
->family
>= CHIP_CEDAR
) {
250 evergreen_pipe_shader_ps(ctx
, shader
);
252 r600_pipe_shader_ps(ctx
, shader
);
258 r600_context_pipe_state_set(&rctx
->ctx
, &shader
->rstate
);
262 static int r600_shader_update(struct pipe_context
*ctx
, struct r600_pipe_shader
*rshader
)
264 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
265 struct r600_shader
*shader
= &rshader
->shader
;
266 const struct util_format_description
*desc
;
267 enum pipe_format resource_format
[160];
268 unsigned i
, nresources
= 0;
269 struct r600_bc
*bc
= &shader
->bc_fetch
;
270 struct r600_bc_cf
*cf
;
271 struct r600_bc_vtx
*vtx
;
273 if (shader
->processor_type
!= TGSI_PROCESSOR_VERTEX
)
275 /* doing a full memcmp fell over the refcount */
276 if ((rshader
->vertex_elements
.count
== rctx
->vertex_elements
->count
) &&
277 (!memcmp(&rshader
->vertex_elements
.elements
, &rctx
->vertex_elements
->elements
,
278 rctx
->vertex_elements
->count
* sizeof(struct pipe_vertex_element
)))) {
281 rshader
->vertex_elements
= *rctx
->vertex_elements
;
282 for (i
= 0; i
< rctx
->vertex_elements
->count
; i
++) {
283 resource_format
[nresources
++] = rctx
->vertex_elements
->hw_format
[i
];
285 r600_bo_reference(rctx
->radeon
, &rshader
->bo_fetch
, NULL
);
286 LIST_FOR_EACH_ENTRY(cf
, &bc
->cf
, list
) {
288 case V_SQ_CF_WORD1_SQ_CF_INST_VTX
:
289 case V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC
:
290 LIST_FOR_EACH_ENTRY(vtx
, &cf
->vtx
, list
) {
291 desc
= util_format_description(resource_format
[vtx
->buffer_id
]);
293 R600_ERR("unknown format %d\n", resource_format
[vtx
->buffer_id
]);
296 vtx
->dst_sel_x
= desc
->swizzle
[0];
297 vtx
->dst_sel_y
= desc
->swizzle
[1];
298 vtx
->dst_sel_z
= desc
->swizzle
[2];
299 vtx
->dst_sel_w
= desc
->swizzle
[3];
306 return r600_bc_build(&shader
->bc_fetch
);
309 int r600_pipe_shader_update(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
311 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
316 /* there should be enough input */
317 if (rctx
->vertex_elements
->count
< shader
->shader
.bc
.nresource
) {
318 R600_ERR("%d resources provided, expecting %d\n",
319 rctx
->vertex_elements
->count
, shader
->shader
.bc
.nresource
);
322 r
= r600_shader_update(ctx
, shader
);
325 return r600_pipe_shader(ctx
, shader
);
328 int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
);
329 int r600_pipe_shader_create(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
, const struct tgsi_token
*tokens
)
331 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
334 //fprintf(stderr, "--------------------------------------------------------------\n");
335 //tgsi_dump(tokens, 0);
336 shader
->shader
.family
= r600_get_family(rctx
->radeon
);
337 r
= r600_shader_from_tgsi(tokens
, &shader
->shader
);
339 R600_ERR("translation from TGSI failed !\n");
342 r
= r600_bc_build(&shader
->shader
.bc
);
344 R600_ERR("building bytecode failed !\n");
347 if (shader
->shader
.processor_type
== TGSI_PROCESSOR_VERTEX
) {
348 r
= r600_bc_build(&shader
->shader
.bc_fetch
);
350 R600_ERR("building bytecode failed !\n");
354 //r600_bc_dump(&shader->shader.bc);
355 //fprintf(stderr, "______________________________________________________________\n");
360 r600_pipe_shader_destroy(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
362 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
364 if (shader
->shader
.processor_type
== TGSI_PROCESSOR_VERTEX
) {
365 r600_bo_reference(rctx
->radeon
, &shader
->bo_fetch
, NULL
);
366 r600_bc_clear(&shader
->shader
.bc_fetch
);
369 r600_bo_reference(rctx
->radeon
, &shader
->bo
, NULL
);
371 r600_bc_clear(&shader
->shader
.bc
);
373 /* FIXME: is there more stuff to free? */
377 * tgsi -> r600 shader
379 struct r600_shader_tgsi_instruction
;
381 struct r600_shader_ctx
{
382 struct tgsi_shader_info info
;
383 struct tgsi_parse_context parse
;
384 const struct tgsi_token
*tokens
;
386 unsigned file_offset
[TGSI_FILE_COUNT
];
388 struct r600_shader_tgsi_instruction
*inst_info
;
390 struct r600_bc
*bc_fetch
;
391 struct r600_shader
*shader
;
395 u32 max_driver_temp_used
;
396 /* needed for evergreen interpolation */
397 boolean input_centroid
;
398 boolean input_linear
;
399 boolean input_perspective
;
403 struct r600_shader_tgsi_instruction
{
404 unsigned tgsi_opcode
;
406 unsigned r600_opcode
;
407 int (*process
)(struct r600_shader_ctx
*ctx
);
410 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[], eg_shader_tgsi_instruction
[];
411 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
413 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
415 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
418 if (i
->Instruction
.NumDstRegs
> 1) {
419 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
422 if (i
->Instruction
.Predicate
) {
423 R600_ERR("predicate unsupported\n");
427 if (i
->Instruction
.Label
) {
428 R600_ERR("label unsupported\n");
432 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
433 if (i
->Src
[j
].Register
.Dimension
) {
434 R600_ERR("unsupported src %d (dimension %d)\n", j
,
435 i
->Src
[j
].Register
.Dimension
);
439 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
440 if (i
->Dst
[j
].Register
.Dimension
) {
441 R600_ERR("unsupported dst (dimension)\n");
448 static int evergreen_interp_alu(struct r600_shader_ctx
*ctx
, int input
)
451 struct r600_bc_alu alu
;
452 int gpr
= 0, base_chan
= 0;
455 if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_PERSPECTIVE
) {
457 if (ctx
->shader
->input
[input
].centroid
)
459 } else if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_LINEAR
) {
461 /* if we have perspective add one */
462 if (ctx
->input_perspective
) {
464 /* if we have perspective centroid */
465 if (ctx
->input_centroid
)
468 if (ctx
->shader
->input
[input
].centroid
)
472 /* work out gpr and base_chan from index */
474 base_chan
= (2 * (ij_index
% 2)) + 1;
476 for (i
= 0; i
< 8; i
++) {
477 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
480 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW
;
482 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_XY
;
484 if ((i
> 1) && (i
< 6)) {
485 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
489 alu
.dst
.chan
= i
% 4;
491 alu
.src
[0].sel
= gpr
;
492 alu
.src
[0].chan
= (base_chan
- (i
% 2));
494 alu
.src
[1].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
496 alu
.bank_swizzle_force
= SQ_ALU_VEC_210
;
499 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
507 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
509 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
510 struct r600_bc_vtx vtx
;
514 switch (d
->Declaration
.File
) {
515 case TGSI_FILE_INPUT
:
516 i
= ctx
->shader
->ninput
++;
517 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
518 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
519 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
520 ctx
->shader
->input
[i
].centroid
= d
->Declaration
.Centroid
;
521 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + i
;
522 if (ctx
->type
== TGSI_PROCESSOR_VERTEX
) {
523 /* turn input into fetch */
524 memset(&vtx
, 0, sizeof(struct r600_bc_vtx
));
528 /* register containing the index into the buffer */
531 vtx
.mega_fetch_count
= 0x1F;
532 vtx
.dst_gpr
= ctx
->shader
->input
[i
].gpr
;
537 vtx
.use_const_fields
= 1;
538 r
= r600_bc_add_vtx(ctx
->bc_fetch
, &vtx
);
542 if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
->bc
->chiprev
== CHIPREV_EVERGREEN
) {
543 /* turn input into interpolate on EG */
544 if (ctx
->shader
->input
[i
].name
!= TGSI_SEMANTIC_POSITION
) {
545 if (ctx
->shader
->input
[i
].interpolate
> 0) {
546 ctx
->shader
->input
[i
].lds_pos
= ctx
->shader
->nlds
++;
547 evergreen_interp_alu(ctx
, i
);
552 case TGSI_FILE_OUTPUT
:
553 i
= ctx
->shader
->noutput
++;
554 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
555 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
556 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + i
;
557 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
559 case TGSI_FILE_CONSTANT
:
560 case TGSI_FILE_TEMPORARY
:
561 case TGSI_FILE_SAMPLER
:
562 case TGSI_FILE_ADDRESS
:
565 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
571 static int r600_get_temp(struct r600_shader_ctx
*ctx
)
573 return ctx
->temp_reg
+ ctx
->max_driver_temp_used
++;
577 * for evergreen we need to scan the shader to find the number of GPRs we need to
578 * reserve for interpolation.
580 * we need to know if we are going to emit
581 * any centroid inputs
582 * if perspective and linear are required
584 static int evergreen_gpr_count(struct r600_shader_ctx
*ctx
)
589 ctx
->input_linear
= FALSE
;
590 ctx
->input_perspective
= FALSE
;
591 ctx
->input_centroid
= FALSE
;
592 ctx
->num_interp_gpr
= 1;
594 /* any centroid inputs */
595 for (i
= 0; i
< ctx
->info
.num_inputs
; i
++) {
596 /* skip position/face */
597 if (ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_POSITION
||
598 ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_FACE
)
600 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_LINEAR
)
601 ctx
->input_linear
= TRUE
;
602 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_PERSPECTIVE
)
603 ctx
->input_perspective
= TRUE
;
604 if (ctx
->info
.input_centroid
[i
])
605 ctx
->input_centroid
= TRUE
;
609 /* ignoring sample for now */
610 if (ctx
->input_perspective
)
612 if (ctx
->input_linear
)
614 if (ctx
->input_centroid
)
617 ctx
->num_interp_gpr
+= (num_baryc
+ 1) >> 1;
619 /* TODO PULL MODEL and LINE STIPPLE, FIXED PT POS */
620 return ctx
->num_interp_gpr
;
623 int r600_shader_from_tgsi(const struct tgsi_token
*tokens
, struct r600_shader
*shader
)
625 struct tgsi_full_immediate
*immediate
;
626 struct r600_shader_ctx ctx
;
627 struct r600_bc_output output
[32];
628 unsigned output_done
, noutput
;
632 ctx
.bc
= &shader
->bc
;
633 ctx
.bc_fetch
= &shader
->bc_fetch
;
635 r
= r600_bc_init(ctx
.bc
, shader
->family
);
639 tgsi_scan_shader(tokens
, &ctx
.info
);
640 tgsi_parse_init(&ctx
.parse
, tokens
);
641 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
642 shader
->processor_type
= ctx
.type
;
643 if (shader
->processor_type
== TGSI_PROCESSOR_VERTEX
) {
644 r
= r600_bc_init(ctx
.bc_fetch
, shader
->family
);
647 ctx
.bc_fetch
->type
= -1;
649 ctx
.bc
->type
= shader
->processor_type
;
651 /* register allocations */
652 /* Values [0,127] correspond to GPR[0..127].
653 * Values [128,159] correspond to constant buffer bank 0
654 * Values [160,191] correspond to constant buffer bank 1
655 * Values [256,511] correspond to cfile constants c[0..255].
656 * Other special values are shown in the list below.
657 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
658 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
659 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
660 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
661 * 248 SQ_ALU_SRC_0: special constant 0.0.
662 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
663 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
664 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
665 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
666 * 253 SQ_ALU_SRC_LITERAL: literal constant.
667 * 254 SQ_ALU_SRC_PV: previous vector result.
668 * 255 SQ_ALU_SRC_PS: previous scalar result.
670 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
671 ctx
.file_offset
[i
] = 0;
673 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
674 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
675 if (ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
) {
676 r600_bc_add_cfinst(ctx
.bc
, EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
678 r600_bc_add_cfinst(ctx
.bc
, V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
681 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
) {
682 ctx
.file_offset
[TGSI_FILE_INPUT
] = evergreen_gpr_count(&ctx
);
684 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
685 ctx
.info
.file_count
[TGSI_FILE_INPUT
];
686 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
687 ctx
.info
.file_count
[TGSI_FILE_OUTPUT
];
689 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 128;
691 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = 253;
692 ctx
.temp_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
693 ctx
.info
.file_count
[TGSI_FILE_TEMPORARY
];
698 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
699 tgsi_parse_token(&ctx
.parse
);
700 switch (ctx
.parse
.FullToken
.Token
.Type
) {
701 case TGSI_TOKEN_TYPE_IMMEDIATE
:
702 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
703 ctx
.literals
= realloc(ctx
.literals
, (ctx
.nliterals
+ 1) * 16);
704 if(ctx
.literals
== NULL
) {
708 ctx
.literals
[ctx
.nliterals
* 4 + 0] = immediate
->u
[0].Uint
;
709 ctx
.literals
[ctx
.nliterals
* 4 + 1] = immediate
->u
[1].Uint
;
710 ctx
.literals
[ctx
.nliterals
* 4 + 2] = immediate
->u
[2].Uint
;
711 ctx
.literals
[ctx
.nliterals
* 4 + 3] = immediate
->u
[3].Uint
;
714 case TGSI_TOKEN_TYPE_DECLARATION
:
715 r
= tgsi_declaration(&ctx
);
719 case TGSI_TOKEN_TYPE_INSTRUCTION
:
720 r
= tgsi_is_supported(&ctx
);
723 ctx
.max_driver_temp_used
= 0;
724 /* reserve first tmp for everyone */
726 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
727 if (ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
)
728 ctx
.inst_info
= &eg_shader_tgsi_instruction
[opcode
];
730 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
731 r
= ctx
.inst_info
->process(&ctx
);
734 r
= r600_bc_add_literal(ctx
.bc
, ctx
.value
);
739 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
745 noutput
= shader
->noutput
;
746 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
747 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
748 output
[i
].gpr
= shader
->output
[i
].gpr
;
749 output
[i
].elem_size
= 3;
750 output
[i
].swizzle_x
= 0;
751 output
[i
].swizzle_y
= 1;
752 output
[i
].swizzle_z
= 2;
753 output
[i
].swizzle_w
= 3;
754 output
[i
].barrier
= 1;
755 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
756 output
[i
].array_base
= i
- pos0
;
757 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
759 case TGSI_PROCESSOR_VERTEX
:
760 if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
761 output
[i
].array_base
= 60;
762 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
763 /* position doesn't count in array_base */
766 if (shader
->output
[i
].name
== TGSI_SEMANTIC_PSIZE
) {
767 output
[i
].array_base
= 61;
768 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
769 /* position doesn't count in array_base */
773 case TGSI_PROCESSOR_FRAGMENT
:
774 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
775 output
[i
].array_base
= shader
->output
[i
].sid
;
776 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
777 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
778 output
[i
].array_base
= 61;
779 output
[i
].swizzle_x
= 2;
780 output
[i
].swizzle_y
= 7;
781 output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
782 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
783 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
) {
784 output
[i
].array_base
= 61;
785 output
[i
].swizzle_x
= 7;
786 output
[i
].swizzle_y
= 1;
787 output
[i
].swizzle_z
= output
[i
].swizzle_w
= 7;
788 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
790 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
796 R600_ERR("unsupported processor type %d\n", ctx
.type
);
801 /* add fake param output for vertex shader if no param is exported */
802 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
803 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
804 if (output
[i
].type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
) {
810 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
812 output
[i
].elem_size
= 3;
813 output
[i
].swizzle_x
= 0;
814 output
[i
].swizzle_y
= 1;
815 output
[i
].swizzle_z
= 2;
816 output
[i
].swizzle_w
= 3;
817 output
[i
].barrier
= 1;
818 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
819 output
[i
].array_base
= 0;
820 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
824 /* add fake pixel export */
825 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& !noutput
) {
826 memset(&output
[0], 0, sizeof(struct r600_bc_output
));
828 output
[0].elem_size
= 3;
829 output
[0].swizzle_x
= 7;
830 output
[0].swizzle_y
= 7;
831 output
[0].swizzle_z
= 7;
832 output
[0].swizzle_w
= 7;
833 output
[0].barrier
= 1;
834 output
[0].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
835 output
[0].array_base
= 0;
836 output
[0].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
839 /* set export done on last export of each type */
840 for (i
= noutput
- 1, output_done
= 0; i
>= 0; i
--) {
841 if (i
== (noutput
- 1)) {
842 output
[i
].end_of_program
= 1;
844 if (!(output_done
& (1 << output
[i
].type
))) {
845 output_done
|= (1 << output
[i
].type
);
846 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
);
849 /* add return to fetch shader */
850 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
851 if (ctx
.bc
->chiprev
== CHIPREV_EVERGREEN
) {
852 r600_bc_add_cfinst(ctx
.bc_fetch
, EG_V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
854 r600_bc_add_cfinst(ctx
.bc_fetch
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
857 /* add output to bytecode */
858 for (i
= 0; i
< noutput
; i
++) {
859 r
= r600_bc_add_output(ctx
.bc
, &output
[i
]);
864 tgsi_parse_free(&ctx
.parse
);
868 tgsi_parse_free(&ctx
.parse
);
872 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
874 R600_ERR("%d tgsi opcode unsupported\n", ctx
->inst_info
->tgsi_opcode
);
878 static int tgsi_end(struct r600_shader_ctx
*ctx
)
883 static int tgsi_src(struct r600_shader_ctx
*ctx
,
884 const struct tgsi_full_src_register
*tgsi_src
,
885 struct r600_bc_alu_src
*r600_src
)
888 memset(r600_src
, 0, sizeof(struct r600_bc_alu_src
));
889 r600_src
->sel
= tgsi_src
->Register
.Index
;
890 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
892 index
= tgsi_src
->Register
.Index
;
893 ctx
->value
[0] = ctx
->literals
[index
* 4 + 0];
894 ctx
->value
[1] = ctx
->literals
[index
* 4 + 1];
895 ctx
->value
[2] = ctx
->literals
[index
* 4 + 2];
896 ctx
->value
[3] = ctx
->literals
[index
* 4 + 3];
898 if (tgsi_src
->Register
.Indirect
)
899 r600_src
->rel
= V_SQ_REL_RELATIVE
;
900 r600_src
->neg
= tgsi_src
->Register
.Negate
;
901 r600_src
->abs
= tgsi_src
->Register
.Absolute
;
902 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
906 static int tgsi_dst(struct r600_shader_ctx
*ctx
,
907 const struct tgsi_full_dst_register
*tgsi_dst
,
909 struct r600_bc_alu_dst
*r600_dst
)
911 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
913 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
914 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
915 r600_dst
->chan
= swizzle
;
917 if (tgsi_dst
->Register
.Indirect
)
918 r600_dst
->rel
= V_SQ_REL_RELATIVE
;
919 if (inst
->Instruction
.Saturate
) {
925 static unsigned tgsi_chan(const struct tgsi_full_src_register
*tgsi_src
, unsigned swizzle
)
929 return tgsi_src
->Register
.SwizzleX
;
931 return tgsi_src
->Register
.SwizzleY
;
933 return tgsi_src
->Register
.SwizzleZ
;
935 return tgsi_src
->Register
.SwizzleW
;
941 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
943 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
944 struct r600_bc_alu alu
;
945 int i
, j
, k
, nconst
, r
;
947 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
948 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
951 r
= tgsi_src(ctx
, &inst
->Src
[i
], &r600_src
[i
]);
956 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
957 if (j
> 0 && inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
958 int treg
= r600_get_temp(ctx
);
959 for (k
= 0; k
< 4; k
++) {
960 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
961 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
962 alu
.src
[0].sel
= r600_src
[i
].sel
;
964 alu
.src
[0].rel
= r600_src
[i
].rel
;
970 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
974 r600_src
[i
].sel
= treg
;
982 /* need to move any immediate into a temp - for trig functions which use literal for PI stuff */
983 static int tgsi_split_literal_constant(struct r600_shader_ctx
*ctx
, struct r600_bc_alu_src r600_src
[3])
985 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
986 struct r600_bc_alu alu
;
987 int i
, j
, k
, nliteral
, r
;
989 for (i
= 0, nliteral
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
990 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_IMMEDIATE
) {
994 for (i
= 0, j
= nliteral
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
995 if (j
> 0 && inst
->Src
[i
].Register
.File
== TGSI_FILE_IMMEDIATE
) {
996 int treg
= r600_get_temp(ctx
);
997 for (k
= 0; k
< 4; k
++) {
998 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
999 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1000 alu
.src
[0].sel
= r600_src
[i
].sel
;
1001 alu
.src
[0].chan
= k
;
1007 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1011 r
= r600_bc_add_literal(ctx
->bc
, &ctx
->literals
[inst
->Src
[i
].Register
.Index
* 4]);
1014 r600_src
[i
].sel
= treg
;
1021 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
)
1023 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1024 struct r600_bc_alu_src r600_src
[3];
1025 struct r600_bc_alu alu
;
1029 for (i
= 0; i
< 4; i
++) {
1030 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
)) {
1035 r
= tgsi_split_constant(ctx
, r600_src
);
1038 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1041 for (i
= 0; i
< lasti
+ 1; i
++) {
1042 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1045 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1046 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1050 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1052 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1053 alu
.src
[j
] = r600_src
[j
];
1054 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1057 alu
.src
[0] = r600_src
[1];
1058 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], i
);
1060 alu
.src
[1] = r600_src
[0];
1061 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1063 /* handle some special cases */
1064 switch (ctx
->inst_info
->tgsi_opcode
) {
1065 case TGSI_OPCODE_SUB
:
1068 case TGSI_OPCODE_ABS
:
1077 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1084 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
1086 return tgsi_op2_s(ctx
, 0);
1089 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
1091 return tgsi_op2_s(ctx
, 1);
1095 * r600 - trunc to -PI..PI range
1096 * r700 - normalize by dividing by 2PI
1099 static int tgsi_setup_trig(struct r600_shader_ctx
*ctx
,
1100 struct r600_bc_alu_src r600_src
[3])
1102 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1104 uint32_t lit_vals
[4];
1105 struct r600_bc_alu alu
;
1107 memset(lit_vals
, 0, 4*4);
1108 r
= tgsi_split_constant(ctx
, r600_src
);
1111 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1115 lit_vals
[0] = fui(1.0 /(3.1415926535 * 2));
1116 lit_vals
[1] = fui(0.5f
);
1118 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1119 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1123 alu
.dst
.sel
= ctx
->temp_reg
;
1126 alu
.src
[0] = r600_src
[0];
1127 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1129 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1130 alu
.src
[1].chan
= 0;
1131 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1132 alu
.src
[2].chan
= 1;
1134 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1137 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
1141 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1142 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
1145 alu
.dst
.sel
= ctx
->temp_reg
;
1148 alu
.src
[0].sel
= ctx
->temp_reg
;
1149 alu
.src
[0].chan
= 0;
1151 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1155 if (ctx
->bc
->chiprev
== CHIPREV_R600
) {
1156 lit_vals
[0] = fui(3.1415926535897f
* 2.0f
);
1157 lit_vals
[1] = fui(-3.1415926535897f
);
1159 lit_vals
[0] = fui(1.0f
);
1160 lit_vals
[1] = fui(-0.5f
);
1163 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1164 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1168 alu
.dst
.sel
= ctx
->temp_reg
;
1171 alu
.src
[0].sel
= ctx
->temp_reg
;
1172 alu
.src
[0].chan
= 0;
1174 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1175 alu
.src
[1].chan
= 0;
1176 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1177 alu
.src
[2].chan
= 1;
1179 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1182 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
1188 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
1190 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1191 struct r600_bc_alu_src r600_src
[3];
1192 struct r600_bc_alu alu
;
1196 r
= tgsi_setup_trig(ctx
, r600_src
);
1200 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1201 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1203 alu
.dst
.sel
= ctx
->temp_reg
;
1206 alu
.src
[0].sel
= ctx
->temp_reg
;
1207 alu
.src
[0].chan
= 0;
1209 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1213 /* replicate result */
1214 for (i
= 0; i
< 4; i
++) {
1215 if (inst
->Dst
[0].Register
.WriteMask
& (1 << i
))
1218 for (i
= 0; i
< lasti
+ 1; i
++) {
1219 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1222 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1223 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1225 alu
.src
[0].sel
= ctx
->temp_reg
;
1226 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1231 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1238 static int tgsi_scs(struct r600_shader_ctx
*ctx
)
1240 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1241 struct r600_bc_alu_src r600_src
[3];
1242 struct r600_bc_alu alu
;
1245 /* We'll only need the trig stuff if we are going to write to the
1246 * X or Y components of the destination vector.
1248 if (likely(inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_XY
)) {
1249 r
= tgsi_setup_trig(ctx
, r600_src
);
1255 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_X
) {
1256 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1257 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
1258 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1262 alu
.src
[0].sel
= ctx
->temp_reg
;
1263 alu
.src
[0].chan
= 0;
1265 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1271 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Y
) {
1272 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1273 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
1274 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1278 alu
.src
[0].sel
= ctx
->temp_reg
;
1279 alu
.src
[0].chan
= 0;
1281 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1287 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Z
) {
1288 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1290 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1292 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1296 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1297 alu
.src
[0].chan
= 0;
1301 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1305 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1311 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
1312 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1314 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1316 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1320 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1321 alu
.src
[0].chan
= 0;
1325 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1329 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1337 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
1339 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1340 struct r600_bc_alu alu
;
1343 for (i
= 0; i
< 4; i
++) {
1344 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1345 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1349 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1351 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
1352 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1355 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1358 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1363 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1367 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1371 /* kill must be last in ALU */
1372 ctx
->bc
->force_add_cf
= 1;
1373 ctx
->shader
->uses_kill
= TRUE
;
1377 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
1379 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1380 struct r600_bc_alu alu
;
1381 struct r600_bc_alu_src r600_src
[3];
1384 r
= tgsi_split_constant(ctx
, r600_src
);
1387 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1392 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1393 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1394 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
1395 alu
.src
[0].chan
= 0;
1396 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1399 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
1400 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1404 /* dst.y = max(src.x, 0.0) */
1405 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1406 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1407 alu
.src
[0] = r600_src
[0];
1408 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1409 alu
.src
[1].chan
= 0;
1410 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1413 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
1414 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1419 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1420 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1421 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1422 alu
.src
[0].chan
= 0;
1423 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1426 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
1428 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1432 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1436 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
1441 /* dst.z = log(src.y) */
1442 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1443 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1444 alu
.src
[0] = r600_src
[0];
1445 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
1446 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1450 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1454 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1458 chan
= alu
.dst
.chan
;
1461 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
1462 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1463 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
1464 alu
.src
[0] = r600_src
[0];
1465 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1466 alu
.src
[1].sel
= sel
;
1467 alu
.src
[1].chan
= chan
;
1469 alu
.src
[2] = r600_src
[0];
1470 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], 0);
1471 alu
.dst
.sel
= ctx
->temp_reg
;
1476 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1480 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1483 /* dst.z = exp(tmp.x) */
1484 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1485 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1486 alu
.src
[0].sel
= ctx
->temp_reg
;
1487 alu
.src
[0].chan
= 0;
1488 r
= tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1492 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1499 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
1501 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1502 struct r600_bc_alu alu
;
1505 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1508 * For state trackers other than OpenGL, we'll want to use
1509 * _RECIPSQRT_IEEE instead.
1511 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
1513 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1514 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1517 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1520 alu
.dst
.sel
= ctx
->temp_reg
;
1523 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1526 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1529 /* replicate result */
1530 return tgsi_helper_tempx_replicate(ctx
);
1533 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1535 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1536 struct r600_bc_alu alu
;
1539 for (i
= 0; i
< 4; i
++) {
1540 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1541 alu
.src
[0].sel
= ctx
->temp_reg
;
1542 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1544 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1547 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1550 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1557 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1559 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1560 struct r600_bc_alu alu
;
1563 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1564 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1565 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1566 r
= tgsi_src(ctx
, &inst
->Src
[i
], &alu
.src
[i
]);
1569 alu
.src
[i
].chan
= tgsi_chan(&inst
->Src
[i
], 0);
1571 alu
.dst
.sel
= ctx
->temp_reg
;
1574 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1577 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1580 /* replicate result */
1581 return tgsi_helper_tempx_replicate(ctx
);
1584 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1586 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1587 struct r600_bc_alu alu
;
1591 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1592 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1593 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1596 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
1597 alu
.dst
.sel
= ctx
->temp_reg
;
1600 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1603 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1607 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1608 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL_IEEE
);
1609 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[0]);
1612 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[1], 0);
1613 alu
.src
[1].sel
= ctx
->temp_reg
;
1614 alu
.dst
.sel
= ctx
->temp_reg
;
1617 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1620 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1623 /* POW(a,b) = EXP2(b * LOG2(a))*/
1624 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1625 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1626 alu
.src
[0].sel
= ctx
->temp_reg
;
1627 alu
.dst
.sel
= ctx
->temp_reg
;
1630 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1633 r
= r600_bc_add_literal(ctx
->bc
,ctx
->value
);
1636 return tgsi_helper_tempx_replicate(ctx
);
1639 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1641 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1642 struct r600_bc_alu alu
;
1643 struct r600_bc_alu_src r600_src
[3];
1646 r
= tgsi_split_constant(ctx
, r600_src
);
1649 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1653 /* tmp = (src > 0 ? 1 : src) */
1654 for (i
= 0; i
< 4; i
++) {
1655 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1656 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1659 alu
.dst
.sel
= ctx
->temp_reg
;
1662 alu
.src
[0] = r600_src
[0];
1663 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
1665 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1667 alu
.src
[2] = r600_src
[0];
1668 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[0], i
);
1671 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1675 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1679 /* dst = (-tmp > 0 ? -1 : tmp) */
1680 for (i
= 0; i
< 4; i
++) {
1681 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1682 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1684 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1688 alu
.src
[0].sel
= ctx
->temp_reg
;
1689 alu
.src
[0].chan
= i
;
1692 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1695 alu
.src
[2].sel
= ctx
->temp_reg
;
1696 alu
.src
[2].chan
= i
;
1700 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1707 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1709 struct r600_bc_alu alu
;
1712 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
1715 for (i
= 0; i
< 4; i
++) {
1716 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1717 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1718 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
1721 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1722 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1725 alu
.src
[0].sel
= ctx
->temp_reg
;
1726 alu
.src
[0].chan
= i
;
1731 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1738 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1740 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1741 struct r600_bc_alu_src r600_src
[3];
1742 struct r600_bc_alu alu
;
1745 r
= tgsi_split_constant(ctx
, r600_src
);
1748 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1751 /* do it in 2 step as op3 doesn't support writemask */
1752 for (i
= 0; i
< 4; i
++) {
1753 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1754 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1755 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1756 alu
.src
[j
] = r600_src
[j
];
1757 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1759 alu
.dst
.sel
= ctx
->temp_reg
;
1766 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1770 return tgsi_helper_copy(ctx
, inst
);
1773 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1775 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1776 struct r600_bc_alu_src r600_src
[3];
1777 struct r600_bc_alu alu
;
1780 r
= tgsi_split_constant(ctx
, r600_src
);
1783 r
= tgsi_split_literal_constant(ctx
, r600_src
);
1786 for (i
= 0; i
< 4; i
++) {
1787 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1788 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1789 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1790 alu
.src
[j
] = r600_src
[j
];
1791 alu
.src
[j
].chan
= tgsi_chan(&inst
->Src
[j
], i
);
1793 alu
.dst
.sel
= ctx
->temp_reg
;
1796 /* handle some special cases */
1797 switch (ctx
->inst_info
->tgsi_opcode
) {
1798 case TGSI_OPCODE_DP2
:
1800 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1801 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1804 case TGSI_OPCODE_DP3
:
1806 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1807 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1810 case TGSI_OPCODE_DPH
:
1812 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1813 alu
.src
[0].chan
= 0;
1823 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1827 return tgsi_helper_copy(ctx
, inst
);
1830 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1832 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1833 struct r600_bc_tex tex
;
1834 struct r600_bc_alu alu
;
1838 boolean src_not_temp
= inst
->Src
[0].Register
.File
!= TGSI_FILE_TEMPORARY
;
1839 uint32_t lit_vals
[4];
1841 src_gpr
= ctx
->file_offset
[inst
->Src
[0].Register
.File
] + inst
->Src
[0].Register
.Index
;
1843 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1844 /* Add perspective divide */
1845 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1846 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1847 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1851 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 3);
1852 alu
.dst
.sel
= ctx
->temp_reg
;
1856 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1860 for (i
= 0; i
< 3; i
++) {
1861 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1862 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1863 alu
.src
[0].sel
= ctx
->temp_reg
;
1864 alu
.src
[0].chan
= 3;
1865 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1868 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
1869 alu
.dst
.sel
= ctx
->temp_reg
;
1872 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1876 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1877 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1878 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1879 alu
.src
[0].chan
= 0;
1880 alu
.dst
.sel
= ctx
->temp_reg
;
1884 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1887 src_not_temp
= FALSE
;
1888 src_gpr
= ctx
->temp_reg
;
1891 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1892 int src_chan
, src2_chan
;
1894 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
1895 for (i
= 0; i
< 4; i
++) {
1896 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1897 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
1921 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
1924 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], src_chan
);
1925 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[1]);
1928 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], src2_chan
);
1929 alu
.dst
.sel
= ctx
->temp_reg
;
1934 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1939 /* tmp1.z = RCP_e(|tmp1.z|) */
1940 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1941 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1942 alu
.src
[0].sel
= ctx
->temp_reg
;
1943 alu
.src
[0].chan
= 2;
1945 alu
.dst
.sel
= ctx
->temp_reg
;
1949 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1953 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
1954 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
1955 * muladd has no writemask, have to use another temp
1957 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1958 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1961 alu
.src
[0].sel
= ctx
->temp_reg
;
1962 alu
.src
[0].chan
= 0;
1963 alu
.src
[1].sel
= ctx
->temp_reg
;
1964 alu
.src
[1].chan
= 2;
1966 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1967 alu
.src
[2].chan
= 0;
1969 alu
.dst
.sel
= ctx
->temp_reg
;
1973 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1977 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1978 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1981 alu
.src
[0].sel
= ctx
->temp_reg
;
1982 alu
.src
[0].chan
= 1;
1983 alu
.src
[1].sel
= ctx
->temp_reg
;
1984 alu
.src
[1].chan
= 2;
1986 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1987 alu
.src
[2].chan
= 0;
1989 alu
.dst
.sel
= ctx
->temp_reg
;
1994 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1998 lit_vals
[0] = fui(1.5f
);
2000 r
= r600_bc_add_literal(ctx
->bc
, lit_vals
);
2003 src_not_temp
= FALSE
;
2004 src_gpr
= ctx
->temp_reg
;
2008 for (i
= 0; i
< 4; i
++) {
2009 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2010 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2011 alu
.src
[0].sel
= src_gpr
;
2012 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2013 alu
.dst
.sel
= ctx
->temp_reg
;
2018 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2022 src_gpr
= ctx
->temp_reg
;
2025 opcode
= ctx
->inst_info
->r600_opcode
;
2026 if (opcode
== SQ_TEX_INST_SAMPLE
&&
2027 (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
))
2028 opcode
= SQ_TEX_INST_SAMPLE_C
;
2030 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
2032 tex
.sampler_id
= ctx
->file_offset
[inst
->Src
[1].Register
.File
] + inst
->Src
[1].Register
.Index
;
2033 tex
.resource_id
= tex
.sampler_id
;
2034 tex
.src_gpr
= src_gpr
;
2035 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
2036 tex
.dst_sel_x
= (inst
->Dst
[0].Register
.WriteMask
& 1) ? 0 : 7;
2037 tex
.dst_sel_y
= (inst
->Dst
[0].Register
.WriteMask
& 2) ? 1 : 7;
2038 tex
.dst_sel_z
= (inst
->Dst
[0].Register
.WriteMask
& 4) ? 2 : 7;
2039 tex
.dst_sel_w
= (inst
->Dst
[0].Register
.WriteMask
& 8) ? 3 : 7;
2045 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
2052 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
2053 tex
.coord_type_x
= 1;
2054 tex
.coord_type_y
= 1;
2055 tex
.coord_type_z
= 1;
2056 tex
.coord_type_w
= 1;
2059 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
)
2062 r
= r600_bc_add_tex(ctx
->bc
, &tex
);
2066 /* add shadow ambient support - gallium doesn't do it yet */
2070 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
2072 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2073 struct r600_bc_alu_src r600_src
[3];
2074 struct r600_bc_alu alu
;
2078 r
= tgsi_split_constant(ctx
, r600_src
);
2081 r
= tgsi_split_literal_constant(ctx
, r600_src
);
2085 for (i
= 0; i
< 4; i
++) {
2086 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2087 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
2088 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2089 alu
.src
[0].chan
= 0;
2090 alu
.src
[1] = r600_src
[0];
2091 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[0], i
);
2093 alu
.dst
.sel
= ctx
->temp_reg
;
2099 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2103 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2107 /* (1 - src0) * src2 */
2108 for (i
= 0; i
< 4; i
++) {
2109 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2110 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2111 alu
.src
[0].sel
= ctx
->temp_reg
;
2112 alu
.src
[0].chan
= i
;
2113 alu
.src
[1] = r600_src
[2];
2114 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
2115 alu
.dst
.sel
= ctx
->temp_reg
;
2121 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2125 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2129 /* src0 * src1 + (1 - src0) * src2 */
2130 for (i
= 0; i
< 4; i
++) {
2131 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2132 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2134 alu
.src
[0] = r600_src
[0];
2135 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2136 alu
.src
[1] = r600_src
[1];
2137 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
2138 alu
.src
[2].sel
= ctx
->temp_reg
;
2139 alu
.src
[2].chan
= i
;
2140 alu
.dst
.sel
= ctx
->temp_reg
;
2145 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2149 return tgsi_helper_copy(ctx
, inst
);
2152 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
2154 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2155 struct r600_bc_alu_src r600_src
[3];
2156 struct r600_bc_alu alu
;
2160 r
= tgsi_split_constant(ctx
, r600_src
);
2163 r
= tgsi_split_literal_constant(ctx
, r600_src
);
2167 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
2170 for (i
= 0; i
< 4; i
++) {
2171 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2172 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
2173 alu
.src
[0] = r600_src
[0];
2174 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2176 alu
.src
[1] = r600_src
[2];
2177 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[2], i
);
2179 alu
.src
[2] = r600_src
[1];
2180 alu
.src
[2].chan
= tgsi_chan(&inst
->Src
[1], i
);
2183 alu
.dst
.sel
= ctx
->temp_reg
;
2185 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2194 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2199 return tgsi_helper_copy(ctx
, inst
);
2203 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
2205 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2206 struct r600_bc_alu_src r600_src
[3];
2207 struct r600_bc_alu alu
;
2208 uint32_t use_temp
= 0;
2211 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
2214 r
= tgsi_split_constant(ctx
, r600_src
);
2217 r
= tgsi_split_literal_constant(ctx
, r600_src
);
2221 for (i
= 0; i
< 4; i
++) {
2222 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2223 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2225 alu
.src
[0] = r600_src
[0];
2228 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
2231 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2234 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
2237 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2238 alu
.src
[0].chan
= i
;
2241 alu
.src
[1] = r600_src
[1];
2244 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
2247 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
2250 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
2253 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2254 alu
.src
[1].chan
= i
;
2257 alu
.dst
.sel
= ctx
->temp_reg
;
2263 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2267 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2272 for (i
= 0; i
< 4; i
++) {
2273 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2274 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2276 alu
.src
[0] = r600_src
[0];
2279 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 1);
2282 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 2);
2285 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2288 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2289 alu
.src
[0].chan
= i
;
2292 alu
.src
[1] = r600_src
[1];
2295 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 2);
2298 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 0);
2301 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], 1);
2304 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2305 alu
.src
[1].chan
= i
;
2308 alu
.src
[2].sel
= ctx
->temp_reg
;
2310 alu
.src
[2].chan
= i
;
2313 alu
.dst
.sel
= ctx
->temp_reg
;
2315 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2324 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2328 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2333 return tgsi_helper_copy(ctx
, inst
);
2337 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
2339 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2340 struct r600_bc_alu_src r600_src
[3] = { { 0 } };
2341 struct r600_bc_alu alu
;
2344 /* result.x = 2^floor(src); */
2345 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2346 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2348 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2349 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2353 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2355 alu
.dst
.sel
= ctx
->temp_reg
;
2359 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2363 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2367 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2368 alu
.src
[0].sel
= ctx
->temp_reg
;
2369 alu
.src
[0].chan
= 0;
2371 alu
.dst
.sel
= ctx
->temp_reg
;
2375 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2379 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2384 /* result.y = tmp - floor(tmp); */
2385 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2386 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2388 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
2389 alu
.src
[0] = r600_src
[0];
2390 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2393 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2395 alu
.dst
.sel
= ctx
->temp_reg
;
2396 // r = tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
2404 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2407 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2412 /* result.z = RoughApprox2ToX(tmp);*/
2413 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
2414 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2415 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2416 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2419 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2421 alu
.dst
.sel
= ctx
->temp_reg
;
2427 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2430 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2435 /* result.w = 1.0;*/
2436 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
2437 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2439 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2440 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2441 alu
.src
[0].chan
= 0;
2443 alu
.dst
.sel
= ctx
->temp_reg
;
2447 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2450 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2454 return tgsi_helper_copy(ctx
, inst
);
2457 static int tgsi_log(struct r600_shader_ctx
*ctx
)
2459 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2460 struct r600_bc_alu alu
;
2463 /* result.x = floor(log2(src)); */
2464 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2465 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2467 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2468 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2472 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2474 alu
.dst
.sel
= ctx
->temp_reg
;
2478 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2482 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2486 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2487 alu
.src
[0].sel
= ctx
->temp_reg
;
2488 alu
.src
[0].chan
= 0;
2490 alu
.dst
.sel
= ctx
->temp_reg
;
2495 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2499 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2504 /* result.y = src.x / (2 ^ floor(log2(src.x))); */
2505 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2506 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2508 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2509 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2513 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2515 alu
.dst
.sel
= ctx
->temp_reg
;
2520 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2524 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2528 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2530 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2531 alu
.src
[0].sel
= ctx
->temp_reg
;
2532 alu
.src
[0].chan
= 1;
2534 alu
.dst
.sel
= ctx
->temp_reg
;
2539 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2543 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2547 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2549 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2550 alu
.src
[0].sel
= ctx
->temp_reg
;
2551 alu
.src
[0].chan
= 1;
2553 alu
.dst
.sel
= ctx
->temp_reg
;
2558 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2562 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2566 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2568 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2569 alu
.src
[0].sel
= ctx
->temp_reg
;
2570 alu
.src
[0].chan
= 1;
2572 alu
.dst
.sel
= ctx
->temp_reg
;
2577 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2581 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2585 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2587 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2589 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2593 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2595 alu
.src
[1].sel
= ctx
->temp_reg
;
2596 alu
.src
[1].chan
= 1;
2598 alu
.dst
.sel
= ctx
->temp_reg
;
2603 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2607 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2612 /* result.z = log2(src);*/
2613 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
2614 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2616 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2617 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2621 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2623 alu
.dst
.sel
= ctx
->temp_reg
;
2628 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2632 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2637 /* result.w = 1.0; */
2638 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
2639 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2641 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2642 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2643 alu
.src
[0].chan
= 0;
2645 alu
.dst
.sel
= ctx
->temp_reg
;
2650 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2654 r
= r600_bc_add_literal(ctx
->bc
, ctx
->value
);
2659 return tgsi_helper_copy(ctx
, inst
);
2662 static int tgsi_eg_arl(struct r600_shader_ctx
*ctx
)
2664 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2665 struct r600_bc_alu alu
;
2667 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2669 switch (inst
->Instruction
.Opcode
) {
2670 case TGSI_OPCODE_ARL
:
2671 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR
;
2673 case TGSI_OPCODE_ARR
:
2674 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
2681 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2684 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2687 alu
.dst
.sel
= ctx
->temp_reg
;
2689 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2692 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2693 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
;
2694 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2697 alu
.src
[0].sel
= ctx
->temp_reg
;
2698 alu
.src
[0].chan
= 0;
2700 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2705 static int tgsi_r600_arl(struct r600_shader_ctx
*ctx
)
2707 /* TODO from r600c, ar values don't persist between clauses */
2708 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2709 struct r600_bc_alu alu
;
2711 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2713 switch (inst
->Instruction
.Opcode
) {
2714 case TGSI_OPCODE_ARL
:
2715 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR
;
2717 case TGSI_OPCODE_ARR
:
2718 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA
;
2726 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2729 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2733 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
));
2736 ctx
->bc
->cf_last
->r6xx_uses_waterfall
= 1;
2740 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
2742 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2743 struct r600_bc_alu alu
;
2746 for (i
= 0; i
< 4; i
++) {
2747 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2749 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2750 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2754 if (i
== 0 || i
== 3) {
2755 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2757 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2760 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], i
);
2763 if (i
== 0 || i
== 2) {
2764 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2766 r
= tgsi_src(ctx
, &inst
->Src
[1], &alu
.src
[1]);
2769 alu
.src
[1].chan
= tgsi_chan(&inst
->Src
[1], i
);
2773 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2780 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
2782 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2783 struct r600_bc_alu alu
;
2786 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2790 alu
.dst
.sel
= ctx
->temp_reg
;
2794 r
= tgsi_src(ctx
, &inst
->Src
[0], &alu
.src
[0]);
2797 alu
.src
[0].chan
= tgsi_chan(&inst
->Src
[0], 0);
2798 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2799 alu
.src
[1].chan
= 0;
2803 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
2809 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
2811 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
2812 ctx
->bc
->cf_last
->pop_count
= pops
;
2813 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2817 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
2821 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2825 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
2828 /* TOODO : for 16 vp asic should -= 2; */
2829 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2834 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
2836 if (check_max_only
) {
2849 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
2850 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2851 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2852 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
2858 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2862 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
2865 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2869 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
2870 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2871 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2872 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
2876 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
2878 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
2880 sp
->mid
= (struct r600_bc_cf
**)realloc((void *)sp
->mid
,
2881 sizeof(struct r600_bc_cf
*) * (sp
->num_mid
+ 1));
2882 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
2886 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
2889 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
2890 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
2893 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
2895 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
2907 static int emit_return(struct r600_shader_ctx
*ctx
)
2909 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
2913 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
2916 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_JUMP
);
2917 ctx
->bc
->cf_last
->pop_count
= pops
;
2918 /* TODO work out offset */
2922 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
2927 static void emit_testflag(struct r600_shader_ctx
*ctx
)
2932 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
2935 emit_jump_to_offset(ctx
, 1, 4);
2936 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
2937 pops(ctx
, ifidx
+ 1);
2941 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
2945 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
2946 ctx
->bc
->cf_last
->pop_count
= 1;
2948 fc_set_mid(ctx
, fc_sp
);
2954 static int tgsi_if(struct r600_shader_ctx
*ctx
)
2956 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
2958 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
2960 fc_pushlevel(ctx
, FC_IF
);
2962 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
2966 static int tgsi_else(struct r600_shader_ctx
*ctx
)
2968 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
2969 ctx
->bc
->cf_last
->pop_count
= 1;
2971 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
2972 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
2976 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
2979 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
2980 R600_ERR("if/endif unbalanced in shader\n");
2984 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
2985 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2986 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
2988 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2992 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
2996 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
2998 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
3000 fc_pushlevel(ctx
, FC_LOOP
);
3002 /* check stack depth */
3003 callstack_check_depth(ctx
, FC_LOOP
, 0);
3007 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
3011 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
3013 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
3014 R600_ERR("loop/endloop in shader code are not paired.\n");
3018 /* fixup loop pointers - from r600isa
3019 LOOP END points to CF after LOOP START,
3020 LOOP START point to CF after LOOP END
3021 BRK/CONT point to LOOP END CF
3023 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
3025 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
3027 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
3028 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
3030 /* TODO add LOOPRET support */
3032 callstack_decrease_current(ctx
, FC_LOOP
);
3036 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
3040 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
3042 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
3047 R600_ERR("Break not inside loop/endloop pair\n");
3051 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
3052 ctx
->bc
->cf_last
->pop_count
= 1;
3054 fc_set_mid(ctx
, fscp
);
3057 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
3061 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
3062 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
3063 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3064 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
3067 * For state trackers other than OpenGL, we'll want to use
3068 * _RECIP_IEEE instead.
3070 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
3072 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
3073 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
3074 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
3075 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
3076 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3077 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3078 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3079 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
3080 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
3081 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
3082 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
3083 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
3084 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
3085 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3086 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
3087 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3089 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3090 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3092 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3093 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3094 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
3095 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3096 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
3097 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3098 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
3099 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
3100 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
3101 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
3103 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3104 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3105 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3106 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3107 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
3108 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
3109 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
3110 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
3111 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3112 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3113 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3114 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3115 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3116 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
3117 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3118 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
3119 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
3120 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
3121 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
3122 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3123 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3124 {TGSI_OPCODE_TXD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3125 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3126 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3127 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3128 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3129 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3130 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3131 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3132 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
3133 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3134 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3135 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3136 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
3137 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
3138 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
3139 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3140 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3141 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3142 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3143 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3144 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
3145 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
3147 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3148 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3149 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
3150 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
3152 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3153 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3154 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3155 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3156 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3157 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3158 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3159 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
3160 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3162 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3163 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3164 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3165 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3166 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3167 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3168 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3169 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3170 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
3171 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3172 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3173 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
3174 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3175 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
3176 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3178 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3179 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3180 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3181 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3182 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3184 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3185 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3186 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3187 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3188 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3189 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3190 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3191 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3192 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
3193 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
3195 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3196 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3197 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3198 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3199 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3200 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3201 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3202 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3203 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3204 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3205 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3206 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3207 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3208 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3209 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3210 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3211 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3212 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3213 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3214 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3215 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3216 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3217 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3218 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3219 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3220 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3221 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3222 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3225 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
3226 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
3227 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3228 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
3229 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
3230 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_trans_srcx_replicate
},
3231 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
3232 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3233 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
3234 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3235 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3236 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3237 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
3238 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
3239 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
3240 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
3241 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
3242 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
3243 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3244 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
3245 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3247 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3248 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3250 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3251 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3252 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
3253 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3254 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
3255 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3256 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
3257 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
3258 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
3259 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
3261 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3262 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3263 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3264 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3265 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
3266 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
3267 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
3268 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
3269 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3270 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3271 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3272 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3273 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3274 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
3275 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3276 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
3277 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
3278 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
3279 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
3280 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3281 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3282 {TGSI_OPCODE_TXD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3283 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3284 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3285 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3286 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3287 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3288 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3289 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3290 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
3291 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3292 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3293 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3294 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
3295 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
3296 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
3297 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3298 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3299 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3300 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3301 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3302 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
3303 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
3305 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3306 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3307 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
3308 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
3310 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3311 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3312 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3313 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3314 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3315 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3316 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3317 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_trans_srcx_replicate
},
3318 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3320 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3321 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3322 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3323 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3324 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3325 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3326 {TGSI_OPCODE_TXF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3327 {TGSI_OPCODE_TXQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3328 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
3329 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3330 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3331 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
3332 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3333 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
3334 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3336 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3337 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3338 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3339 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3340 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3342 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3343 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3344 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3345 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3346 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3347 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3348 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3349 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3350 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
3351 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
3353 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3354 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3355 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3356 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3357 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3358 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3359 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3360 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3361 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3362 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3363 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3364 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3365 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3366 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3367 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3368 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3369 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3370 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3371 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3372 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3373 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3374 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3375 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3376 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3377 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3378 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3379 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3380 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},