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_info.h"
25 #include "tgsi/tgsi_parse.h"
26 #include "tgsi/tgsi_scan.h"
27 #include "tgsi/tgsi_dump.h"
28 #include "util/u_format.h"
29 #include "r600_pipe.h"
32 #include "r600_formats.h"
33 #include "r600_opcodes.h"
40 Why CAYMAN got loops for lots of instructions is explained here.
42 -These 8xx t-slot only ops are implemented in all vector slots.
43 MUL_LIT, FLT_TO_UINT, INT_TO_FLT, UINT_TO_FLT
44 These 8xx t-slot only opcodes become vector ops, with all four
45 slots expecting the arguments on sources a and b. Result is
46 broadcast to all channels.
47 MULLO_INT, MULHI_INT, MULLO_UINT, MULHI_UINT
48 These 8xx t-slot only opcodes become vector ops in the z, y, and
50 EXP_IEEE, LOG_IEEE/CLAMPED, RECIP_IEEE/CLAMPED/FF/INT/UINT/_64/CLAMPED_64
51 RECIPSQRT_IEEE/CLAMPED/FF/_64/CLAMPED_64
54 The w slot may have an independent co-issued operation, or if the
55 result is required to be in the w slot, the opcode above may be
56 issued in the w slot as well.
57 The compiler must issue the source argument to slots z, y, and x
60 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
62 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
63 struct r600_shader
*rshader
= &shader
->shader
;
68 if (shader
->bo
== NULL
) {
69 shader
->bo
= (struct r600_resource
*)
70 pipe_buffer_create(ctx
->screen
, PIPE_BIND_CUSTOM
, PIPE_USAGE_IMMUTABLE
, rshader
->bc
.ndw
* 4);
71 if (shader
->bo
== NULL
) {
74 ptr
= (uint32_t*)rctx
->ws
->buffer_map(shader
->bo
->buf
, rctx
->ctx
.cs
, PIPE_TRANSFER_WRITE
);
75 if (R600_BIG_ENDIAN
) {
76 for (i
= 0; i
< rshader
->bc
.ndw
; ++i
) {
77 ptr
[i
] = bswap_32(rshader
->bc
.bytecode
[i
]);
80 memcpy(ptr
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* sizeof(*ptr
));
82 rctx
->ws
->buffer_unmap(shader
->bo
->buf
);
85 switch (rshader
->processor_type
) {
86 case TGSI_PROCESSOR_VERTEX
:
87 if (rctx
->chip_class
>= EVERGREEN
) {
88 evergreen_pipe_shader_vs(ctx
, shader
);
90 r600_pipe_shader_vs(ctx
, shader
);
93 case TGSI_PROCESSOR_FRAGMENT
:
94 if (rctx
->chip_class
>= EVERGREEN
) {
95 evergreen_pipe_shader_ps(ctx
, shader
);
97 r600_pipe_shader_ps(ctx
, shader
);
106 static int r600_shader_from_tgsi(struct r600_pipe_context
* rctx
, struct r600_pipe_shader
*pipeshader
);
108 int r600_pipe_shader_create(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
110 static int dump_shaders
= -1;
111 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
114 /* Would like some magic "get_bool_option_once" routine.
116 if (dump_shaders
== -1)
117 dump_shaders
= debug_get_bool_option("R600_DUMP_SHADERS", FALSE
);
120 fprintf(stderr
, "--------------------------------------------------------------\n");
121 tgsi_dump(shader
->tokens
, 0);
123 if (shader
->so
.num_outputs
) {
125 fprintf(stderr
, "STREAMOUT\n");
126 for (i
= 0; i
< shader
->so
.num_outputs
; i
++) {
127 unsigned mask
= ((1 << shader
->so
.output
[i
].num_components
) - 1) <<
128 shader
->so
.output
[i
].start_component
;
129 fprintf(stderr
, " %i: MEM_STREAM0_BUF%i OUT[%i].%s%s%s%s\n", i
,
130 shader
->so
.output
[i
].output_buffer
, shader
->so
.output
[i
].register_index
,
131 mask
& 1 ? "x" : "_",
132 (mask
>> 1) & 1 ? "y" : "_",
133 (mask
>> 2) & 1 ? "z" : "_",
134 (mask
>> 3) & 1 ? "w" : "_");
138 r
= r600_shader_from_tgsi(rctx
, shader
);
140 R600_ERR("translation from TGSI failed !\n");
143 r
= r600_bytecode_build(&shader
->shader
.bc
);
145 R600_ERR("building bytecode failed !\n");
149 r600_bytecode_dump(&shader
->shader
.bc
);
150 fprintf(stderr
, "______________________________________________________________\n");
152 return r600_pipe_shader(ctx
, shader
);
155 void r600_pipe_shader_destroy(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
157 pipe_resource_reference((struct pipe_resource
**)&shader
->bo
, NULL
);
158 r600_bytecode_clear(&shader
->shader
.bc
);
160 memset(&shader
->shader
,0,sizeof(struct r600_shader
));
164 * tgsi -> r600 shader
166 struct r600_shader_tgsi_instruction
;
168 struct r600_shader_src
{
177 struct r600_shader_ctx
{
178 struct tgsi_shader_info info
;
179 struct tgsi_parse_context parse
;
180 const struct tgsi_token
*tokens
;
182 unsigned file_offset
[TGSI_FILE_COUNT
];
184 struct r600_shader_tgsi_instruction
*inst_info
;
185 struct r600_bytecode
*bc
;
186 struct r600_shader
*shader
;
187 struct r600_shader_src src
[4];
190 u32 max_driver_temp_used
;
191 /* needed for evergreen interpolation */
192 boolean input_centroid
;
193 boolean input_linear
;
194 boolean input_perspective
;
200 struct r600_shader_tgsi_instruction
{
201 unsigned tgsi_opcode
;
203 unsigned r600_opcode
;
204 int (*process
)(struct r600_shader_ctx
*ctx
);
207 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[], eg_shader_tgsi_instruction
[], cm_shader_tgsi_instruction
[];
208 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
210 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
212 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
215 if (i
->Instruction
.NumDstRegs
> 1) {
216 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
219 if (i
->Instruction
.Predicate
) {
220 R600_ERR("predicate unsupported\n");
224 if (i
->Instruction
.Label
) {
225 R600_ERR("label unsupported\n");
229 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
230 if (i
->Src
[j
].Register
.Dimension
) {
231 R600_ERR("unsupported src %d (dimension %d)\n", j
,
232 i
->Src
[j
].Register
.Dimension
);
236 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
237 if (i
->Dst
[j
].Register
.Dimension
) {
238 R600_ERR("unsupported dst (dimension)\n");
245 static int evergreen_interp_alu(struct r600_shader_ctx
*ctx
, int input
)
248 struct r600_bytecode_alu alu
;
249 int gpr
= 0, base_chan
= 0;
252 if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_PERSPECTIVE
) {
254 if (ctx
->shader
->input
[input
].centroid
)
256 } else if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_LINEAR
) {
258 /* if we have perspective add one */
259 if (ctx
->input_perspective
) {
261 /* if we have perspective centroid */
262 if (ctx
->input_centroid
)
265 if (ctx
->shader
->input
[input
].centroid
)
269 /* work out gpr and base_chan from index */
271 base_chan
= (2 * (ij_index
% 2)) + 1;
273 for (i
= 0; i
< 8; i
++) {
274 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
277 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW
;
279 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_XY
;
281 if ((i
> 1) && (i
< 6)) {
282 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
286 alu
.dst
.chan
= i
% 4;
288 alu
.src
[0].sel
= gpr
;
289 alu
.src
[0].chan
= (base_chan
- (i
% 2));
291 alu
.src
[1].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
293 alu
.bank_swizzle_force
= SQ_ALU_VEC_210
;
296 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
303 static int evergreen_interp_flat(struct r600_shader_ctx
*ctx
, int input
)
306 struct r600_bytecode_alu alu
;
308 for (i
= 0; i
< 4; i
++) {
309 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
311 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_LOAD_P0
;
313 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
318 alu
.src
[0].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
323 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
331 * Special export handling in shaders
333 * shader export ARRAY_BASE for EXPORT_POS:
336 * 62, 63 are clip distance vectors
338 * The use of the values exported in 61-63 are controlled by PA_CL_VS_OUT_CNTL:
339 * VS_OUT_MISC_VEC_ENA - enables the use of all fields in export 61
340 * USE_VTX_POINT_SIZE - point size in the X channel of export 61
341 * USE_VTX_EDGE_FLAG - edge flag in the Y channel of export 61
342 * USE_VTX_RENDER_TARGET_INDX - render target index in the Z channel of export 61
343 * USE_VTX_VIEWPORT_INDX - viewport index in the W channel of export 61
344 * USE_VTX_KILL_FLAG - kill flag in the Z channel of export 61 (mutually
345 * exclusive from render target index)
346 * VS_OUT_CCDIST0_VEC_ENA/VS_OUT_CCDIST1_VEC_ENA - enable clip distance vectors
349 * shader export ARRAY_BASE for EXPORT_PIXEL:
351 * 61 computed Z vector
353 * The use of the values exported in the computed Z vector are controlled
354 * by DB_SHADER_CONTROL:
355 * Z_EXPORT_ENABLE - Z as a float in RED
356 * STENCIL_REF_EXPORT_ENABLE - stencil ref as int in GREEN
357 * COVERAGE_TO_MASK_ENABLE - alpha to mask in ALPHA
358 * MASK_EXPORT_ENABLE - pixel sample mask in BLUE
359 * DB_SOURCE_FORMAT - export control restrictions
364 /* Map name/sid pair from tgsi to the 8-bit semantic index for SPI setup */
365 static int r600_spi_sid(struct r600_shader_io
* io
)
367 int index
, name
= io
->name
;
369 /* These params are handled differently, they don't need
370 * semantic indices, so we'll use 0 for them.
372 if (name
== TGSI_SEMANTIC_POSITION
||
373 name
== TGSI_SEMANTIC_PSIZE
||
374 name
== TGSI_SEMANTIC_FACE
)
377 if (name
== TGSI_SEMANTIC_GENERIC
) {
378 /* For generic params simply use sid from tgsi */
381 /* For non-generic params - pack name and sid into 8 bits */
382 index
= 0x80 | (name
<<3) | (io
->sid
);
385 /* Make sure that all really used indices have nonzero value, so
386 * we can just compare it to 0 later instead of comparing the name
387 * with different values to detect special cases. */
394 /* turn input into interpolate on EG */
395 static int evergreen_interp_input(struct r600_shader_ctx
*ctx
, int index
)
399 if (ctx
->shader
->input
[index
].spi_sid
) {
400 ctx
->shader
->input
[index
].lds_pos
= ctx
->shader
->nlds
++;
401 if (ctx
->shader
->input
[index
].interpolate
> 0) {
402 r
= evergreen_interp_alu(ctx
, index
);
404 r
= evergreen_interp_flat(ctx
, index
);
410 static int select_twoside_color(struct r600_shader_ctx
*ctx
, int front
, int back
)
412 struct r600_bytecode_alu alu
;
414 int gpr_front
= ctx
->shader
->input
[front
].gpr
;
415 int gpr_back
= ctx
->shader
->input
[back
].gpr
;
417 for (i
= 0; i
< 4; i
++) {
418 memset(&alu
, 0, sizeof(alu
));
419 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
422 alu
.dst
.sel
= gpr_front
;
423 alu
.src
[0].sel
= ctx
->face_gpr
;
424 alu
.src
[1].sel
= gpr_front
;
425 alu
.src
[2].sel
= gpr_back
;
432 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
439 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
441 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
445 switch (d
->Declaration
.File
) {
446 case TGSI_FILE_INPUT
:
447 i
= ctx
->shader
->ninput
++;
448 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
449 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
450 ctx
->shader
->input
[i
].spi_sid
= r600_spi_sid(&ctx
->shader
->input
[i
]);
451 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
452 ctx
->shader
->input
[i
].centroid
= d
->Declaration
.Centroid
;
453 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + d
->Range
.First
;
454 if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
) {
455 if (ctx
->shader
->input
[i
].name
== TGSI_SEMANTIC_FACE
)
456 ctx
->face_gpr
= ctx
->shader
->input
[i
].gpr
;
457 else if (ctx
->shader
->input
[i
].name
== TGSI_SEMANTIC_COLOR
)
459 if (ctx
->bc
->chip_class
>= EVERGREEN
) {
460 r
= evergreen_interp_input(ctx
, i
);
466 case TGSI_FILE_OUTPUT
:
467 i
= ctx
->shader
->noutput
++;
468 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
469 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
470 ctx
->shader
->output
[i
].spi_sid
= r600_spi_sid(&ctx
->shader
->output
[i
]);
471 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + d
->Range
.First
;
472 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
473 ctx
->shader
->output
[i
].write_mask
= d
->Declaration
.UsageMask
;
474 if (ctx
->type
== TGSI_PROCESSOR_VERTEX
) {
475 switch (d
->Semantic
.Name
) {
476 case TGSI_SEMANTIC_CLIPDIST
:
477 ctx
->shader
->clip_dist_write
|= d
->Declaration
.UsageMask
<< (d
->Semantic
.Index
<< 2);
479 case TGSI_SEMANTIC_PSIZE
:
480 ctx
->shader
->vs_out_misc_write
= 1;
485 case TGSI_FILE_CONSTANT
:
486 case TGSI_FILE_TEMPORARY
:
487 case TGSI_FILE_SAMPLER
:
488 case TGSI_FILE_ADDRESS
:
491 case TGSI_FILE_SYSTEM_VALUE
:
492 if (d
->Semantic
.Name
== TGSI_SEMANTIC_INSTANCEID
) {
493 struct r600_bytecode_alu alu
;
494 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
496 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
);
505 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
508 } else if (d
->Semantic
.Name
== TGSI_SEMANTIC_VERTEXID
)
511 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
517 static int r600_get_temp(struct r600_shader_ctx
*ctx
)
519 return ctx
->temp_reg
+ ctx
->max_driver_temp_used
++;
523 * for evergreen we need to scan the shader to find the number of GPRs we need to
524 * reserve for interpolation.
526 * we need to know if we are going to emit
527 * any centroid inputs
528 * if perspective and linear are required
530 static int evergreen_gpr_count(struct r600_shader_ctx
*ctx
)
535 ctx
->input_linear
= FALSE
;
536 ctx
->input_perspective
= FALSE
;
537 ctx
->input_centroid
= FALSE
;
538 ctx
->num_interp_gpr
= 1;
540 /* any centroid inputs */
541 for (i
= 0; i
< ctx
->info
.num_inputs
; i
++) {
542 /* skip position/face */
543 if (ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_POSITION
||
544 ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_FACE
)
546 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_LINEAR
)
547 ctx
->input_linear
= TRUE
;
548 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_PERSPECTIVE
)
549 ctx
->input_perspective
= TRUE
;
550 if (ctx
->info
.input_centroid
[i
])
551 ctx
->input_centroid
= TRUE
;
555 /* ignoring sample for now */
556 if (ctx
->input_perspective
)
558 if (ctx
->input_linear
)
560 if (ctx
->input_centroid
)
563 ctx
->num_interp_gpr
+= (num_baryc
+ 1) >> 1;
565 /* TODO PULL MODEL and LINE STIPPLE, FIXED PT POS */
566 return ctx
->num_interp_gpr
;
569 static void tgsi_src(struct r600_shader_ctx
*ctx
,
570 const struct tgsi_full_src_register
*tgsi_src
,
571 struct r600_shader_src
*r600_src
)
573 memset(r600_src
, 0, sizeof(*r600_src
));
574 r600_src
->swizzle
[0] = tgsi_src
->Register
.SwizzleX
;
575 r600_src
->swizzle
[1] = tgsi_src
->Register
.SwizzleY
;
576 r600_src
->swizzle
[2] = tgsi_src
->Register
.SwizzleZ
;
577 r600_src
->swizzle
[3] = tgsi_src
->Register
.SwizzleW
;
578 r600_src
->neg
= tgsi_src
->Register
.Negate
;
579 r600_src
->abs
= tgsi_src
->Register
.Absolute
;
581 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
583 if ((tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleY
) &&
584 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleZ
) &&
585 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleW
)) {
587 index
= tgsi_src
->Register
.Index
* 4 + tgsi_src
->Register
.SwizzleX
;
588 r600_bytecode_special_constants(ctx
->literals
[index
], &r600_src
->sel
, &r600_src
->neg
);
589 if (r600_src
->sel
!= V_SQ_ALU_SRC_LITERAL
)
592 index
= tgsi_src
->Register
.Index
;
593 r600_src
->sel
= V_SQ_ALU_SRC_LITERAL
;
594 memcpy(r600_src
->value
, ctx
->literals
+ index
* 4, sizeof(r600_src
->value
));
595 } else if (tgsi_src
->Register
.File
== TGSI_FILE_SYSTEM_VALUE
) {
596 if (ctx
->info
.system_value_semantic_name
[tgsi_src
->Register
.Index
] == TGSI_SEMANTIC_INSTANCEID
) {
597 r600_src
->swizzle
[0] = 3;
598 r600_src
->swizzle
[1] = 3;
599 r600_src
->swizzle
[2] = 3;
600 r600_src
->swizzle
[3] = 3;
602 } else if (ctx
->info
.system_value_semantic_name
[tgsi_src
->Register
.Index
] == TGSI_SEMANTIC_VERTEXID
) {
603 r600_src
->swizzle
[0] = 0;
604 r600_src
->swizzle
[1] = 0;
605 r600_src
->swizzle
[2] = 0;
606 r600_src
->swizzle
[3] = 0;
610 if (tgsi_src
->Register
.Indirect
)
611 r600_src
->rel
= V_SQ_REL_RELATIVE
;
612 r600_src
->sel
= tgsi_src
->Register
.Index
;
613 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
617 static int tgsi_fetch_rel_const(struct r600_shader_ctx
*ctx
, unsigned int offset
, unsigned int dst_reg
)
619 struct r600_bytecode_vtx vtx
;
624 struct r600_bytecode_alu alu
;
626 memset(&alu
, 0, sizeof(alu
));
628 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
629 alu
.src
[0].sel
= ctx
->bc
->ar_reg
;
631 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
632 alu
.src
[1].value
= offset
;
634 alu
.dst
.sel
= dst_reg
;
638 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
643 ar_reg
= ctx
->bc
->ar_reg
;
646 memset(&vtx
, 0, sizeof(vtx
));
647 vtx
.fetch_type
= 2; /* VTX_FETCH_NO_INDEX_OFFSET */
648 vtx
.src_gpr
= ar_reg
;
649 vtx
.mega_fetch_count
= 16;
650 vtx
.dst_gpr
= dst_reg
;
651 vtx
.dst_sel_x
= 0; /* SEL_X */
652 vtx
.dst_sel_y
= 1; /* SEL_Y */
653 vtx
.dst_sel_z
= 2; /* SEL_Z */
654 vtx
.dst_sel_w
= 3; /* SEL_W */
655 vtx
.data_format
= FMT_32_32_32_32_FLOAT
;
656 vtx
.num_format_all
= 2; /* NUM_FORMAT_SCALED */
657 vtx
.format_comp_all
= 1; /* FORMAT_COMP_SIGNED */
658 vtx
.srf_mode_all
= 1; /* SRF_MODE_NO_ZERO */
659 vtx
.endian
= r600_endian_swap(32);
661 if ((r
= r600_bytecode_add_vtx(ctx
->bc
, &vtx
)))
667 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
)
669 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
670 struct r600_bytecode_alu alu
;
671 int i
, j
, k
, nconst
, r
;
673 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
674 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
677 tgsi_src(ctx
, &inst
->Src
[i
], &ctx
->src
[i
]);
679 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
680 if (inst
->Src
[i
].Register
.File
!= TGSI_FILE_CONSTANT
) {
684 if (ctx
->src
[i
].rel
) {
685 int treg
= r600_get_temp(ctx
);
686 if ((r
= tgsi_fetch_rel_const(ctx
, ctx
->src
[i
].sel
- 512, treg
)))
689 ctx
->src
[i
].sel
= treg
;
693 int treg
= r600_get_temp(ctx
);
694 for (k
= 0; k
< 4; k
++) {
695 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
696 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
697 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
699 alu
.src
[0].rel
= ctx
->src
[i
].rel
;
705 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
709 ctx
->src
[i
].sel
= treg
;
717 /* need to move any immediate into a temp - for trig functions which use literal for PI stuff */
718 static int tgsi_split_literal_constant(struct r600_shader_ctx
*ctx
)
720 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
721 struct r600_bytecode_alu alu
;
722 int i
, j
, k
, nliteral
, r
;
724 for (i
= 0, nliteral
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
725 if (ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
729 for (i
= 0, j
= nliteral
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
730 if (j
> 0 && ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
731 int treg
= r600_get_temp(ctx
);
732 for (k
= 0; k
< 4; k
++) {
733 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
734 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
735 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
737 alu
.src
[0].value
= ctx
->src
[i
].value
[k
];
743 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
747 ctx
->src
[i
].sel
= treg
;
754 static int process_twoside_color_inputs(struct r600_shader_ctx
*ctx
)
756 int i
, r
, count
= ctx
->shader
->ninput
;
758 /* additional inputs will be allocated right after the existing inputs,
759 * we won't need them after the color selection, so we don't need to
760 * reserve these gprs for the rest of the shader code and to adjust
761 * output offsets etc. */
762 int gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] +
763 ctx
->info
.file_max
[TGSI_FILE_INPUT
] + 1;
765 if (ctx
->face_gpr
== -1) {
766 i
= ctx
->shader
->ninput
++;
767 ctx
->shader
->input
[i
].name
= TGSI_SEMANTIC_FACE
;
768 ctx
->shader
->input
[i
].spi_sid
= 0;
769 ctx
->shader
->input
[i
].gpr
= gpr
++;
770 ctx
->face_gpr
= ctx
->shader
->input
[i
].gpr
;
773 for (i
= 0; i
< count
; i
++) {
774 if (ctx
->shader
->input
[i
].name
== TGSI_SEMANTIC_COLOR
) {
775 int ni
= ctx
->shader
->ninput
++;
776 memcpy(&ctx
->shader
->input
[ni
],&ctx
->shader
->input
[i
], sizeof(struct r600_shader_io
));
777 ctx
->shader
->input
[ni
].name
= TGSI_SEMANTIC_BCOLOR
;
778 ctx
->shader
->input
[ni
].spi_sid
= r600_spi_sid(&ctx
->shader
->input
[ni
]);
779 ctx
->shader
->input
[ni
].gpr
= gpr
++;
781 if (ctx
->bc
->chip_class
>= EVERGREEN
) {
782 r
= evergreen_interp_input(ctx
, ni
);
787 r
= select_twoside_color(ctx
, i
, ni
);
795 static int r600_shader_from_tgsi(struct r600_pipe_context
* rctx
, struct r600_pipe_shader
*pipeshader
)
797 struct r600_shader
*shader
= &pipeshader
->shader
;
798 struct tgsi_token
*tokens
= pipeshader
->tokens
;
799 struct pipe_stream_output_info so
= pipeshader
->so
;
800 struct tgsi_full_immediate
*immediate
;
801 struct tgsi_full_property
*property
;
802 struct r600_shader_ctx ctx
;
803 struct r600_bytecode_output output
[32];
804 unsigned output_done
, noutput
;
806 int i
, j
, r
= 0, pos0
;
808 ctx
.bc
= &shader
->bc
;
810 r600_bytecode_init(ctx
.bc
, rctx
->chip_class
);
812 tgsi_scan_shader(tokens
, &ctx
.info
);
813 tgsi_parse_init(&ctx
.parse
, tokens
);
814 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
815 shader
->processor_type
= ctx
.type
;
816 ctx
.bc
->type
= shader
->processor_type
;
821 shader
->two_side
= (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
) && rctx
->two_side
;
823 shader
->clamp_color
= (((ctx
.type
== TGSI_PROCESSOR_FRAGMENT
) && rctx
->clamp_fragment_color
) ||
824 ((ctx
.type
== TGSI_PROCESSOR_VERTEX
) && rctx
->clamp_vertex_color
));
826 shader
->nr_cbufs
= rctx
->nr_cbufs
;
828 /* register allocations */
829 /* Values [0,127] correspond to GPR[0..127].
830 * Values [128,159] correspond to constant buffer bank 0
831 * Values [160,191] correspond to constant buffer bank 1
832 * Values [256,511] correspond to cfile constants c[0..255]. (Gone on EG)
833 * Values [256,287] correspond to constant buffer bank 2 (EG)
834 * Values [288,319] correspond to constant buffer bank 3 (EG)
835 * Other special values are shown in the list below.
836 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
837 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
838 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
839 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
840 * 248 SQ_ALU_SRC_0: special constant 0.0.
841 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
842 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
843 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
844 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
845 * 253 SQ_ALU_SRC_LITERAL: literal constant.
846 * 254 SQ_ALU_SRC_PV: previous vector result.
847 * 255 SQ_ALU_SRC_PS: previous scalar result.
849 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
850 ctx
.file_offset
[i
] = 0;
852 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
853 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
854 if (ctx
.bc
->chip_class
>= EVERGREEN
) {
855 r600_bytecode_add_cfinst(ctx
.bc
, EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
857 r600_bytecode_add_cfinst(ctx
.bc
, V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
860 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
.bc
->chip_class
>= EVERGREEN
) {
861 ctx
.file_offset
[TGSI_FILE_INPUT
] = evergreen_gpr_count(&ctx
);
863 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
864 ctx
.info
.file_max
[TGSI_FILE_INPUT
] + 1;
865 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
866 ctx
.info
.file_max
[TGSI_FILE_OUTPUT
] + 1;
868 /* Outside the GPR range. This will be translated to one of the
869 * kcache banks later. */
870 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 512;
872 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = V_SQ_ALU_SRC_LITERAL
;
873 ctx
.bc
->ar_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
874 ctx
.info
.file_max
[TGSI_FILE_TEMPORARY
] + 1;
875 ctx
.temp_reg
= ctx
.bc
->ar_reg
+ 1;
879 shader
->fs_write_all
= FALSE
;
880 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
881 tgsi_parse_token(&ctx
.parse
);
882 switch (ctx
.parse
.FullToken
.Token
.Type
) {
883 case TGSI_TOKEN_TYPE_IMMEDIATE
:
884 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
885 ctx
.literals
= realloc(ctx
.literals
, (ctx
.nliterals
+ 1) * 16);
886 if(ctx
.literals
== NULL
) {
890 ctx
.literals
[ctx
.nliterals
* 4 + 0] = immediate
->u
[0].Uint
;
891 ctx
.literals
[ctx
.nliterals
* 4 + 1] = immediate
->u
[1].Uint
;
892 ctx
.literals
[ctx
.nliterals
* 4 + 2] = immediate
->u
[2].Uint
;
893 ctx
.literals
[ctx
.nliterals
* 4 + 3] = immediate
->u
[3].Uint
;
896 case TGSI_TOKEN_TYPE_DECLARATION
:
897 r
= tgsi_declaration(&ctx
);
901 case TGSI_TOKEN_TYPE_INSTRUCTION
:
903 case TGSI_TOKEN_TYPE_PROPERTY
:
904 property
= &ctx
.parse
.FullToken
.FullProperty
;
905 switch (property
->Property
.PropertyName
) {
906 case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS
:
907 if (property
->u
[0].Data
== 1)
908 shader
->fs_write_all
= TRUE
;
910 case TGSI_PROPERTY_VS_PROHIBIT_UCPS
:
911 if (property
->u
[0].Data
== 1)
912 shader
->vs_prohibit_ucps
= TRUE
;
917 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
923 if (shader
->two_side
&& ctx
.colors_used
) {
924 if ((r
= process_twoside_color_inputs(&ctx
)))
928 tgsi_parse_init(&ctx
.parse
, tokens
);
929 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
930 tgsi_parse_token(&ctx
.parse
);
931 switch (ctx
.parse
.FullToken
.Token
.Type
) {
932 case TGSI_TOKEN_TYPE_INSTRUCTION
:
933 r
= tgsi_is_supported(&ctx
);
936 ctx
.max_driver_temp_used
= 0;
937 /* reserve first tmp for everyone */
940 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
941 if ((r
= tgsi_split_constant(&ctx
)))
943 if ((r
= tgsi_split_literal_constant(&ctx
)))
945 if (ctx
.bc
->chip_class
== CAYMAN
)
946 ctx
.inst_info
= &cm_shader_tgsi_instruction
[opcode
];
947 else if (ctx
.bc
->chip_class
>= EVERGREEN
)
948 ctx
.inst_info
= &eg_shader_tgsi_instruction
[opcode
];
950 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
951 r
= ctx
.inst_info
->process(&ctx
);
960 noutput
= shader
->noutput
;
962 /* clamp color outputs */
963 if (shader
->clamp_color
) {
964 for (i
= 0; i
< noutput
; i
++) {
965 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
||
966 shader
->output
[i
].name
== TGSI_SEMANTIC_BCOLOR
) {
969 for (j
= 0; j
< 4; j
++) {
970 struct r600_bytecode_alu alu
;
971 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
974 alu
.inst
= BC_INST(ctx
.bc
, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
975 alu
.dst
.sel
= shader
->output
[i
].gpr
;
979 alu
.src
[0].sel
= alu
.dst
.sel
;
985 r
= r600_bytecode_add_alu(ctx
.bc
, &alu
);
993 /* Add stream outputs. */
994 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
&& so
.num_outputs
) {
995 for (i
= 0; i
< so
.num_outputs
; i
++) {
996 struct r600_bytecode_output output
;
998 if (so
.output
[i
].output_buffer
>= 4) {
999 R600_ERR("exceeded the max number of stream output buffers, got: %d\n",
1000 so
.output
[i
].output_buffer
);
1004 if (so
.output
[i
].start_component
) {
1005 R600_ERR("stream_output - start_component cannot be non-zero\n");
1010 memset(&output
, 0, sizeof(struct r600_bytecode_output
));
1011 output
.gpr
= shader
->output
[so
.output
[i
].register_index
].gpr
;
1012 output
.elem_size
= 0;
1013 output
.array_base
= so
.output
[i
].dst_offset
;
1014 output
.type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_WRITE
;
1015 output
.burst_count
= 1;
1017 output
.array_size
= 0;
1018 output
.comp_mask
= (1 << so
.output
[i
].num_components
) - 1;
1019 if (ctx
.bc
->chip_class
>= EVERGREEN
) {
1020 switch (so
.output
[i
].output_buffer
) {
1022 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF0
;
1025 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF1
;
1028 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF2
;
1031 output
.inst
= EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF3
;
1035 switch (so
.output
[i
].output_buffer
) {
1037 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0
;
1040 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1
;
1043 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2
;
1046 output
.inst
= V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3
;
1050 r
= r600_bytecode_add_output(ctx
.bc
, &output
);
1059 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
1060 memset(&output
[i
+j
], 0, sizeof(struct r600_bytecode_output
));
1061 output
[i
+ j
].gpr
= shader
->output
[i
].gpr
;
1062 output
[i
+ j
].elem_size
= 3;
1063 output
[i
+ j
].swizzle_x
= 0;
1064 output
[i
+ j
].swizzle_y
= 1;
1065 output
[i
+ j
].swizzle_z
= 2;
1066 output
[i
+ j
].swizzle_w
= 3;
1067 output
[i
+ j
].burst_count
= 1;
1068 output
[i
+ j
].barrier
= 1;
1069 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
1070 output
[i
+ j
].array_base
= i
+j
- pos0
;
1071 output
[i
+ j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1073 case TGSI_PROCESSOR_VERTEX
:
1074 switch (shader
->output
[i
].name
) {
1075 case TGSI_SEMANTIC_POSITION
:
1076 output
[i
+ j
].array_base
= 60;
1077 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
1078 /* position doesn't count in array_base */
1082 case TGSI_SEMANTIC_PSIZE
:
1083 output
[i
+ j
].array_base
= 61;
1084 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
1085 /* position doesn't count in array_base */
1089 case TGSI_SEMANTIC_CLIPDIST
:
1090 /* array base for enabled OUT_MISC_VEC & CCDIST[0|1]_VEC
1091 * vectors is allocated sequentially, starting from 61 */
1092 output
[i
+ j
].array_base
= 61 + shader
->output
[i
].sid
1093 /* +1 if OUT_MISC_VEC is enabled */
1094 + shader
->vs_out_misc_write
1095 /* -1 if OUT_CCDIST0_VEC is disabled */
1096 - (((shader
->clip_dist_write
& 0xF) == 0)? 1 : 0);
1097 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
1100 /* duplicate it as PARAM to pass to the pixel shader */
1101 memcpy(&output
[i
+j
], &output
[i
+j
-1], sizeof(struct r600_bytecode_output
));
1102 output
[i
+ j
].array_base
= i
+j
-pos0
;
1103 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
1107 case TGSI_PROCESSOR_FRAGMENT
:
1108 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
1109 output
[i
+ j
].array_base
= shader
->output
[i
].sid
;
1110 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1111 if (shader
->fs_write_all
&& (rctx
->chip_class
>= EVERGREEN
)) {
1112 for (j
= 1; j
< shader
->nr_cbufs
; j
++) {
1113 memset(&output
[i
+ j
], 0, sizeof(struct r600_bytecode_output
));
1114 output
[i
+ j
].gpr
= shader
->output
[i
].gpr
;
1115 output
[i
+ j
].elem_size
= 3;
1116 output
[i
+ j
].swizzle_x
= 0;
1117 output
[i
+ j
].swizzle_y
= 1;
1118 output
[i
+ j
].swizzle_z
= 2;
1119 output
[i
+ j
].swizzle_w
= 3;
1120 output
[i
+ j
].burst_count
= 1;
1121 output
[i
+ j
].barrier
= 1;
1122 output
[i
+ j
].array_base
= shader
->output
[i
].sid
+ j
;
1123 output
[i
+ j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1124 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1126 j
= shader
->nr_cbufs
-1;
1128 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
1129 output
[i
+ j
].array_base
= 61;
1130 output
[i
+ j
].swizzle_x
= 2;
1131 output
[i
+ j
].swizzle_y
= 7;
1132 output
[i
+ j
].swizzle_z
= output
[i
+ j
].swizzle_w
= 7;
1133 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1134 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
) {
1135 output
[i
+ j
].array_base
= 61;
1136 output
[i
+ j
].swizzle_x
= 7;
1137 output
[i
+ j
].swizzle_y
= 1;
1138 output
[i
+ j
].swizzle_z
= output
[i
+ j
].swizzle_w
= 7;
1139 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1141 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
1147 R600_ERR("unsupported processor type %d\n", ctx
.type
);
1153 /* add fake param output for vertex shader if no param is exported */
1154 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
1155 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
1156 if (output
[i
].type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
) {
1162 memset(&output
[i
], 0, sizeof(struct r600_bytecode_output
));
1164 output
[i
].elem_size
= 3;
1165 output
[i
].swizzle_x
= 7;
1166 output
[i
].swizzle_y
= 7;
1167 output
[i
].swizzle_z
= 7;
1168 output
[i
].swizzle_w
= 7;
1169 output
[i
].burst_count
= 1;
1170 output
[i
].barrier
= 1;
1171 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
1172 output
[i
].array_base
= 0;
1173 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1177 /* add fake pixel export */
1178 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& !noutput
) {
1179 memset(&output
[0], 0, sizeof(struct r600_bytecode_output
));
1181 output
[0].elem_size
= 3;
1182 output
[0].swizzle_x
= 7;
1183 output
[0].swizzle_y
= 7;
1184 output
[0].swizzle_z
= 7;
1185 output
[0].swizzle_w
= 7;
1186 output
[0].burst_count
= 1;
1187 output
[0].barrier
= 1;
1188 output
[0].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
1189 output
[0].array_base
= 0;
1190 output
[0].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
1193 /* set export done on last export of each type */
1194 for (i
= noutput
- 1, output_done
= 0; i
>= 0; i
--) {
1195 if (ctx
.bc
->chip_class
< CAYMAN
) {
1196 if (i
== (noutput
- 1)) {
1197 output
[i
].end_of_program
= 1;
1200 if (!(output_done
& (1 << output
[i
].type
))) {
1201 output_done
|= (1 << output
[i
].type
);
1202 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
);
1205 /* add output to bytecode */
1206 for (i
= 0; i
< noutput
; i
++) {
1207 r
= r600_bytecode_add_output(ctx
.bc
, &output
[i
]);
1211 /* add program end */
1212 if (ctx
.bc
->chip_class
== CAYMAN
)
1213 cm_bytecode_add_cf_end(ctx
.bc
);
1216 tgsi_parse_free(&ctx
.parse
);
1220 tgsi_parse_free(&ctx
.parse
);
1224 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
1226 R600_ERR("%s tgsi opcode unsupported\n",
1227 tgsi_get_opcode_name(ctx
->inst_info
->tgsi_opcode
));
1231 static int tgsi_end(struct r600_shader_ctx
*ctx
)
1236 static void r600_bytecode_src(struct r600_bytecode_alu_src
*bc_src
,
1237 const struct r600_shader_src
*shader_src
,
1240 bc_src
->sel
= shader_src
->sel
;
1241 bc_src
->chan
= shader_src
->swizzle
[chan
];
1242 bc_src
->neg
= shader_src
->neg
;
1243 bc_src
->abs
= shader_src
->abs
;
1244 bc_src
->rel
= shader_src
->rel
;
1245 bc_src
->value
= shader_src
->value
[bc_src
->chan
];
1248 static void r600_bytecode_src_set_abs(struct r600_bytecode_alu_src
*bc_src
)
1254 static void r600_bytecode_src_toggle_neg(struct r600_bytecode_alu_src
*bc_src
)
1256 bc_src
->neg
= !bc_src
->neg
;
1259 static void tgsi_dst(struct r600_shader_ctx
*ctx
,
1260 const struct tgsi_full_dst_register
*tgsi_dst
,
1262 struct r600_bytecode_alu_dst
*r600_dst
)
1264 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1266 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
1267 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
1268 r600_dst
->chan
= swizzle
;
1269 r600_dst
->write
= 1;
1270 if (tgsi_dst
->Register
.Indirect
)
1271 r600_dst
->rel
= V_SQ_REL_RELATIVE
;
1272 if (inst
->Instruction
.Saturate
) {
1273 r600_dst
->clamp
= 1;
1277 static int tgsi_last_instruction(unsigned writemask
)
1281 for (i
= 0; i
< 4; i
++) {
1282 if (writemask
& (1 << i
)) {
1289 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
, int trans_only
)
1291 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1292 struct r600_bytecode_alu alu
;
1294 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1296 for (i
= 0; i
< lasti
+ 1; i
++) {
1297 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1300 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1301 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1303 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1305 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1306 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
1309 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
1310 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
1312 /* handle some special cases */
1313 switch (ctx
->inst_info
->tgsi_opcode
) {
1314 case TGSI_OPCODE_SUB
:
1315 r600_bytecode_src_toggle_neg(&alu
.src
[1]);
1317 case TGSI_OPCODE_ABS
:
1318 r600_bytecode_src_set_abs(&alu
.src
[0]);
1323 if (i
== lasti
|| trans_only
) {
1326 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1333 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
1335 return tgsi_op2_s(ctx
, 0, 0);
1338 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
1340 return tgsi_op2_s(ctx
, 1, 0);
1343 static int tgsi_op2_trans(struct r600_shader_ctx
*ctx
)
1345 return tgsi_op2_s(ctx
, 0, 1);
1348 static int tgsi_ineg(struct r600_shader_ctx
*ctx
)
1350 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1351 struct r600_bytecode_alu alu
;
1353 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1355 for (i
= 0; i
< lasti
+ 1; i
++) {
1357 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1359 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1360 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1362 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1364 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
1366 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1371 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1379 static int cayman_emit_float_instr(struct r600_shader_ctx
*ctx
)
1381 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1383 struct r600_bytecode_alu alu
;
1384 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
1386 for (i
= 0 ; i
< last_slot
; i
++) {
1387 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1388 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1389 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1390 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], 0);
1392 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1393 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1395 if (i
== last_slot
- 1)
1397 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1405 * r600 - trunc to -PI..PI range
1406 * r700 - normalize by dividing by 2PI
1409 static int tgsi_setup_trig(struct r600_shader_ctx
*ctx
)
1411 static float half_inv_pi
= 1.0 /(3.1415926535 * 2);
1412 static float double_pi
= 3.1415926535 * 2;
1413 static float neg_pi
= -3.1415926535;
1416 struct r600_bytecode_alu alu
;
1418 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1419 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1423 alu
.dst
.sel
= ctx
->temp_reg
;
1426 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
1428 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1429 alu
.src
[1].chan
= 0;
1430 alu
.src
[1].value
= *(uint32_t *)&half_inv_pi
;
1431 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
1432 alu
.src
[2].chan
= 0;
1434 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1438 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1439 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
1442 alu
.dst
.sel
= ctx
->temp_reg
;
1445 alu
.src
[0].sel
= ctx
->temp_reg
;
1446 alu
.src
[0].chan
= 0;
1448 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1452 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1453 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1457 alu
.dst
.sel
= ctx
->temp_reg
;
1460 alu
.src
[0].sel
= ctx
->temp_reg
;
1461 alu
.src
[0].chan
= 0;
1463 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1464 alu
.src
[1].chan
= 0;
1465 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1466 alu
.src
[2].chan
= 0;
1468 if (ctx
->bc
->chip_class
== R600
) {
1469 alu
.src
[1].value
= *(uint32_t *)&double_pi
;
1470 alu
.src
[2].value
= *(uint32_t *)&neg_pi
;
1472 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1473 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
1478 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1484 static int cayman_trig(struct r600_shader_ctx
*ctx
)
1486 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1487 struct r600_bytecode_alu alu
;
1488 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
1491 r
= tgsi_setup_trig(ctx
);
1496 for (i
= 0; i
< last_slot
; i
++) {
1497 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1498 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1501 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1502 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1504 alu
.src
[0].sel
= ctx
->temp_reg
;
1505 alu
.src
[0].chan
= 0;
1506 if (i
== last_slot
- 1)
1508 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1515 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
1517 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1518 struct r600_bytecode_alu alu
;
1520 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1522 r
= tgsi_setup_trig(ctx
);
1526 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1527 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1529 alu
.dst
.sel
= ctx
->temp_reg
;
1532 alu
.src
[0].sel
= ctx
->temp_reg
;
1533 alu
.src
[0].chan
= 0;
1535 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1539 /* replicate result */
1540 for (i
= 0; i
< lasti
+ 1; i
++) {
1541 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1544 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1545 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1547 alu
.src
[0].sel
= ctx
->temp_reg
;
1548 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1551 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1558 static int tgsi_scs(struct r600_shader_ctx
*ctx
)
1560 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1561 struct r600_bytecode_alu alu
;
1564 /* We'll only need the trig stuff if we are going to write to the
1565 * X or Y components of the destination vector.
1567 if (likely(inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_XY
)) {
1568 r
= tgsi_setup_trig(ctx
);
1574 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_X
) {
1575 if (ctx
->bc
->chip_class
== CAYMAN
) {
1576 for (i
= 0 ; i
< 3; i
++) {
1577 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1578 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
1579 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1585 alu
.src
[0].sel
= ctx
->temp_reg
;
1586 alu
.src
[0].chan
= 0;
1589 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1594 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1595 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
1596 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1598 alu
.src
[0].sel
= ctx
->temp_reg
;
1599 alu
.src
[0].chan
= 0;
1601 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1608 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Y
) {
1609 if (ctx
->bc
->chip_class
== CAYMAN
) {
1610 for (i
= 0 ; i
< 3; i
++) {
1611 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1612 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
1613 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1618 alu
.src
[0].sel
= ctx
->temp_reg
;
1619 alu
.src
[0].chan
= 0;
1622 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1627 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1628 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
1629 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1631 alu
.src
[0].sel
= ctx
->temp_reg
;
1632 alu
.src
[0].chan
= 0;
1634 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1641 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Z
) {
1642 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1644 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1646 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1648 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1649 alu
.src
[0].chan
= 0;
1653 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1659 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
1660 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1662 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1664 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1666 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1667 alu
.src
[0].chan
= 0;
1671 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1679 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
1681 struct r600_bytecode_alu alu
;
1684 for (i
= 0; i
< 4; i
++) {
1685 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1686 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1690 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1692 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
1693 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1696 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
1701 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1706 /* kill must be last in ALU */
1707 ctx
->bc
->force_add_cf
= 1;
1708 ctx
->shader
->uses_kill
= TRUE
;
1712 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
1714 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1715 struct r600_bytecode_alu alu
;
1718 /* tmp.x = max(src.y, 0.0) */
1719 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1720 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1721 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 1);
1722 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1723 alu
.src
[1].chan
= 1;
1725 alu
.dst
.sel
= ctx
->temp_reg
;
1730 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1734 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
1740 if (ctx
->bc
->chip_class
== CAYMAN
) {
1741 for (i
= 0; i
< 3; i
++) {
1742 /* tmp.z = log(tmp.x) */
1743 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1744 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1745 alu
.src
[0].sel
= ctx
->temp_reg
;
1746 alu
.src
[0].chan
= 0;
1747 alu
.dst
.sel
= ctx
->temp_reg
;
1755 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1760 /* tmp.z = log(tmp.x) */
1761 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1762 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1763 alu
.src
[0].sel
= ctx
->temp_reg
;
1764 alu
.src
[0].chan
= 0;
1765 alu
.dst
.sel
= ctx
->temp_reg
;
1769 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1774 chan
= alu
.dst
.chan
;
1777 /* tmp.x = amd MUL_LIT(tmp.z, src.w, src.x ) */
1778 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1779 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
1780 alu
.src
[0].sel
= sel
;
1781 alu
.src
[0].chan
= chan
;
1782 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], 3);
1783 r600_bytecode_src(&alu
.src
[2], &ctx
->src
[0], 0);
1784 alu
.dst
.sel
= ctx
->temp_reg
;
1789 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1793 if (ctx
->bc
->chip_class
== CAYMAN
) {
1794 for (i
= 0; i
< 3; i
++) {
1795 /* dst.z = exp(tmp.x) */
1796 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1797 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1798 alu
.src
[0].sel
= ctx
->temp_reg
;
1799 alu
.src
[0].chan
= 0;
1800 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1806 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1811 /* dst.z = exp(tmp.x) */
1812 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1813 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1814 alu
.src
[0].sel
= ctx
->temp_reg
;
1815 alu
.src
[0].chan
= 0;
1816 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1818 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1825 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1826 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1827 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
1828 alu
.src
[0].chan
= 0;
1829 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1830 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
1831 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1835 /* dst.y = max(src.x, 0.0) */
1836 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1837 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1838 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
1839 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1840 alu
.src
[1].chan
= 0;
1841 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1842 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
1843 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1848 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1849 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1850 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1851 alu
.src
[0].chan
= 0;
1852 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1853 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
1855 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1862 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
1864 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1865 struct r600_bytecode_alu alu
;
1868 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1871 * For state trackers other than OpenGL, we'll want to use
1872 * _RECIPSQRT_IEEE instead.
1874 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
1876 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1877 r600_bytecode_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
1878 r600_bytecode_src_set_abs(&alu
.src
[i
]);
1880 alu
.dst
.sel
= ctx
->temp_reg
;
1883 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1886 /* replicate result */
1887 return tgsi_helper_tempx_replicate(ctx
);
1890 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1892 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1893 struct r600_bytecode_alu alu
;
1896 for (i
= 0; i
< 4; i
++) {
1897 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1898 alu
.src
[0].sel
= ctx
->temp_reg
;
1899 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1901 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1902 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1905 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1912 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1914 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1915 struct r600_bytecode_alu alu
;
1918 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1919 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1920 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1921 r600_bytecode_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
1923 alu
.dst
.sel
= ctx
->temp_reg
;
1926 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1929 /* replicate result */
1930 return tgsi_helper_tempx_replicate(ctx
);
1933 static int cayman_pow(struct r600_shader_ctx
*ctx
)
1935 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1937 struct r600_bytecode_alu alu
;
1938 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
1940 for (i
= 0; i
< 3; i
++) {
1941 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1942 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1943 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
1944 alu
.dst
.sel
= ctx
->temp_reg
;
1949 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1955 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1956 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1957 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], 0);
1958 alu
.src
[1].sel
= ctx
->temp_reg
;
1959 alu
.dst
.sel
= ctx
->temp_reg
;
1962 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1966 for (i
= 0; i
< last_slot
; i
++) {
1967 /* POW(a,b) = EXP2(b * LOG2(a))*/
1968 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1969 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1970 alu
.src
[0].sel
= ctx
->temp_reg
;
1972 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1973 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1974 if (i
== last_slot
- 1)
1976 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1983 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1985 struct r600_bytecode_alu alu
;
1989 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
1990 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1991 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
1992 alu
.dst
.sel
= ctx
->temp_reg
;
1995 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
1999 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2000 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2001 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], 0);
2002 alu
.src
[1].sel
= ctx
->temp_reg
;
2003 alu
.dst
.sel
= ctx
->temp_reg
;
2006 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2009 /* POW(a,b) = EXP2(b * LOG2(a))*/
2010 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2011 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2012 alu
.src
[0].sel
= ctx
->temp_reg
;
2013 alu
.dst
.sel
= ctx
->temp_reg
;
2016 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2019 return tgsi_helper_tempx_replicate(ctx
);
2022 static int tgsi_idiv(struct r600_shader_ctx
*ctx
)
2024 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2025 struct r600_bytecode_alu alu
;
2027 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
2028 int last_inst
= tgsi_last_instruction(write_mask
);
2029 int tmp0
= ctx
->temp_reg
;
2030 int tmp1
= r600_get_temp(ctx
);
2031 int unsigned_op
= (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_UDIV
);
2033 /* tmp0 = float(src0) */
2034 for (i
= 0; i
< 4; i
++) {
2035 if (!(write_mask
& (1<<i
)))
2038 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2041 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
);
2043 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
);
2049 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
2051 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2057 /* tmp1 = tmp0>=0 ? 0.5 : -0.5 for int*/
2058 for (i
= 0; i
< 4; i
++) {
2059 if (!(write_mask
& (1<<i
)))
2062 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2063 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
2070 alu
.src
[0].sel
= tmp0
;
2071 alu
.src
[0].chan
= i
;
2073 alu
.src
[1].sel
= V_SQ_ALU_SRC_0_5
;
2076 alu
.src
[2].sel
= V_SQ_ALU_SRC_0
;
2078 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
2084 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2090 /* tmp0 = tmp0 + tmp1 for int */
2091 /* tmp0 = tmp0 + 0.5 for uint */
2092 for (i
= 0; i
< 4; i
++) {
2093 if (!(write_mask
& (1<<i
)))
2096 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2097 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
2103 alu
.src
[0].sel
= tmp0
;
2104 alu
.src
[0].chan
= i
;
2107 alu
.src
[1].sel
= V_SQ_ALU_SRC_0_5
;
2109 alu
.src
[1].sel
= tmp1
;
2110 alu
.src
[1].chan
= i
;
2115 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2120 /* tmp1 = float(src1) */
2121 for (i
= 0; i
< 4; i
++) {
2122 if (!(write_mask
& (1<<i
)))
2125 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2128 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
);
2130 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
);
2136 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
2138 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2143 /* tmp1 = 1.0/src1 */
2144 for (i
= 0; i
< 4; i
++) {
2145 if (!(write_mask
& (1<<i
)))
2148 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2149 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2155 alu
.src
[0].sel
= tmp1
;
2156 alu
.src
[0].chan
= i
;
2159 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2164 /* tmp1 = tmp0 * tmp1 */
2165 for (i
= 0; i
< 4; i
++) {
2166 if (!(write_mask
& (1<<i
)))
2169 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2170 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2176 alu
.src
[0].sel
= ctx
->temp_reg
;
2177 alu
.src
[0].chan
= i
;
2179 alu
.src
[1].sel
= tmp1
;
2180 alu
.src
[1].chan
= i
;
2184 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2189 /* tmp1 = trunc(tmp1) for evergreen+ */
2190 if (ctx
->bc
->chip_class
>= EVERGREEN
) {
2191 for (i
= 0; i
< 4; i
++) {
2192 if (!(write_mask
& (1<<i
)))
2195 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2196 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
);
2202 alu
.src
[0].sel
= tmp1
;
2203 alu
.src
[0].chan
= i
;
2207 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2213 /* dst = int(tmp1) */
2214 for (i
= 0; i
< 4; i
++) {
2215 if (!(write_mask
& (1<<i
)))
2218 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2221 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
);
2223 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
);
2225 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2227 alu
.src
[0].sel
= tmp1
;
2228 alu
.src
[0].chan
= i
;
2230 if ((ctx
->bc
->chip_class
< EVERGREEN
|| unsigned_op
) || i
== last_inst
)
2232 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2240 static int tgsi_f2i(struct r600_shader_ctx
*ctx
)
2242 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2243 struct r600_bytecode_alu alu
;
2245 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
2246 int last_inst
= tgsi_last_instruction(write_mask
);
2248 for (i
= 0; i
< 4; i
++) {
2249 if (!(write_mask
& (1<<i
)))
2252 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2253 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
);
2255 alu
.dst
.sel
= ctx
->temp_reg
;
2259 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
2262 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2267 for (i
= 0; i
< 4; i
++) {
2268 if (!(write_mask
& (1<<i
)))
2271 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2272 alu
.inst
= ctx
->inst_info
->r600_opcode
;
2274 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2276 alu
.src
[0].sel
= ctx
->temp_reg
;
2277 alu
.src
[0].chan
= i
;
2281 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2289 static int tgsi_iabs(struct r600_shader_ctx
*ctx
)
2291 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2292 struct r600_bytecode_alu alu
;
2294 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
2295 int last_inst
= tgsi_last_instruction(write_mask
);
2298 for (i
= 0; i
< 4; i
++) {
2299 if (!(write_mask
& (1<<i
)))
2302 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2303 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
);
2305 alu
.dst
.sel
= ctx
->temp_reg
;
2309 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
2310 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2314 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2319 /* dst = (src >= 0 ? src : tmp) */
2320 for (i
= 0; i
< 4; i
++) {
2321 if (!(write_mask
& (1<<i
)))
2324 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2325 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
2329 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2331 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
2332 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
2333 alu
.src
[2].sel
= ctx
->temp_reg
;
2334 alu
.src
[2].chan
= i
;
2338 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2345 static int tgsi_issg(struct r600_shader_ctx
*ctx
)
2347 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2348 struct r600_bytecode_alu alu
;
2350 unsigned write_mask
= inst
->Dst
[0].Register
.WriteMask
;
2351 int last_inst
= tgsi_last_instruction(write_mask
);
2353 /* tmp = (src >= 0 ? src : -1) */
2354 for (i
= 0; i
< 4; i
++) {
2355 if (!(write_mask
& (1<<i
)))
2358 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2359 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE_INT
);
2362 alu
.dst
.sel
= ctx
->temp_reg
;
2366 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
2367 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
2368 alu
.src
[2].sel
= V_SQ_ALU_SRC_M_1_INT
;
2372 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2377 /* dst = (tmp > 0 ? 1 : tmp) */
2378 for (i
= 0; i
< 4; i
++) {
2379 if (!(write_mask
& (1<<i
)))
2382 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2383 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT_INT
);
2387 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2389 alu
.src
[0].sel
= ctx
->temp_reg
;
2390 alu
.src
[0].chan
= i
;
2392 alu
.src
[1].sel
= V_SQ_ALU_SRC_1_INT
;
2394 alu
.src
[2].sel
= ctx
->temp_reg
;
2395 alu
.src
[2].chan
= i
;
2399 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2408 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
2410 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2411 struct r600_bytecode_alu alu
;
2414 /* tmp = (src > 0 ? 1 : src) */
2415 for (i
= 0; i
< 4; i
++) {
2416 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2417 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
2420 alu
.dst
.sel
= ctx
->temp_reg
;
2423 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
2424 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2425 r600_bytecode_src(&alu
.src
[2], &ctx
->src
[0], i
);
2429 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2434 /* dst = (-tmp > 0 ? -1 : tmp) */
2435 for (i
= 0; i
< 4; i
++) {
2436 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2437 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
2439 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2441 alu
.src
[0].sel
= ctx
->temp_reg
;
2442 alu
.src
[0].chan
= i
;
2445 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2448 alu
.src
[2].sel
= ctx
->temp_reg
;
2449 alu
.src
[2].chan
= i
;
2453 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2460 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
2462 struct r600_bytecode_alu alu
;
2465 for (i
= 0; i
< 4; i
++) {
2466 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2467 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
2468 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
2471 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2472 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2473 alu
.src
[0].sel
= ctx
->temp_reg
;
2474 alu
.src
[0].chan
= i
;
2479 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2486 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
2488 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2489 struct r600_bytecode_alu alu
;
2491 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
2493 for (i
= 0; i
< lasti
+ 1; i
++) {
2494 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
2497 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2498 alu
.inst
= ctx
->inst_info
->r600_opcode
;
2499 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
2500 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
2503 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2510 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2517 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
2519 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2520 struct r600_bytecode_alu alu
;
2523 for (i
= 0; i
< 4; i
++) {
2524 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2525 alu
.inst
= ctx
->inst_info
->r600_opcode
;
2526 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
2527 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
2530 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2532 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
2533 /* handle some special cases */
2534 switch (ctx
->inst_info
->tgsi_opcode
) {
2535 case TGSI_OPCODE_DP2
:
2537 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2538 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
2541 case TGSI_OPCODE_DP3
:
2543 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2544 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
2547 case TGSI_OPCODE_DPH
:
2549 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2550 alu
.src
[0].chan
= 0;
2560 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2567 static inline boolean
tgsi_tex_src_requires_loading(struct r600_shader_ctx
*ctx
,
2570 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2571 return (inst
->Src
[index
].Register
.File
!= TGSI_FILE_TEMPORARY
&&
2572 inst
->Src
[index
].Register
.File
!= TGSI_FILE_INPUT
) ||
2573 ctx
->src
[index
].neg
|| ctx
->src
[index
].abs
;
2576 static inline unsigned tgsi_tex_get_src_gpr(struct r600_shader_ctx
*ctx
,
2579 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2580 return ctx
->file_offset
[inst
->Src
[index
].Register
.File
] + inst
->Src
[index
].Register
.Index
;
2583 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
2585 static float one_point_five
= 1.5f
;
2586 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2587 struct r600_bytecode_tex tex
;
2588 struct r600_bytecode_alu alu
;
2592 /* Texture fetch instructions can only use gprs as source.
2593 * Also they cannot negate the source or take the absolute value */
2594 const boolean src_requires_loading
= tgsi_tex_src_requires_loading(ctx
, 0);
2595 boolean src_loaded
= FALSE
;
2596 unsigned sampler_src_reg
= 1;
2597 u8 offset_x
= 0, offset_y
= 0, offset_z
= 0;
2599 src_gpr
= tgsi_tex_get_src_gpr(ctx
, 0);
2601 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXF
) {
2602 /* get offset values */
2603 if (inst
->Texture
.NumOffsets
) {
2604 assert(inst
->Texture
.NumOffsets
== 1);
2606 offset_x
= ctx
->literals
[inst
->TexOffsets
[0].Index
+ inst
->TexOffsets
[0].SwizzleX
] << 1;
2607 offset_y
= ctx
->literals
[inst
->TexOffsets
[0].Index
+ inst
->TexOffsets
[0].SwizzleY
] << 1;
2608 offset_z
= ctx
->literals
[inst
->TexOffsets
[0].Index
+ inst
->TexOffsets
[0].SwizzleZ
] << 1;
2610 } else if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXD
) {
2611 /* TGSI moves the sampler to src reg 3 for TXD */
2612 sampler_src_reg
= 3;
2614 for (i
= 1; i
< 3; i
++) {
2615 /* set gradients h/v */
2616 memset(&tex
, 0, sizeof(struct r600_bytecode_tex
));
2617 tex
.inst
= (i
== 1) ? SQ_TEX_INST_SET_GRADIENTS_H
:
2618 SQ_TEX_INST_SET_GRADIENTS_V
;
2619 tex
.sampler_id
= tgsi_tex_get_src_gpr(ctx
, sampler_src_reg
);
2620 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
2622 if (tgsi_tex_src_requires_loading(ctx
, i
)) {
2623 tex
.src_gpr
= r600_get_temp(ctx
);
2629 for (j
= 0; j
< 4; j
++) {
2630 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2631 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2632 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[i
], j
);
2633 alu
.dst
.sel
= tex
.src_gpr
;
2638 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2644 tex
.src_gpr
= tgsi_tex_get_src_gpr(ctx
, i
);
2645 tex
.src_sel_x
= ctx
->src
[i
].swizzle
[0];
2646 tex
.src_sel_y
= ctx
->src
[i
].swizzle
[1];
2647 tex
.src_sel_z
= ctx
->src
[i
].swizzle
[2];
2648 tex
.src_sel_w
= ctx
->src
[i
].swizzle
[3];
2649 tex
.src_rel
= ctx
->src
[i
].rel
;
2651 tex
.dst_gpr
= ctx
->temp_reg
; /* just to avoid confusing the asm scheduler */
2652 tex
.dst_sel_x
= tex
.dst_sel_y
= tex
.dst_sel_z
= tex
.dst_sel_w
= 7;
2653 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
2654 tex
.coord_type_x
= 1;
2655 tex
.coord_type_y
= 1;
2656 tex
.coord_type_z
= 1;
2657 tex
.coord_type_w
= 1;
2659 r
= r600_bytecode_add_tex(ctx
->bc
, &tex
);
2663 } else if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
2665 /* Add perspective divide */
2666 if (ctx
->bc
->chip_class
== CAYMAN
) {
2668 for (i
= 0; i
< 3; i
++) {
2669 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2670 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2671 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 3);
2673 alu
.dst
.sel
= ctx
->temp_reg
;
2679 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2686 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2687 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2688 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 3);
2690 alu
.dst
.sel
= ctx
->temp_reg
;
2691 alu
.dst
.chan
= out_chan
;
2694 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2699 for (i
= 0; i
< 3; i
++) {
2700 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2701 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2702 alu
.src
[0].sel
= ctx
->temp_reg
;
2703 alu
.src
[0].chan
= out_chan
;
2704 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
2705 alu
.dst
.sel
= ctx
->temp_reg
;
2708 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2712 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2713 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2714 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2715 alu
.src
[0].chan
= 0;
2716 alu
.dst
.sel
= ctx
->temp_reg
;
2720 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2724 src_gpr
= ctx
->temp_reg
;
2727 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
2728 static const unsigned src0_swizzle
[] = {2, 2, 0, 1};
2729 static const unsigned src1_swizzle
[] = {1, 0, 2, 2};
2731 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
2732 for (i
= 0; i
< 4; i
++) {
2733 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2734 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
2735 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], src0_swizzle
[i
]);
2736 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], src1_swizzle
[i
]);
2737 alu
.dst
.sel
= ctx
->temp_reg
;
2742 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2747 /* tmp1.z = RCP_e(|tmp1.z|) */
2748 if (ctx
->bc
->chip_class
== CAYMAN
) {
2749 for (i
= 0; i
< 3; i
++) {
2750 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2751 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2752 alu
.src
[0].sel
= ctx
->temp_reg
;
2753 alu
.src
[0].chan
= 2;
2755 alu
.dst
.sel
= ctx
->temp_reg
;
2761 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2766 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2767 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2768 alu
.src
[0].sel
= ctx
->temp_reg
;
2769 alu
.src
[0].chan
= 2;
2771 alu
.dst
.sel
= ctx
->temp_reg
;
2775 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2780 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
2781 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
2782 * muladd has no writemask, have to use another temp
2784 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2785 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2788 alu
.src
[0].sel
= ctx
->temp_reg
;
2789 alu
.src
[0].chan
= 0;
2790 alu
.src
[1].sel
= ctx
->temp_reg
;
2791 alu
.src
[1].chan
= 2;
2793 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
2794 alu
.src
[2].chan
= 0;
2795 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
2797 alu
.dst
.sel
= ctx
->temp_reg
;
2801 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2805 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2806 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2809 alu
.src
[0].sel
= ctx
->temp_reg
;
2810 alu
.src
[0].chan
= 1;
2811 alu
.src
[1].sel
= ctx
->temp_reg
;
2812 alu
.src
[1].chan
= 2;
2814 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
2815 alu
.src
[2].chan
= 0;
2816 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
2818 alu
.dst
.sel
= ctx
->temp_reg
;
2823 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2828 src_gpr
= ctx
->temp_reg
;
2831 if (src_requires_loading
&& !src_loaded
) {
2832 for (i
= 0; i
< 4; i
++) {
2833 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2834 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2835 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
2836 alu
.dst
.sel
= ctx
->temp_reg
;
2841 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2846 src_gpr
= ctx
->temp_reg
;
2849 opcode
= ctx
->inst_info
->r600_opcode
;
2850 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
||
2851 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
||
2852 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWRECT
||
2853 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D_ARRAY
||
2854 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D_ARRAY
) {
2856 case SQ_TEX_INST_SAMPLE
:
2857 opcode
= SQ_TEX_INST_SAMPLE_C
;
2859 case SQ_TEX_INST_SAMPLE_L
:
2860 opcode
= SQ_TEX_INST_SAMPLE_C_L
;
2862 case SQ_TEX_INST_SAMPLE_LB
:
2863 opcode
= SQ_TEX_INST_SAMPLE_C_LB
;
2865 case SQ_TEX_INST_SAMPLE_G
:
2866 opcode
= SQ_TEX_INST_SAMPLE_C_G
;
2871 memset(&tex
, 0, sizeof(struct r600_bytecode_tex
));
2874 tex
.sampler_id
= tgsi_tex_get_src_gpr(ctx
, sampler_src_reg
);
2875 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
2876 tex
.src_gpr
= src_gpr
;
2877 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
2878 tex
.dst_sel_x
= (inst
->Dst
[0].Register
.WriteMask
& 1) ? 0 : 7;
2879 tex
.dst_sel_y
= (inst
->Dst
[0].Register
.WriteMask
& 2) ? 1 : 7;
2880 tex
.dst_sel_z
= (inst
->Dst
[0].Register
.WriteMask
& 4) ? 2 : 7;
2881 tex
.dst_sel_w
= (inst
->Dst
[0].Register
.WriteMask
& 8) ? 3 : 7;
2888 tex
.src_sel_x
= ctx
->src
[0].swizzle
[0];
2889 tex
.src_sel_y
= ctx
->src
[0].swizzle
[1];
2890 tex
.src_sel_z
= ctx
->src
[0].swizzle
[2];
2891 tex
.src_sel_w
= ctx
->src
[0].swizzle
[3];
2892 tex
.src_rel
= ctx
->src
[0].rel
;
2895 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
2902 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
&&
2903 inst
->Texture
.Texture
!= TGSI_TEXTURE_SHADOWRECT
) {
2904 tex
.coord_type_x
= 1;
2905 tex
.coord_type_y
= 1;
2907 tex
.coord_type_z
= 1;
2908 tex
.coord_type_w
= 1;
2910 tex
.offset_x
= offset_x
;
2911 tex
.offset_y
= offset_y
;
2912 tex
.offset_z
= offset_z
;
2914 /* Put the depth for comparison in W.
2915 * TGSI_TEXTURE_SHADOW2D_ARRAY already has the depth in W.
2916 * Some instructions expect the depth in Z. */
2917 if ((inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
||
2918 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
||
2919 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOWRECT
||
2920 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D_ARRAY
) &&
2921 opcode
!= SQ_TEX_INST_SAMPLE_C_L
&&
2922 opcode
!= SQ_TEX_INST_SAMPLE_C_LB
) {
2923 tex
.src_sel_w
= tex
.src_sel_z
;
2926 if (inst
->Texture
.Texture
== TGSI_TEXTURE_1D_ARRAY
||
2927 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D_ARRAY
) {
2928 if (opcode
== SQ_TEX_INST_SAMPLE_C_L
||
2929 opcode
== SQ_TEX_INST_SAMPLE_C_LB
) {
2930 /* the array index is read from Y */
2931 tex
.coord_type_y
= 0;
2933 /* the array index is read from Z */
2934 tex
.coord_type_z
= 0;
2935 tex
.src_sel_z
= tex
.src_sel_y
;
2937 } else if (inst
->Texture
.Texture
== TGSI_TEXTURE_2D_ARRAY
||
2938 inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D_ARRAY
)
2939 /* the array index is read from Z */
2940 tex
.coord_type_z
= 0;
2942 r
= r600_bytecode_add_tex(ctx
->bc
, &tex
);
2946 /* add shadow ambient support - gallium doesn't do it yet */
2950 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
2952 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2953 struct r600_bytecode_alu alu
;
2954 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
2958 /* optimize if it's just an equal balance */
2959 if (ctx
->src
[0].sel
== V_SQ_ALU_SRC_0_5
) {
2960 for (i
= 0; i
< lasti
+ 1; i
++) {
2961 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
2964 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2965 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
2966 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[1], i
);
2967 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
2969 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2974 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
2982 for (i
= 0; i
< lasti
+ 1; i
++) {
2983 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
2986 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
2987 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
2988 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2989 alu
.src
[0].chan
= 0;
2990 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[0], i
);
2991 r600_bytecode_src_toggle_neg(&alu
.src
[1]);
2992 alu
.dst
.sel
= ctx
->temp_reg
;
2998 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3003 /* (1 - src0) * src2 */
3004 for (i
= 0; i
< lasti
+ 1; i
++) {
3005 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
3008 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3009 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
3010 alu
.src
[0].sel
= ctx
->temp_reg
;
3011 alu
.src
[0].chan
= i
;
3012 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
3013 alu
.dst
.sel
= ctx
->temp_reg
;
3019 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3024 /* src0 * src1 + (1 - src0) * src2 */
3025 for (i
= 0; i
< lasti
+ 1; i
++) {
3026 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
3029 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3030 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
3032 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3033 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
3034 alu
.src
[2].sel
= ctx
->temp_reg
;
3035 alu
.src
[2].chan
= i
;
3037 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3042 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3049 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
3051 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3052 struct r600_bytecode_alu alu
;
3054 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
3056 for (i
= 0; i
< lasti
+ 1; i
++) {
3057 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
3060 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3061 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
3062 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3063 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
3064 r600_bytecode_src(&alu
.src
[2], &ctx
->src
[1], i
);
3065 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3071 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3078 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
3080 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3081 static const unsigned int src0_swizzle
[] = {2, 0, 1};
3082 static const unsigned int src1_swizzle
[] = {1, 2, 0};
3083 struct r600_bytecode_alu alu
;
3084 uint32_t use_temp
= 0;
3087 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
3090 for (i
= 0; i
< 4; i
++) {
3091 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3092 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
3094 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], src0_swizzle
[i
]);
3095 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], src1_swizzle
[i
]);
3097 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
3098 alu
.src
[0].chan
= i
;
3099 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
3100 alu
.src
[1].chan
= i
;
3103 alu
.dst
.sel
= ctx
->temp_reg
;
3109 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3114 for (i
= 0; i
< 4; i
++) {
3115 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3116 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
3119 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], src1_swizzle
[i
]);
3120 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], src0_swizzle
[i
]);
3122 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
3123 alu
.src
[0].chan
= i
;
3124 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
3125 alu
.src
[1].chan
= i
;
3128 alu
.src
[2].sel
= ctx
->temp_reg
;
3130 alu
.src
[2].chan
= i
;
3133 alu
.dst
.sel
= ctx
->temp_reg
;
3135 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3141 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3146 return tgsi_helper_copy(ctx
, inst
);
3150 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
3152 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3153 struct r600_bytecode_alu alu
;
3157 /* result.x = 2^floor(src); */
3158 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
3159 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3161 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
3162 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3164 alu
.dst
.sel
= ctx
->temp_reg
;
3168 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3172 if (ctx
->bc
->chip_class
== CAYMAN
) {
3173 for (i
= 0; i
< 3; i
++) {
3174 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
3175 alu
.src
[0].sel
= ctx
->temp_reg
;
3176 alu
.src
[0].chan
= 0;
3178 alu
.dst
.sel
= ctx
->temp_reg
;
3184 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3189 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
3190 alu
.src
[0].sel
= ctx
->temp_reg
;
3191 alu
.src
[0].chan
= 0;
3193 alu
.dst
.sel
= ctx
->temp_reg
;
3197 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3203 /* result.y = tmp - floor(tmp); */
3204 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
3205 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3207 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
3208 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3210 alu
.dst
.sel
= ctx
->temp_reg
;
3212 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3221 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3226 /* result.z = RoughApprox2ToX(tmp);*/
3227 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
3228 if (ctx
->bc
->chip_class
== CAYMAN
) {
3229 for (i
= 0; i
< 3; i
++) {
3230 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3231 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
3232 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3234 alu
.dst
.sel
= ctx
->temp_reg
;
3241 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3246 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3247 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
3248 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3250 alu
.dst
.sel
= ctx
->temp_reg
;
3256 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3262 /* result.w = 1.0;*/
3263 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
3264 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3266 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
3267 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
3268 alu
.src
[0].chan
= 0;
3270 alu
.dst
.sel
= ctx
->temp_reg
;
3274 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3278 return tgsi_helper_copy(ctx
, inst
);
3281 static int tgsi_log(struct r600_shader_ctx
*ctx
)
3283 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3284 struct r600_bytecode_alu alu
;
3288 /* result.x = floor(log2(|src|)); */
3289 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
3290 if (ctx
->bc
->chip_class
== CAYMAN
) {
3291 for (i
= 0; i
< 3; i
++) {
3292 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3294 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
3295 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3296 r600_bytecode_src_set_abs(&alu
.src
[0]);
3298 alu
.dst
.sel
= ctx
->temp_reg
;
3304 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3310 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3312 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
3313 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3314 r600_bytecode_src_set_abs(&alu
.src
[0]);
3316 alu
.dst
.sel
= ctx
->temp_reg
;
3320 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3325 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
3326 alu
.src
[0].sel
= ctx
->temp_reg
;
3327 alu
.src
[0].chan
= 0;
3329 alu
.dst
.sel
= ctx
->temp_reg
;
3334 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3339 /* result.y = |src.x| / (2 ^ floor(log2(|src.x|))); */
3340 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
3342 if (ctx
->bc
->chip_class
== CAYMAN
) {
3343 for (i
= 0; i
< 3; i
++) {
3344 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3346 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
3347 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3348 r600_bytecode_src_set_abs(&alu
.src
[0]);
3350 alu
.dst
.sel
= ctx
->temp_reg
;
3357 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3362 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3364 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
3365 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3366 r600_bytecode_src_set_abs(&alu
.src
[0]);
3368 alu
.dst
.sel
= ctx
->temp_reg
;
3373 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3378 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3380 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
3381 alu
.src
[0].sel
= ctx
->temp_reg
;
3382 alu
.src
[0].chan
= 1;
3384 alu
.dst
.sel
= ctx
->temp_reg
;
3389 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3393 if (ctx
->bc
->chip_class
== CAYMAN
) {
3394 for (i
= 0; i
< 3; i
++) {
3395 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3396 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
3397 alu
.src
[0].sel
= ctx
->temp_reg
;
3398 alu
.src
[0].chan
= 1;
3400 alu
.dst
.sel
= ctx
->temp_reg
;
3407 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3412 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3413 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
3414 alu
.src
[0].sel
= ctx
->temp_reg
;
3415 alu
.src
[0].chan
= 1;
3417 alu
.dst
.sel
= ctx
->temp_reg
;
3422 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3427 if (ctx
->bc
->chip_class
== CAYMAN
) {
3428 for (i
= 0; i
< 3; i
++) {
3429 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3430 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
3431 alu
.src
[0].sel
= ctx
->temp_reg
;
3432 alu
.src
[0].chan
= 1;
3434 alu
.dst
.sel
= ctx
->temp_reg
;
3441 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3446 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3447 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
3448 alu
.src
[0].sel
= ctx
->temp_reg
;
3449 alu
.src
[0].chan
= 1;
3451 alu
.dst
.sel
= ctx
->temp_reg
;
3456 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3461 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3463 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
3465 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3466 r600_bytecode_src_set_abs(&alu
.src
[0]);
3468 alu
.src
[1].sel
= ctx
->temp_reg
;
3469 alu
.src
[1].chan
= 1;
3471 alu
.dst
.sel
= ctx
->temp_reg
;
3476 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3481 /* result.z = log2(|src|);*/
3482 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
3483 if (ctx
->bc
->chip_class
== CAYMAN
) {
3484 for (i
= 0; i
< 3; i
++) {
3485 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3487 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
3488 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3489 r600_bytecode_src_set_abs(&alu
.src
[0]);
3491 alu
.dst
.sel
= ctx
->temp_reg
;
3498 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3503 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3505 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
3506 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3507 r600_bytecode_src_set_abs(&alu
.src
[0]);
3509 alu
.dst
.sel
= ctx
->temp_reg
;
3514 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3520 /* result.w = 1.0; */
3521 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
3522 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3524 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
3525 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
3526 alu
.src
[0].chan
= 0;
3528 alu
.dst
.sel
= ctx
->temp_reg
;
3533 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3538 return tgsi_helper_copy(ctx
, inst
);
3541 static int tgsi_eg_arl(struct r600_shader_ctx
*ctx
)
3543 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3544 struct r600_bytecode_alu alu
;
3547 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3549 switch (inst
->Instruction
.Opcode
) {
3550 case TGSI_OPCODE_ARL
:
3551 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR
;
3553 case TGSI_OPCODE_ARR
:
3554 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
3556 case TGSI_OPCODE_UARL
:
3557 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
3564 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3566 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
3568 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3572 ctx
->bc
->ar_loaded
= 0;
3575 static int tgsi_r600_arl(struct r600_shader_ctx
*ctx
)
3577 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3578 struct r600_bytecode_alu alu
;
3581 switch (inst
->Instruction
.Opcode
) {
3582 case TGSI_OPCODE_ARL
:
3583 memset(&alu
, 0, sizeof(alu
));
3584 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
;
3585 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3586 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
3590 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3593 memset(&alu
, 0, sizeof(alu
));
3594 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
3595 alu
.src
[0].sel
= ctx
->bc
->ar_reg
;
3596 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
3600 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3603 case TGSI_OPCODE_ARR
:
3604 memset(&alu
, 0, sizeof(alu
));
3605 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
3606 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3607 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
3611 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3614 case TGSI_OPCODE_UARL
:
3615 memset(&alu
, 0, sizeof(alu
));
3616 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
;
3617 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3618 alu
.dst
.sel
= ctx
->bc
->ar_reg
;
3622 if ((r
= r600_bytecode_add_alu(ctx
->bc
, &alu
)))
3630 ctx
->bc
->ar_loaded
= 0;
3634 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
3636 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3637 struct r600_bytecode_alu alu
;
3640 for (i
= 0; i
< 4; i
++) {
3641 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3643 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
3644 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
3646 if (i
== 0 || i
== 3) {
3647 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
3649 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], i
);
3652 if (i
== 0 || i
== 2) {
3653 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
3655 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[1], i
);
3659 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3666 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
3668 struct r600_bytecode_alu alu
;
3671 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3675 alu
.dst
.sel
= ctx
->temp_reg
;
3679 r600_bytecode_src(&alu
.src
[0], &ctx
->src
[0], 0);
3680 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
3681 alu
.src
[1].chan
= 0;
3685 r
= r600_bytecode_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
3691 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
3693 unsigned force_pop
= ctx
->bc
->force_add_cf
;
3697 if (ctx
->bc
->cf_last
) {
3698 if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
))
3700 else if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
))
3705 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
);
3706 ctx
->bc
->force_add_cf
= 1;
3707 } else if (alu_pop
== 2) {
3708 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
);
3709 ctx
->bc
->force_add_cf
= 1;
3716 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
3717 ctx
->bc
->cf_last
->pop_count
= pops
;
3718 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
3724 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
3728 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
3732 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
3735 /* TOODO : for 16 vp asic should -= 2; */
3736 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
3741 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
3743 if (check_max_only
) {
3756 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
3757 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
3758 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
3759 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
3765 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
3769 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
3772 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
3776 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
3777 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
3778 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
3779 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
3783 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
3785 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
3787 sp
->mid
= (struct r600_bytecode_cf
**)realloc((void *)sp
->mid
,
3788 sizeof(struct r600_bytecode_cf
*) * (sp
->num_mid
+ 1));
3789 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
3793 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
3796 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
3797 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
3800 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
3802 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
3814 static int emit_return(struct r600_shader_ctx
*ctx
)
3816 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_RETURN
));
3820 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
3823 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
3824 ctx
->bc
->cf_last
->pop_count
= pops
;
3825 /* TODO work out offset */
3829 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
3834 static void emit_testflag(struct r600_shader_ctx
*ctx
)
3839 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
3842 emit_jump_to_offset(ctx
, 1, 4);
3843 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
3844 pops(ctx
, ifidx
+ 1);
3848 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
3852 r600_bytecode_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
3853 ctx
->bc
->cf_last
->pop_count
= 1;
3855 fc_set_mid(ctx
, fc_sp
);
3861 static int tgsi_if(struct r600_shader_ctx
*ctx
)
3863 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT
));
3865 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
3867 fc_pushlevel(ctx
, FC_IF
);
3869 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
3873 static int tgsi_else(struct r600_shader_ctx
*ctx
)
3875 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
3876 ctx
->bc
->cf_last
->pop_count
= 1;
3878 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
3879 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
3883 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
3886 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
3887 R600_ERR("if/endif unbalanced in shader\n");
3891 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
3892 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
3893 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
3895 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
3899 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
3903 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
3905 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
3907 fc_pushlevel(ctx
, FC_LOOP
);
3909 /* check stack depth */
3910 callstack_check_depth(ctx
, FC_LOOP
, 0);
3914 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
3918 r600_bytecode_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
3920 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
3921 R600_ERR("loop/endloop in shader code are not paired.\n");
3925 /* fixup loop pointers - from r600isa
3926 LOOP END points to CF after LOOP START,
3927 LOOP START point to CF after LOOP END
3928 BRK/CONT point to LOOP END CF
3930 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
3932 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
3934 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
3935 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
3937 /* TODO add LOOPRET support */
3939 callstack_decrease_current(ctx
, FC_LOOP
);
3943 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
3947 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
3949 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
3954 R600_ERR("Break not inside loop/endloop pair\n");
3958 r600_bytecode_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
3959 ctx
->bc
->cf_last
->pop_count
= 1;
3961 fc_set_mid(ctx
, fscp
);
3964 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
3968 static int tgsi_umad(struct r600_shader_ctx
*ctx
)
3970 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
3971 struct r600_bytecode_alu alu
;
3973 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
3976 for (i
= 0; i
< lasti
+ 1; i
++) {
3977 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
3980 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
3983 alu
.dst
.sel
= ctx
->temp_reg
;
3986 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
);
3987 for (j
= 0; j
< 2; j
++) {
3988 r600_bytecode_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
3992 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
3998 for (i
= 0; i
< lasti
+ 1; i
++) {
3999 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
4002 memset(&alu
, 0, sizeof(struct r600_bytecode_alu
));
4003 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
4005 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
4007 alu
.src
[0].sel
= ctx
->temp_reg
;
4008 alu
.src
[0].chan
= i
;
4010 r600_bytecode_src(&alu
.src
[1], &ctx
->src
[2], i
);
4014 r
= r600_bytecode_add_alu(ctx
->bc
, &alu
);
4021 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
4022 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
4023 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
4024 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
4027 * For state trackers other than OpenGL, we'll want to use
4028 * _RECIP_IEEE instead.
4030 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
4032 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
4033 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
4034 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
4035 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
4036 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
4037 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4038 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4039 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
4040 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
4041 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
4042 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
4043 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
4044 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
4045 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
4046 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
4047 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4049 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4050 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4052 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4053 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4054 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
4055 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4056 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
4057 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE
, tgsi_op2
},
4058 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
4059 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
4060 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
4061 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
4063 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4064 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
4065 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4066 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4067 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
4068 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
4069 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
4070 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
4071 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4072 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4073 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4074 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4075 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4076 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
4077 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4078 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
4079 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
4080 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
4081 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
4082 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4083 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
4084 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
4085 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
4086 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4087 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4088 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4089 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4090 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4091 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4092 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
4093 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4094 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4095 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4096 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
4097 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
4098 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
4099 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
4100 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4101 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4102 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4103 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
4104 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
4105 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
4107 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4108 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4109 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
4110 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
4112 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4113 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4114 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4115 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4116 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4117 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
, tgsi_op2_trans
},
4118 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT
, tgsi_op2
},
4119 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
4120 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT
, tgsi_op2_trans
},
4122 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4123 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
, tgsi_op2
},
4124 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT
, tgsi_op2
},
4125 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4126 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
, tgsi_op2
},
4127 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4128 {TGSI_OPCODE_TXF
, 0, SQ_TEX_INST_LD
, tgsi_tex
},
4129 {TGSI_OPCODE_TXQ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
4130 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
4131 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4132 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4133 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
4134 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4135 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
4136 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4138 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4139 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4140 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4141 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4142 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4144 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4145 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4146 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4147 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4148 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4149 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4150 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4151 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4152 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
4153 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
4155 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4156 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
, tgsi_op2_trans
},
4157 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_idiv
},
4158 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT
, tgsi_op2
},
4159 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT
, tgsi_op2
},
4160 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
, tgsi_op2
},
4161 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT
, tgsi_op2
},
4162 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT
, tgsi_op2_trans
},
4163 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
, tgsi_op2
},
4164 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
, tgsi_op2
},
4165 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
, tgsi_op2_trans
},
4166 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
, tgsi_op2
},
4167 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_idiv
},
4168 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umad
},
4169 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT
, tgsi_op2
},
4170 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT
, tgsi_op2
},
4171 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4172 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
, tgsi_op2_trans
},
4173 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT
, tgsi_op2
},
4174 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
, tgsi_op2
},
4175 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
, tgsi_op2_trans
},
4176 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
, tgsi_op2_swap
},
4177 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT
, tgsi_op2_swap
},
4178 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4179 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4180 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4181 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4182 {TGSI_OPCODE_LOAD
, 0, 0, tgsi_unsupported
},
4183 {TGSI_OPCODE_LOAD_MS
, 0, 0, tgsi_unsupported
},
4184 {TGSI_OPCODE_SAMPLE
, 0, 0, tgsi_unsupported
},
4185 {TGSI_OPCODE_SAMPLE_B
, 0, 0, tgsi_unsupported
},
4186 {TGSI_OPCODE_SAMPLE_C
, 0, 0, tgsi_unsupported
},
4187 {TGSI_OPCODE_SAMPLE_C_LZ
, 0, 0, tgsi_unsupported
},
4188 {TGSI_OPCODE_SAMPLE_D
, 0, 0, tgsi_unsupported
},
4189 {TGSI_OPCODE_SAMPLE_L
, 0, 0, tgsi_unsupported
},
4190 {TGSI_OPCODE_GATHER4
, 0, 0, tgsi_unsupported
},
4191 {TGSI_OPCODE_RESINFO
, 0, 0, tgsi_unsupported
},
4192 {TGSI_OPCODE_SAMPLE_POS
, 0, 0, tgsi_unsupported
},
4193 {TGSI_OPCODE_SAMPLE_INFO
, 0, 0, tgsi_unsupported
},
4194 {TGSI_OPCODE_UARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
, tgsi_r600_arl
},
4195 {TGSI_OPCODE_UCMP
, 0, 0, tgsi_unsupported
},
4196 {TGSI_OPCODE_IABS
, 0, 0, tgsi_iabs
},
4197 {TGSI_OPCODE_ISSG
, 0, 0, tgsi_issg
},
4198 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4201 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
4202 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
4203 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
4204 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
4205 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
4206 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_rsq
},
4207 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
4208 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
4209 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
4210 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
4211 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4212 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4213 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
4214 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
4215 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
4216 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
4217 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
4218 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
4219 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
4220 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
4221 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4223 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4224 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4226 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4227 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4228 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
4229 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4230 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
4231 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE
, tgsi_op2
},
4232 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
4233 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
4234 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
4235 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
4237 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4238 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
4239 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4240 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4241 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
4242 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
4243 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
4244 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
4245 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4246 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4247 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4248 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4249 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4250 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
4251 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4252 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
4253 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
4254 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
4255 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
4256 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4257 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
4258 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
4259 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
4260 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4261 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4262 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4263 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4264 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4265 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4266 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
4267 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4268 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4269 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4270 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
4271 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
4272 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
4273 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
4274 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4275 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4276 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4277 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
4278 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
4279 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
4281 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4282 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4283 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
4284 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
4286 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4287 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4288 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4289 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4290 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4291 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
, tgsi_op2_trans
},
4292 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT
, tgsi_op2
},
4293 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
4294 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT
, tgsi_op2
},
4296 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4297 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT
, tgsi_op2
},
4298 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT
, tgsi_op2
},
4299 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4300 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
, tgsi_op2
},
4301 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4302 {TGSI_OPCODE_TXF
, 0, SQ_TEX_INST_LD
, tgsi_tex
},
4303 {TGSI_OPCODE_TXQ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
4304 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
4305 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4306 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4307 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
4308 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4309 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
4310 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4312 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4313 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4314 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4315 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4316 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4318 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4319 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4320 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4321 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4322 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4323 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4324 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4325 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4326 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
4327 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
4329 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4330 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
, tgsi_f2i
},
4331 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_idiv
},
4332 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT
, tgsi_op2
},
4333 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT
, tgsi_op2
},
4334 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT
, tgsi_ineg
},
4335 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT
, tgsi_op2
},
4336 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT
, tgsi_op2
},
4337 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
, tgsi_op2_swap
},
4338 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT
, tgsi_f2i
},
4339 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT
, tgsi_op2
},
4340 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
, tgsi_op2
},
4341 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_idiv
},
4342 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_umad
},
4343 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT
, tgsi_op2
},
4344 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT
, tgsi_op2
},
4345 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4346 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT
, tgsi_op2_trans
},
4347 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT
, tgsi_op2
},
4348 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT
, tgsi_op2
},
4349 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT
, tgsi_op2
},
4350 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT
, tgsi_op2_swap
},
4351 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT
, tgsi_op2
},
4352 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4353 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4354 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4355 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4356 {TGSI_OPCODE_LOAD
, 0, 0, tgsi_unsupported
},
4357 {TGSI_OPCODE_LOAD_MS
, 0, 0, tgsi_unsupported
},
4358 {TGSI_OPCODE_SAMPLE
, 0, 0, tgsi_unsupported
},
4359 {TGSI_OPCODE_SAMPLE_B
, 0, 0, tgsi_unsupported
},
4360 {TGSI_OPCODE_SAMPLE_C
, 0, 0, tgsi_unsupported
},
4361 {TGSI_OPCODE_SAMPLE_C_LZ
, 0, 0, tgsi_unsupported
},
4362 {TGSI_OPCODE_SAMPLE_D
, 0, 0, tgsi_unsupported
},
4363 {TGSI_OPCODE_SAMPLE_L
, 0, 0, tgsi_unsupported
},
4364 {TGSI_OPCODE_GATHER4
, 0, 0, tgsi_unsupported
},
4365 {TGSI_OPCODE_RESINFO
, 0, 0, tgsi_unsupported
},
4366 {TGSI_OPCODE_SAMPLE_POS
, 0, 0, tgsi_unsupported
},
4367 {TGSI_OPCODE_SAMPLE_INFO
, 0, 0, tgsi_unsupported
},
4368 {TGSI_OPCODE_UARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
, tgsi_eg_arl
},
4369 {TGSI_OPCODE_UCMP
, 0, 0, tgsi_unsupported
},
4370 {TGSI_OPCODE_IABS
, 0, 0, tgsi_iabs
},
4371 {TGSI_OPCODE_ISSG
, 0, 0, tgsi_issg
},
4372 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4375 static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction
[] = {
4376 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
4377 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
4378 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
4379 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, cayman_emit_float_instr
},
4380 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, cayman_emit_float_instr
},
4381 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
4382 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
4383 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
4384 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
4385 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4386 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4387 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
4388 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
4389 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
4390 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
4391 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
4392 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
4393 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
4394 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
4395 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4397 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4398 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4400 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4401 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4402 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
4403 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4404 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
4405 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE
, tgsi_op2
},
4406 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, cayman_emit_float_instr
},
4407 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, cayman_emit_float_instr
},
4408 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, cayman_pow
},
4409 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
4411 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4412 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
4413 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4414 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4415 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, cayman_trig
},
4416 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
4417 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
4418 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
4419 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4420 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4421 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4422 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4423 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4424 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
4425 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4426 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
4427 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, cayman_trig
},
4428 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
4429 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
4430 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4431 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
4432 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
4433 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
4434 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4435 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4436 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4437 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4438 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4439 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4440 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
4441 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4442 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4443 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4444 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
4445 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
4446 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
4447 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_LB
, tgsi_tex
},
4448 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4449 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4450 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
4451 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
4452 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
4453 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
4455 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4456 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4457 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
4458 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
4460 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4461 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4462 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4463 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4464 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4465 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4466 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT
, tgsi_op2
},
4467 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
4468 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4470 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4471 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4472 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4473 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4474 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT
, tgsi_op2
},
4475 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4476 {TGSI_OPCODE_TXF
, 0, SQ_TEX_INST_LD
, tgsi_tex
},
4477 {TGSI_OPCODE_TXQ
, 0, SQ_TEX_INST_GET_TEXTURE_RESINFO
, tgsi_tex
},
4478 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
4479 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4480 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4481 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
4482 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4483 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
4484 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4486 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4487 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4488 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4489 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4490 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4492 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4493 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4494 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4495 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4496 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4497 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4498 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4499 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4500 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
4501 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
4503 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4504 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4505 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4506 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT
, tgsi_op2
},
4507 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT
, tgsi_op2
},
4508 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4509 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4510 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4511 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4512 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4513 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4514 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4515 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4516 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4517 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4518 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4519 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4520 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4521 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4522 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4523 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4524 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4525 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4526 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4527 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4528 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4529 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
4530 {TGSI_OPCODE_LOAD
, 0, 0, tgsi_unsupported
},
4531 {TGSI_OPCODE_LOAD_MS
, 0, 0, tgsi_unsupported
},
4532 {TGSI_OPCODE_SAMPLE
, 0, 0, tgsi_unsupported
},
4533 {TGSI_OPCODE_SAMPLE_B
, 0, 0, tgsi_unsupported
},
4534 {TGSI_OPCODE_SAMPLE_C
, 0, 0, tgsi_unsupported
},
4535 {TGSI_OPCODE_SAMPLE_C_LZ
, 0, 0, tgsi_unsupported
},
4536 {TGSI_OPCODE_SAMPLE_D
, 0, 0, tgsi_unsupported
},
4537 {TGSI_OPCODE_SAMPLE_L
, 0, 0, tgsi_unsupported
},
4538 {TGSI_OPCODE_GATHER4
, 0, 0, tgsi_unsupported
},
4539 {TGSI_OPCODE_RESINFO
, 0, 0, tgsi_unsupported
},
4540 {TGSI_OPCODE_SAMPLE_POS
, 0, 0, tgsi_unsupported
},
4541 {TGSI_OPCODE_SAMPLE_INFO
, 0, 0, tgsi_unsupported
},
4542 {TGSI_OPCODE_UARL
, 0, 0, tgsi_unsupported
},
4543 {TGSI_OPCODE_UCMP
, 0, 0, tgsi_unsupported
},
4544 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},