1 /**************************************************************************
3 * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 * TGSI interpreter/executor.
31 * Flow control information:
33 * Since we operate on 'quads' (4 pixels or 4 vertices in parallel)
34 * flow control statements (IF/ELSE/ENDIF, LOOP/ENDLOOP) require special
35 * care since a condition may be true for some quad components but false
36 * for other components.
38 * We basically execute all statements (even if they're in the part of
39 * an IF/ELSE clause that's "not taken") and use a special mask to
40 * control writing to destination registers. This is the ExecMask.
43 * The ExecMask is computed from three other masks (CondMask, LoopMask and
44 * ContMask) which are controlled by the flow control instructions (namely:
45 * (IF/ELSE/ENDIF, LOOP/ENDLOOP and CONT).
53 #include "pipe/p_compiler.h"
54 #include "pipe/p_state.h"
55 #include "pipe/p_shader_tokens.h"
56 #include "tgsi/tgsi_dump.h"
57 #include "tgsi/tgsi_parse.h"
58 #include "tgsi/tgsi_util.h"
59 #include "tgsi_exec.h"
60 #include "util/u_memory.h"
61 #include "util/u_math.h"
65 /** for tgsi_full_instruction::Flags */
66 #define SOA_DEPENDENCY_FLAG 0x1
68 #define TILE_TOP_LEFT 0
69 #define TILE_TOP_RIGHT 1
70 #define TILE_BOTTOM_LEFT 2
71 #define TILE_BOTTOM_RIGHT 3
79 * Shorthand locations of various utility registers (_I = Index, _C = Channel)
81 #define TEMP_0_I TGSI_EXEC_TEMP_00000000_I
82 #define TEMP_0_C TGSI_EXEC_TEMP_00000000_C
83 #define TEMP_7F_I TGSI_EXEC_TEMP_7FFFFFFF_I
84 #define TEMP_7F_C TGSI_EXEC_TEMP_7FFFFFFF_C
85 #define TEMP_80_I TGSI_EXEC_TEMP_80000000_I
86 #define TEMP_80_C TGSI_EXEC_TEMP_80000000_C
87 #define TEMP_FF_I TGSI_EXEC_TEMP_FFFFFFFF_I
88 #define TEMP_FF_C TGSI_EXEC_TEMP_FFFFFFFF_C
89 #define TEMP_1_I TGSI_EXEC_TEMP_ONE_I
90 #define TEMP_1_C TGSI_EXEC_TEMP_ONE_C
91 #define TEMP_2_I TGSI_EXEC_TEMP_TWO_I
92 #define TEMP_2_C TGSI_EXEC_TEMP_TWO_C
93 #define TEMP_128_I TGSI_EXEC_TEMP_128_I
94 #define TEMP_128_C TGSI_EXEC_TEMP_128_C
95 #define TEMP_M128_I TGSI_EXEC_TEMP_MINUS_128_I
96 #define TEMP_M128_C TGSI_EXEC_TEMP_MINUS_128_C
97 #define TEMP_KILMASK_I TGSI_EXEC_TEMP_KILMASK_I
98 #define TEMP_KILMASK_C TGSI_EXEC_TEMP_KILMASK_C
99 #define TEMP_OUTPUT_I TGSI_EXEC_TEMP_OUTPUT_I
100 #define TEMP_OUTPUT_C TGSI_EXEC_TEMP_OUTPUT_C
101 #define TEMP_PRIMITIVE_I TGSI_EXEC_TEMP_PRIMITIVE_I
102 #define TEMP_PRIMITIVE_C TGSI_EXEC_TEMP_PRIMITIVE_C
103 #define TEMP_CC_I TGSI_EXEC_TEMP_CC_I
104 #define TEMP_CC_C TGSI_EXEC_TEMP_CC_C
105 #define TEMP_3_I TGSI_EXEC_TEMP_THREE_I
106 #define TEMP_3_C TGSI_EXEC_TEMP_THREE_C
107 #define TEMP_HALF_I TGSI_EXEC_TEMP_HALF_I
108 #define TEMP_HALF_C TGSI_EXEC_TEMP_HALF_C
109 #define TEMP_R0 TGSI_EXEC_TEMP_R0
111 #define IS_CHANNEL_ENABLED(INST, CHAN)\
112 ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
114 #define IS_CHANNEL_ENABLED2(INST, CHAN)\
115 ((INST).FullDstRegisters[1].DstRegister.WriteMask & (1 << (CHAN)))
117 #define FOR_EACH_ENABLED_CHANNEL(INST, CHAN)\
118 for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)\
119 if (IS_CHANNEL_ENABLED( INST, CHAN ))
121 #define FOR_EACH_ENABLED_CHANNEL2(INST, CHAN)\
122 for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)\
123 if (IS_CHANNEL_ENABLED2( INST, CHAN ))
126 /** The execution mask depends on the conditional mask and the loop mask */
127 #define UPDATE_EXEC_MASK(MACH) \
128 MACH->ExecMask = MACH->CondMask & MACH->LoopMask & MACH->ContMask & MACH->FuncMask
131 static const union tgsi_exec_channel ZeroVec
=
132 { { 0.0, 0.0, 0.0, 0.0 } };
137 check_inf_or_nan(const union tgsi_exec_channel
*chan
)
139 assert(!util_is_inf_or_nan(chan
->f
[0]));
140 assert(!util_is_inf_or_nan(chan
->f
[1]));
141 assert(!util_is_inf_or_nan(chan
->f
[2]));
142 assert(!util_is_inf_or_nan(chan
->f
[3]));
149 print_chan(const char *msg
, const union tgsi_exec_channel
*chan
)
151 debug_printf("%s = {%f, %f, %f, %f}\n",
152 msg
, chan
->f
[0], chan
->f
[1], chan
->f
[2], chan
->f
[3]);
159 print_temp(const struct tgsi_exec_machine
*mach
, uint index
)
161 const struct tgsi_exec_vector
*tmp
= &mach
->Temps
[index
];
163 debug_printf("Temp[%u] =\n", index
);
164 for (i
= 0; i
< 4; i
++) {
165 debug_printf(" %c: { %f, %f, %f, %f }\n",
177 * Check if there's a potential src/dst register data dependency when
178 * using SOA execution.
181 * This would expand into:
186 * The second instruction will have the wrong value for t0 if executed as-is.
189 tgsi_check_soa_dependencies(const struct tgsi_full_instruction
*inst
)
193 uint writemask
= inst
->FullDstRegisters
[0].DstRegister
.WriteMask
;
194 if (writemask
== TGSI_WRITEMASK_X
||
195 writemask
== TGSI_WRITEMASK_Y
||
196 writemask
== TGSI_WRITEMASK_Z
||
197 writemask
== TGSI_WRITEMASK_W
||
198 writemask
== TGSI_WRITEMASK_NONE
) {
199 /* no chance of data dependency */
203 /* loop over src regs */
204 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
205 if ((inst
->FullSrcRegisters
[i
].SrcRegister
.File
==
206 inst
->FullDstRegisters
[0].DstRegister
.File
) &&
207 (inst
->FullSrcRegisters
[i
].SrcRegister
.Index
==
208 inst
->FullDstRegisters
[0].DstRegister
.Index
)) {
209 /* loop over dest channels */
210 uint channelsWritten
= 0x0;
211 FOR_EACH_ENABLED_CHANNEL(*inst
, chan
) {
212 /* check if we're reading a channel that's been written */
213 uint swizzle
= tgsi_util_get_full_src_register_extswizzle(&inst
->FullSrcRegisters
[i
], chan
);
214 if (swizzle
<= TGSI_SWIZZLE_W
&&
215 (channelsWritten
& (1 << swizzle
))) {
219 channelsWritten
|= (1 << chan
);
228 * Initialize machine state by expanding tokens to full instructions,
229 * allocating temporary storage, setting up constants, etc.
230 * After this, we can call tgsi_exec_machine_run() many times.
233 tgsi_exec_machine_bind_shader(
234 struct tgsi_exec_machine
*mach
,
235 const struct tgsi_token
*tokens
,
237 struct tgsi_sampler
**samplers
)
240 struct tgsi_parse_context parse
;
241 struct tgsi_exec_labels
*labels
= &mach
->Labels
;
242 struct tgsi_full_instruction
*instructions
;
243 struct tgsi_full_declaration
*declarations
;
244 uint maxInstructions
= 10, numInstructions
= 0;
245 uint maxDeclarations
= 10, numDeclarations
= 0;
249 tgsi_dump(tokens
, 0);
254 mach
->Tokens
= tokens
;
255 mach
->Samplers
= samplers
;
257 k
= tgsi_parse_init (&parse
, mach
->Tokens
);
258 if (k
!= TGSI_PARSE_OK
) {
259 debug_printf( "Problem parsing!\n" );
263 mach
->Processor
= parse
.FullHeader
.Processor
.Processor
;
267 declarations
= (struct tgsi_full_declaration
*)
268 MALLOC( maxDeclarations
* sizeof(struct tgsi_full_declaration
) );
274 instructions
= (struct tgsi_full_instruction
*)
275 MALLOC( maxInstructions
* sizeof(struct tgsi_full_instruction
) );
278 FREE( declarations
);
282 while( !tgsi_parse_end_of_tokens( &parse
) ) {
283 uint pointer
= parse
.Position
;
286 tgsi_parse_token( &parse
);
287 switch( parse
.FullToken
.Token
.Type
) {
288 case TGSI_TOKEN_TYPE_DECLARATION
:
289 /* save expanded declaration */
290 if (numDeclarations
== maxDeclarations
) {
291 declarations
= REALLOC(declarations
,
293 * sizeof(struct tgsi_full_declaration
),
294 (maxDeclarations
+ 10)
295 * sizeof(struct tgsi_full_declaration
));
296 maxDeclarations
+= 10;
298 memcpy(declarations
+ numDeclarations
,
299 &parse
.FullToken
.FullDeclaration
,
300 sizeof(declarations
[0]));
304 case TGSI_TOKEN_TYPE_IMMEDIATE
:
306 uint size
= parse
.FullToken
.FullImmediate
.Immediate
.NrTokens
- 1;
308 assert( mach
->ImmLimit
+ 1 <= TGSI_EXEC_NUM_IMMEDIATES
);
310 for( i
= 0; i
< size
; i
++ ) {
311 mach
->Imms
[mach
->ImmLimit
][i
] =
312 parse
.FullToken
.FullImmediate
.u
[i
].Float
;
318 case TGSI_TOKEN_TYPE_INSTRUCTION
:
319 assert( labels
->count
< MAX_LABELS
);
321 labels
->labels
[labels
->count
][0] = instno
;
322 labels
->labels
[labels
->count
][1] = pointer
;
325 /* save expanded instruction */
326 if (numInstructions
== maxInstructions
) {
327 instructions
= REALLOC(instructions
,
329 * sizeof(struct tgsi_full_instruction
),
330 (maxInstructions
+ 10)
331 * sizeof(struct tgsi_full_instruction
));
332 maxInstructions
+= 10;
335 if (tgsi_check_soa_dependencies(&parse
.FullToken
.FullInstruction
)) {
336 uint opcode
= parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
337 parse
.FullToken
.FullInstruction
.Flags
= SOA_DEPENDENCY_FLAG
;
338 /* XXX we only handle SOA dependencies properly for MOV/SWZ
341 if (opcode
!= TGSI_OPCODE_MOV
&& opcode
!= TGSI_OPCODE_SWZ
) {
342 debug_printf("Warning: SOA dependency in instruction"
343 " is not handled:\n");
344 tgsi_dump_instruction(&parse
.FullToken
.FullInstruction
,
349 memcpy(instructions
+ numInstructions
,
350 &parse
.FullToken
.FullInstruction
,
351 sizeof(instructions
[0]));
360 tgsi_parse_free (&parse
);
362 if (mach
->Declarations
) {
363 FREE( mach
->Declarations
);
365 mach
->Declarations
= declarations
;
366 mach
->NumDeclarations
= numDeclarations
;
368 if (mach
->Instructions
) {
369 FREE( mach
->Instructions
);
371 mach
->Instructions
= instructions
;
372 mach
->NumInstructions
= numInstructions
;
376 struct tgsi_exec_machine
*
377 tgsi_exec_machine_create( void )
379 struct tgsi_exec_machine
*mach
;
382 mach
= align_malloc( sizeof *mach
, 16 );
386 memset(mach
, 0, sizeof(*mach
));
388 mach
->Addrs
= &mach
->Temps
[TGSI_EXEC_TEMP_ADDR
];
390 /* Setup constants. */
391 for( i
= 0; i
< 4; i
++ ) {
392 mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
].u
[i
] = 0x00000000;
393 mach
->Temps
[TEMP_7F_I
].xyzw
[TEMP_7F_C
].u
[i
] = 0x7FFFFFFF;
394 mach
->Temps
[TEMP_80_I
].xyzw
[TEMP_80_C
].u
[i
] = 0x80000000;
395 mach
->Temps
[TEMP_FF_I
].xyzw
[TEMP_FF_C
].u
[i
] = 0xFFFFFFFF;
396 mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
].f
[i
] = 1.0f
;
397 mach
->Temps
[TEMP_2_I
].xyzw
[TEMP_2_C
].f
[i
] = 2.0f
;
398 mach
->Temps
[TEMP_128_I
].xyzw
[TEMP_128_C
].f
[i
] = 128.0f
;
399 mach
->Temps
[TEMP_M128_I
].xyzw
[TEMP_M128_C
].f
[i
] = -128.0f
;
400 mach
->Temps
[TEMP_3_I
].xyzw
[TEMP_3_C
].f
[i
] = 3.0f
;
401 mach
->Temps
[TEMP_HALF_I
].xyzw
[TEMP_HALF_C
].f
[i
] = 0.5f
;
405 /* silence warnings */
419 tgsi_exec_machine_destroy(struct tgsi_exec_machine
*mach
)
422 FREE(mach
->Instructions
);
423 FREE(mach
->Declarations
);
432 union tgsi_exec_channel
*dst
,
433 const union tgsi_exec_channel
*src
)
435 dst
->f
[0] = fabsf( src
->f
[0] );
436 dst
->f
[1] = fabsf( src
->f
[1] );
437 dst
->f
[2] = fabsf( src
->f
[2] );
438 dst
->f
[3] = fabsf( src
->f
[3] );
443 union tgsi_exec_channel
*dst
,
444 const union tgsi_exec_channel
*src0
,
445 const union tgsi_exec_channel
*src1
)
447 dst
->f
[0] = src0
->f
[0] + src1
->f
[0];
448 dst
->f
[1] = src0
->f
[1] + src1
->f
[1];
449 dst
->f
[2] = src0
->f
[2] + src1
->f
[2];
450 dst
->f
[3] = src0
->f
[3] + src1
->f
[3];
456 union tgsi_exec_channel
*dst
,
457 const union tgsi_exec_channel
*src0
,
458 const union tgsi_exec_channel
*src1
)
460 dst
->i
[0] = src0
->i
[0] + src1
->i
[0];
461 dst
->i
[1] = src0
->i
[1] + src1
->i
[1];
462 dst
->i
[2] = src0
->i
[2] + src1
->i
[2];
463 dst
->i
[3] = src0
->i
[3] + src1
->i
[3];
469 union tgsi_exec_channel
*dst
,
470 const union tgsi_exec_channel
*src0
,
471 const union tgsi_exec_channel
*src1
)
473 dst
->u
[0] = src0
->u
[0] & src1
->u
[0];
474 dst
->u
[1] = src0
->u
[1] & src1
->u
[1];
475 dst
->u
[2] = src0
->u
[2] & src1
->u
[2];
476 dst
->u
[3] = src0
->u
[3] & src1
->u
[3];
481 union tgsi_exec_channel
*dst
,
482 const union tgsi_exec_channel
*src
)
484 dst
->f
[0] = ceilf( src
->f
[0] );
485 dst
->f
[1] = ceilf( src
->f
[1] );
486 dst
->f
[2] = ceilf( src
->f
[2] );
487 dst
->f
[3] = ceilf( src
->f
[3] );
492 union tgsi_exec_channel
*dst
,
493 const union tgsi_exec_channel
*src
)
495 dst
->f
[0] = cosf( src
->f
[0] );
496 dst
->f
[1] = cosf( src
->f
[1] );
497 dst
->f
[2] = cosf( src
->f
[2] );
498 dst
->f
[3] = cosf( src
->f
[3] );
503 union tgsi_exec_channel
*dst
,
504 const union tgsi_exec_channel
*src
)
509 dst
->f
[3] = src
->f
[TILE_BOTTOM_RIGHT
] - src
->f
[TILE_BOTTOM_LEFT
];
514 union tgsi_exec_channel
*dst
,
515 const union tgsi_exec_channel
*src
)
520 dst
->f
[3] = src
->f
[TILE_TOP_LEFT
] - src
->f
[TILE_BOTTOM_LEFT
];
525 union tgsi_exec_channel
*dst
,
526 const union tgsi_exec_channel
*src0
,
527 const union tgsi_exec_channel
*src1
)
529 if (src1
->f
[0] != 0) {
530 dst
->f
[0] = src0
->f
[0] / src1
->f
[0];
532 if (src1
->f
[1] != 0) {
533 dst
->f
[1] = src0
->f
[1] / src1
->f
[1];
535 if (src1
->f
[2] != 0) {
536 dst
->f
[2] = src0
->f
[2] / src1
->f
[2];
538 if (src1
->f
[3] != 0) {
539 dst
->f
[3] = src0
->f
[3] / src1
->f
[3];
546 union tgsi_exec_channel
*dst
,
547 const union tgsi_exec_channel
*src0
,
548 const union tgsi_exec_channel
*src1
)
550 dst
->u
[0] = src0
->u
[0] / src1
->u
[0];
551 dst
->u
[1] = src0
->u
[1] / src1
->u
[1];
552 dst
->u
[2] = src0
->u
[2] / src1
->u
[2];
553 dst
->u
[3] = src0
->u
[3] / src1
->u
[3];
559 union tgsi_exec_channel
*dst
,
560 const union tgsi_exec_channel
*src0
,
561 const union tgsi_exec_channel
*src1
,
562 const union tgsi_exec_channel
*src2
,
563 const union tgsi_exec_channel
*src3
)
565 dst
->f
[0] = src0
->f
[0] == src1
->f
[0] ? src2
->f
[0] : src3
->f
[0];
566 dst
->f
[1] = src0
->f
[1] == src1
->f
[1] ? src2
->f
[1] : src3
->f
[1];
567 dst
->f
[2] = src0
->f
[2] == src1
->f
[2] ? src2
->f
[2] : src3
->f
[2];
568 dst
->f
[3] = src0
->f
[3] == src1
->f
[3] ? src2
->f
[3] : src3
->f
[3];
574 union tgsi_exec_channel
*dst
,
575 const union tgsi_exec_channel
*src0
,
576 const union tgsi_exec_channel
*src1
,
577 const union tgsi_exec_channel
*src2
,
578 const union tgsi_exec_channel
*src3
)
580 dst
->i
[0] = src0
->i
[0] == src1
->i
[0] ? src2
->i
[0] : src3
->i
[0];
581 dst
->i
[1] = src0
->i
[1] == src1
->i
[1] ? src2
->i
[1] : src3
->i
[1];
582 dst
->i
[2] = src0
->i
[2] == src1
->i
[2] ? src2
->i
[2] : src3
->i
[2];
583 dst
->i
[3] = src0
->i
[3] == src1
->i
[3] ? src2
->i
[3] : src3
->i
[3];
589 union tgsi_exec_channel
*dst
,
590 const union tgsi_exec_channel
*src
)
593 dst
->f
[0] = util_fast_exp2( src
->f
[0] );
594 dst
->f
[1] = util_fast_exp2( src
->f
[1] );
595 dst
->f
[2] = util_fast_exp2( src
->f
[2] );
596 dst
->f
[3] = util_fast_exp2( src
->f
[3] );
598 dst
->f
[0] = powf( 2.0f
, src
->f
[0] );
599 dst
->f
[1] = powf( 2.0f
, src
->f
[1] );
600 dst
->f
[2] = powf( 2.0f
, src
->f
[2] );
601 dst
->f
[3] = powf( 2.0f
, src
->f
[3] );
608 union tgsi_exec_channel
*dst
,
609 const union tgsi_exec_channel
*src
)
611 dst
->u
[0] = (uint
) src
->f
[0];
612 dst
->u
[1] = (uint
) src
->f
[1];
613 dst
->u
[2] = (uint
) src
->f
[2];
614 dst
->u
[3] = (uint
) src
->f
[3];
619 micro_float_clamp(union tgsi_exec_channel
*dst
,
620 const union tgsi_exec_channel
*src
)
624 for (i
= 0; i
< 4; i
++) {
625 if (src
->f
[i
] > 0.0f
) {
626 if (src
->f
[i
] > 1.884467e+019f
)
627 dst
->f
[i
] = 1.884467e+019f
;
628 else if (src
->f
[i
] < 5.42101e-020f
)
629 dst
->f
[i
] = 5.42101e-020f
;
631 dst
->f
[i
] = src
->f
[i
];
634 if (src
->f
[i
] < -1.884467e+019f
)
635 dst
->f
[i
] = -1.884467e+019f
;
636 else if (src
->f
[i
] > -5.42101e-020f
)
637 dst
->f
[i
] = -5.42101e-020f
;
639 dst
->f
[i
] = src
->f
[i
];
646 union tgsi_exec_channel
*dst
,
647 const union tgsi_exec_channel
*src
)
649 dst
->f
[0] = floorf( src
->f
[0] );
650 dst
->f
[1] = floorf( src
->f
[1] );
651 dst
->f
[2] = floorf( src
->f
[2] );
652 dst
->f
[3] = floorf( src
->f
[3] );
657 union tgsi_exec_channel
*dst
,
658 const union tgsi_exec_channel
*src
)
660 dst
->f
[0] = src
->f
[0] - floorf( src
->f
[0] );
661 dst
->f
[1] = src
->f
[1] - floorf( src
->f
[1] );
662 dst
->f
[2] = src
->f
[2] - floorf( src
->f
[2] );
663 dst
->f
[3] = src
->f
[3] - floorf( src
->f
[3] );
668 union tgsi_exec_channel
*dst
,
669 const union tgsi_exec_channel
*src
)
671 dst
->f
[0] = (float) src
->i
[0];
672 dst
->f
[1] = (float) src
->i
[1];
673 dst
->f
[2] = (float) src
->i
[2];
674 dst
->f
[3] = (float) src
->i
[3];
679 union tgsi_exec_channel
*dst
,
680 const union tgsi_exec_channel
*src
)
683 dst
->f
[0] = util_fast_log2( src
->f
[0] );
684 dst
->f
[1] = util_fast_log2( src
->f
[1] );
685 dst
->f
[2] = util_fast_log2( src
->f
[2] );
686 dst
->f
[3] = util_fast_log2( src
->f
[3] );
688 dst
->f
[0] = logf( src
->f
[0] ) * 1.442695f
;
689 dst
->f
[1] = logf( src
->f
[1] ) * 1.442695f
;
690 dst
->f
[2] = logf( src
->f
[2] ) * 1.442695f
;
691 dst
->f
[3] = logf( src
->f
[3] ) * 1.442695f
;
697 union tgsi_exec_channel
*dst
,
698 const union tgsi_exec_channel
*src0
,
699 const union tgsi_exec_channel
*src1
,
700 const union tgsi_exec_channel
*src2
,
701 const union tgsi_exec_channel
*src3
)
703 dst
->f
[0] = src0
->f
[0] <= src1
->f
[0] ? src2
->f
[0] : src3
->f
[0];
704 dst
->f
[1] = src0
->f
[1] <= src1
->f
[1] ? src2
->f
[1] : src3
->f
[1];
705 dst
->f
[2] = src0
->f
[2] <= src1
->f
[2] ? src2
->f
[2] : src3
->f
[2];
706 dst
->f
[3] = src0
->f
[3] <= src1
->f
[3] ? src2
->f
[3] : src3
->f
[3];
711 union tgsi_exec_channel
*dst
,
712 const union tgsi_exec_channel
*src0
,
713 const union tgsi_exec_channel
*src1
,
714 const union tgsi_exec_channel
*src2
,
715 const union tgsi_exec_channel
*src3
)
717 dst
->f
[0] = src0
->f
[0] < src1
->f
[0] ? src2
->f
[0] : src3
->f
[0];
718 dst
->f
[1] = src0
->f
[1] < src1
->f
[1] ? src2
->f
[1] : src3
->f
[1];
719 dst
->f
[2] = src0
->f
[2] < src1
->f
[2] ? src2
->f
[2] : src3
->f
[2];
720 dst
->f
[3] = src0
->f
[3] < src1
->f
[3] ? src2
->f
[3] : src3
->f
[3];
726 union tgsi_exec_channel
*dst
,
727 const union tgsi_exec_channel
*src0
,
728 const union tgsi_exec_channel
*src1
,
729 const union tgsi_exec_channel
*src2
,
730 const union tgsi_exec_channel
*src3
)
732 dst
->i
[0] = src0
->i
[0] < src1
->i
[0] ? src2
->i
[0] : src3
->i
[0];
733 dst
->i
[1] = src0
->i
[1] < src1
->i
[1] ? src2
->i
[1] : src3
->i
[1];
734 dst
->i
[2] = src0
->i
[2] < src1
->i
[2] ? src2
->i
[2] : src3
->i
[2];
735 dst
->i
[3] = src0
->i
[3] < src1
->i
[3] ? src2
->i
[3] : src3
->i
[3];
742 union tgsi_exec_channel
*dst
,
743 const union tgsi_exec_channel
*src0
,
744 const union tgsi_exec_channel
*src1
,
745 const union tgsi_exec_channel
*src2
,
746 const union tgsi_exec_channel
*src3
)
748 dst
->u
[0] = src0
->u
[0] < src1
->u
[0] ? src2
->u
[0] : src3
->u
[0];
749 dst
->u
[1] = src0
->u
[1] < src1
->u
[1] ? src2
->u
[1] : src3
->u
[1];
750 dst
->u
[2] = src0
->u
[2] < src1
->u
[2] ? src2
->u
[2] : src3
->u
[2];
751 dst
->u
[3] = src0
->u
[3] < src1
->u
[3] ? src2
->u
[3] : src3
->u
[3];
757 union tgsi_exec_channel
*dst
,
758 const union tgsi_exec_channel
*src0
,
759 const union tgsi_exec_channel
*src1
)
761 dst
->f
[0] = src0
->f
[0] > src1
->f
[0] ? src0
->f
[0] : src1
->f
[0];
762 dst
->f
[1] = src0
->f
[1] > src1
->f
[1] ? src0
->f
[1] : src1
->f
[1];
763 dst
->f
[2] = src0
->f
[2] > src1
->f
[2] ? src0
->f
[2] : src1
->f
[2];
764 dst
->f
[3] = src0
->f
[3] > src1
->f
[3] ? src0
->f
[3] : src1
->f
[3];
770 union tgsi_exec_channel
*dst
,
771 const union tgsi_exec_channel
*src0
,
772 const union tgsi_exec_channel
*src1
)
774 dst
->i
[0] = src0
->i
[0] > src1
->i
[0] ? src0
->i
[0] : src1
->i
[0];
775 dst
->i
[1] = src0
->i
[1] > src1
->i
[1] ? src0
->i
[1] : src1
->i
[1];
776 dst
->i
[2] = src0
->i
[2] > src1
->i
[2] ? src0
->i
[2] : src1
->i
[2];
777 dst
->i
[3] = src0
->i
[3] > src1
->i
[3] ? src0
->i
[3] : src1
->i
[3];
784 union tgsi_exec_channel
*dst
,
785 const union tgsi_exec_channel
*src0
,
786 const union tgsi_exec_channel
*src1
)
788 dst
->u
[0] = src0
->u
[0] > src1
->u
[0] ? src0
->u
[0] : src1
->u
[0];
789 dst
->u
[1] = src0
->u
[1] > src1
->u
[1] ? src0
->u
[1] : src1
->u
[1];
790 dst
->u
[2] = src0
->u
[2] > src1
->u
[2] ? src0
->u
[2] : src1
->u
[2];
791 dst
->u
[3] = src0
->u
[3] > src1
->u
[3] ? src0
->u
[3] : src1
->u
[3];
797 union tgsi_exec_channel
*dst
,
798 const union tgsi_exec_channel
*src0
,
799 const union tgsi_exec_channel
*src1
)
801 dst
->f
[0] = src0
->f
[0] < src1
->f
[0] ? src0
->f
[0] : src1
->f
[0];
802 dst
->f
[1] = src0
->f
[1] < src1
->f
[1] ? src0
->f
[1] : src1
->f
[1];
803 dst
->f
[2] = src0
->f
[2] < src1
->f
[2] ? src0
->f
[2] : src1
->f
[2];
804 dst
->f
[3] = src0
->f
[3] < src1
->f
[3] ? src0
->f
[3] : src1
->f
[3];
810 union tgsi_exec_channel
*dst
,
811 const union tgsi_exec_channel
*src0
,
812 const union tgsi_exec_channel
*src1
)
814 dst
->i
[0] = src0
->i
[0] < src1
->i
[0] ? src0
->i
[0] : src1
->i
[0];
815 dst
->i
[1] = src0
->i
[1] < src1
->i
[1] ? src0
->i
[1] : src1
->i
[1];
816 dst
->i
[2] = src0
->i
[2] < src1
->i
[2] ? src0
->i
[2] : src1
->i
[2];
817 dst
->i
[3] = src0
->i
[3] < src1
->i
[3] ? src0
->i
[3] : src1
->i
[3];
824 union tgsi_exec_channel
*dst
,
825 const union tgsi_exec_channel
*src0
,
826 const union tgsi_exec_channel
*src1
)
828 dst
->u
[0] = src0
->u
[0] < src1
->u
[0] ? src0
->u
[0] : src1
->u
[0];
829 dst
->u
[1] = src0
->u
[1] < src1
->u
[1] ? src0
->u
[1] : src1
->u
[1];
830 dst
->u
[2] = src0
->u
[2] < src1
->u
[2] ? src0
->u
[2] : src1
->u
[2];
831 dst
->u
[3] = src0
->u
[3] < src1
->u
[3] ? src0
->u
[3] : src1
->u
[3];
838 union tgsi_exec_channel
*dst
,
839 const union tgsi_exec_channel
*src0
,
840 const union tgsi_exec_channel
*src1
)
842 dst
->u
[0] = src0
->u
[0] % src1
->u
[0];
843 dst
->u
[1] = src0
->u
[1] % src1
->u
[1];
844 dst
->u
[2] = src0
->u
[2] % src1
->u
[2];
845 dst
->u
[3] = src0
->u
[3] % src1
->u
[3];
851 union tgsi_exec_channel
*dst
,
852 const union tgsi_exec_channel
*src0
,
853 const union tgsi_exec_channel
*src1
)
855 dst
->f
[0] = src0
->f
[0] * src1
->f
[0];
856 dst
->f
[1] = src0
->f
[1] * src1
->f
[1];
857 dst
->f
[2] = src0
->f
[2] * src1
->f
[2];
858 dst
->f
[3] = src0
->f
[3] * src1
->f
[3];
864 union tgsi_exec_channel
*dst
,
865 const union tgsi_exec_channel
*src0
,
866 const union tgsi_exec_channel
*src1
)
868 dst
->i
[0] = src0
->i
[0] * src1
->i
[0];
869 dst
->i
[1] = src0
->i
[1] * src1
->i
[1];
870 dst
->i
[2] = src0
->i
[2] * src1
->i
[2];
871 dst
->i
[3] = src0
->i
[3] * src1
->i
[3];
878 union tgsi_exec_channel
*dst0
,
879 union tgsi_exec_channel
*dst1
,
880 const union tgsi_exec_channel
*src0
,
881 const union tgsi_exec_channel
*src1
)
883 dst1
->i
[0] = src0
->i
[0] * src1
->i
[0];
884 dst1
->i
[1] = src0
->i
[1] * src1
->i
[1];
885 dst1
->i
[2] = src0
->i
[2] * src1
->i
[2];
886 dst1
->i
[3] = src0
->i
[3] * src1
->i
[3];
897 union tgsi_exec_channel
*dst0
,
898 union tgsi_exec_channel
*dst1
,
899 const union tgsi_exec_channel
*src0
,
900 const union tgsi_exec_channel
*src1
)
902 dst1
->u
[0] = src0
->u
[0] * src1
->u
[0];
903 dst1
->u
[1] = src0
->u
[1] * src1
->u
[1];
904 dst1
->u
[2] = src0
->u
[2] * src1
->u
[2];
905 dst1
->u
[3] = src0
->u
[3] * src1
->u
[3];
917 union tgsi_exec_channel
*dst
,
918 const union tgsi_exec_channel
*src0
,
919 const union tgsi_exec_channel
*src1
,
920 const union tgsi_exec_channel
*src2
)
922 dst
->u
[0] = src0
->u
[0] ? src1
->u
[0] : src2
->u
[0];
923 dst
->u
[1] = src0
->u
[1] ? src1
->u
[1] : src2
->u
[1];
924 dst
->u
[2] = src0
->u
[2] ? src1
->u
[2] : src2
->u
[2];
925 dst
->u
[3] = src0
->u
[3] ? src1
->u
[3] : src2
->u
[3];
931 union tgsi_exec_channel
*dst
,
932 const union tgsi_exec_channel
*src
)
934 dst
->f
[0] = -src
->f
[0];
935 dst
->f
[1] = -src
->f
[1];
936 dst
->f
[2] = -src
->f
[2];
937 dst
->f
[3] = -src
->f
[3];
943 union tgsi_exec_channel
*dst
,
944 const union tgsi_exec_channel
*src
)
946 dst
->i
[0] = -src
->i
[0];
947 dst
->i
[1] = -src
->i
[1];
948 dst
->i
[2] = -src
->i
[2];
949 dst
->i
[3] = -src
->i
[3];
955 union tgsi_exec_channel
*dst
,
956 const union tgsi_exec_channel
*src
)
958 dst
->u
[0] = ~src
->u
[0];
959 dst
->u
[1] = ~src
->u
[1];
960 dst
->u
[2] = ~src
->u
[2];
961 dst
->u
[3] = ~src
->u
[3];
966 union tgsi_exec_channel
*dst
,
967 const union tgsi_exec_channel
*src0
,
968 const union tgsi_exec_channel
*src1
)
970 dst
->u
[0] = src0
->u
[0] | src1
->u
[0];
971 dst
->u
[1] = src0
->u
[1] | src1
->u
[1];
972 dst
->u
[2] = src0
->u
[2] | src1
->u
[2];
973 dst
->u
[3] = src0
->u
[3] | src1
->u
[3];
978 union tgsi_exec_channel
*dst
,
979 const union tgsi_exec_channel
*src0
,
980 const union tgsi_exec_channel
*src1
)
983 dst
->f
[0] = util_fast_pow( src0
->f
[0], src1
->f
[0] );
984 dst
->f
[1] = util_fast_pow( src0
->f
[1], src1
->f
[1] );
985 dst
->f
[2] = util_fast_pow( src0
->f
[2], src1
->f
[2] );
986 dst
->f
[3] = util_fast_pow( src0
->f
[3], src1
->f
[3] );
988 dst
->f
[0] = powf( src0
->f
[0], src1
->f
[0] );
989 dst
->f
[1] = powf( src0
->f
[1], src1
->f
[1] );
990 dst
->f
[2] = powf( src0
->f
[2], src1
->f
[2] );
991 dst
->f
[3] = powf( src0
->f
[3], src1
->f
[3] );
997 union tgsi_exec_channel
*dst
,
998 const union tgsi_exec_channel
*src
)
1000 dst
->f
[0] = floorf( src
->f
[0] + 0.5f
);
1001 dst
->f
[1] = floorf( src
->f
[1] + 0.5f
);
1002 dst
->f
[2] = floorf( src
->f
[2] + 0.5f
);
1003 dst
->f
[3] = floorf( src
->f
[3] + 0.5f
);
1008 union tgsi_exec_channel
*dst
,
1009 const union tgsi_exec_channel
*src
)
1011 dst
->f
[0] = src
->f
[0] < 0.0f
? -1.0f
: src
->f
[0] > 0.0f
? 1.0f
: 0.0f
;
1012 dst
->f
[1] = src
->f
[1] < 0.0f
? -1.0f
: src
->f
[1] > 0.0f
? 1.0f
: 0.0f
;
1013 dst
->f
[2] = src
->f
[2] < 0.0f
? -1.0f
: src
->f
[2] > 0.0f
? 1.0f
: 0.0f
;
1014 dst
->f
[3] = src
->f
[3] < 0.0f
? -1.0f
: src
->f
[3] > 0.0f
? 1.0f
: 0.0f
;
1019 union tgsi_exec_channel
*dst
,
1020 const union tgsi_exec_channel
*src0
,
1021 const union tgsi_exec_channel
*src1
)
1023 dst
->i
[0] = src0
->i
[0] << src1
->i
[0];
1024 dst
->i
[1] = src0
->i
[1] << src1
->i
[1];
1025 dst
->i
[2] = src0
->i
[2] << src1
->i
[2];
1026 dst
->i
[3] = src0
->i
[3] << src1
->i
[3];
1031 union tgsi_exec_channel
*dst
,
1032 const union tgsi_exec_channel
*src0
,
1033 const union tgsi_exec_channel
*src1
)
1035 dst
->i
[0] = src0
->i
[0] >> src1
->i
[0];
1036 dst
->i
[1] = src0
->i
[1] >> src1
->i
[1];
1037 dst
->i
[2] = src0
->i
[2] >> src1
->i
[2];
1038 dst
->i
[3] = src0
->i
[3] >> src1
->i
[3];
1043 union tgsi_exec_channel
*dst
,
1044 const union tgsi_exec_channel
*src0
)
1046 dst
->f
[0] = (float) (int) src0
->f
[0];
1047 dst
->f
[1] = (float) (int) src0
->f
[1];
1048 dst
->f
[2] = (float) (int) src0
->f
[2];
1049 dst
->f
[3] = (float) (int) src0
->f
[3];
1055 union tgsi_exec_channel
*dst
,
1056 const union tgsi_exec_channel
*src0
,
1057 const union tgsi_exec_channel
*src1
)
1059 dst
->u
[0] = src0
->u
[0] >> src1
->u
[0];
1060 dst
->u
[1] = src0
->u
[1] >> src1
->u
[1];
1061 dst
->u
[2] = src0
->u
[2] >> src1
->u
[2];
1062 dst
->u
[3] = src0
->u
[3] >> src1
->u
[3];
1068 union tgsi_exec_channel
*dst
,
1069 const union tgsi_exec_channel
*src
)
1071 dst
->f
[0] = sinf( src
->f
[0] );
1072 dst
->f
[1] = sinf( src
->f
[1] );
1073 dst
->f
[2] = sinf( src
->f
[2] );
1074 dst
->f
[3] = sinf( src
->f
[3] );
1078 micro_sqrt( union tgsi_exec_channel
*dst
,
1079 const union tgsi_exec_channel
*src
)
1081 dst
->f
[0] = sqrtf( src
->f
[0] );
1082 dst
->f
[1] = sqrtf( src
->f
[1] );
1083 dst
->f
[2] = sqrtf( src
->f
[2] );
1084 dst
->f
[3] = sqrtf( src
->f
[3] );
1089 union tgsi_exec_channel
*dst
,
1090 const union tgsi_exec_channel
*src0
,
1091 const union tgsi_exec_channel
*src1
)
1093 dst
->f
[0] = src0
->f
[0] - src1
->f
[0];
1094 dst
->f
[1] = src0
->f
[1] - src1
->f
[1];
1095 dst
->f
[2] = src0
->f
[2] - src1
->f
[2];
1096 dst
->f
[3] = src0
->f
[3] - src1
->f
[3];
1102 union tgsi_exec_channel
*dst
,
1103 const union tgsi_exec_channel
*src
)
1105 dst
->f
[0] = (float) src
->u
[0];
1106 dst
->f
[1] = (float) src
->u
[1];
1107 dst
->f
[2] = (float) src
->u
[2];
1108 dst
->f
[3] = (float) src
->u
[3];
1114 union tgsi_exec_channel
*dst
,
1115 const union tgsi_exec_channel
*src0
,
1116 const union tgsi_exec_channel
*src1
)
1118 dst
->u
[0] = src0
->u
[0] ^ src1
->u
[0];
1119 dst
->u
[1] = src0
->u
[1] ^ src1
->u
[1];
1120 dst
->u
[2] = src0
->u
[2] ^ src1
->u
[2];
1121 dst
->u
[3] = src0
->u
[3] ^ src1
->u
[3];
1125 fetch_src_file_channel(
1126 const struct tgsi_exec_machine
*mach
,
1129 const union tgsi_exec_channel
*index
,
1130 union tgsi_exec_channel
*chan
)
1133 case TGSI_EXTSWIZZLE_X
:
1134 case TGSI_EXTSWIZZLE_Y
:
1135 case TGSI_EXTSWIZZLE_Z
:
1136 case TGSI_EXTSWIZZLE_W
:
1138 case TGSI_FILE_CONSTANT
:
1139 assert(mach
->Consts
);
1140 if (index
->i
[0] < 0)
1143 chan
->f
[0] = mach
->Consts
[index
->i
[0]][swizzle
];
1144 if (index
->i
[1] < 0)
1147 chan
->f
[1] = mach
->Consts
[index
->i
[1]][swizzle
];
1148 if (index
->i
[2] < 0)
1151 chan
->f
[2] = mach
->Consts
[index
->i
[2]][swizzle
];
1152 if (index
->i
[3] < 0)
1155 chan
->f
[3] = mach
->Consts
[index
->i
[3]][swizzle
];
1158 case TGSI_FILE_INPUT
:
1159 chan
->u
[0] = mach
->Inputs
[index
->i
[0]].xyzw
[swizzle
].u
[0];
1160 chan
->u
[1] = mach
->Inputs
[index
->i
[1]].xyzw
[swizzle
].u
[1];
1161 chan
->u
[2] = mach
->Inputs
[index
->i
[2]].xyzw
[swizzle
].u
[2];
1162 chan
->u
[3] = mach
->Inputs
[index
->i
[3]].xyzw
[swizzle
].u
[3];
1165 case TGSI_FILE_TEMPORARY
:
1166 assert(index
->i
[0] < TGSI_EXEC_NUM_TEMPS
);
1167 chan
->u
[0] = mach
->Temps
[index
->i
[0]].xyzw
[swizzle
].u
[0];
1168 chan
->u
[1] = mach
->Temps
[index
->i
[1]].xyzw
[swizzle
].u
[1];
1169 chan
->u
[2] = mach
->Temps
[index
->i
[2]].xyzw
[swizzle
].u
[2];
1170 chan
->u
[3] = mach
->Temps
[index
->i
[3]].xyzw
[swizzle
].u
[3];
1173 case TGSI_FILE_IMMEDIATE
:
1174 assert( index
->i
[0] < (int) mach
->ImmLimit
);
1175 chan
->f
[0] = mach
->Imms
[index
->i
[0]][swizzle
];
1176 assert( index
->i
[1] < (int) mach
->ImmLimit
);
1177 chan
->f
[1] = mach
->Imms
[index
->i
[1]][swizzle
];
1178 assert( index
->i
[2] < (int) mach
->ImmLimit
);
1179 chan
->f
[2] = mach
->Imms
[index
->i
[2]][swizzle
];
1180 assert( index
->i
[3] < (int) mach
->ImmLimit
);
1181 chan
->f
[3] = mach
->Imms
[index
->i
[3]][swizzle
];
1184 case TGSI_FILE_ADDRESS
:
1185 chan
->u
[0] = mach
->Addrs
[index
->i
[0]].xyzw
[swizzle
].u
[0];
1186 chan
->u
[1] = mach
->Addrs
[index
->i
[1]].xyzw
[swizzle
].u
[1];
1187 chan
->u
[2] = mach
->Addrs
[index
->i
[2]].xyzw
[swizzle
].u
[2];
1188 chan
->u
[3] = mach
->Addrs
[index
->i
[3]].xyzw
[swizzle
].u
[3];
1191 case TGSI_FILE_OUTPUT
:
1192 /* vertex/fragment output vars can be read too */
1193 chan
->u
[0] = mach
->Outputs
[index
->i
[0]].xyzw
[swizzle
].u
[0];
1194 chan
->u
[1] = mach
->Outputs
[index
->i
[1]].xyzw
[swizzle
].u
[1];
1195 chan
->u
[2] = mach
->Outputs
[index
->i
[2]].xyzw
[swizzle
].u
[2];
1196 chan
->u
[3] = mach
->Outputs
[index
->i
[3]].xyzw
[swizzle
].u
[3];
1204 case TGSI_EXTSWIZZLE_ZERO
:
1205 *chan
= mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
];
1208 case TGSI_EXTSWIZZLE_ONE
:
1209 *chan
= mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
];
1219 const struct tgsi_exec_machine
*mach
,
1220 union tgsi_exec_channel
*chan
,
1221 const struct tgsi_full_src_register
*reg
,
1222 const uint chan_index
)
1224 union tgsi_exec_channel index
;
1227 /* We start with a direct index into a register file.
1231 * file = SrcRegister.File
1232 * [1] = SrcRegister.Index
1237 index
.i
[3] = reg
->SrcRegister
.Index
;
1239 /* There is an extra source register that indirectly subscripts
1240 * a register file. The direct index now becomes an offset
1241 * that is being added to the indirect register.
1245 * ind = SrcRegisterInd.File
1246 * [2] = SrcRegisterInd.Index
1247 * .x = SrcRegisterInd.SwizzleX
1249 if (reg
->SrcRegister
.Indirect
) {
1250 union tgsi_exec_channel index2
;
1251 union tgsi_exec_channel indir_index
;
1252 const uint execmask
= mach
->ExecMask
;
1255 /* which address register (always zero now) */
1259 index2
.i
[3] = reg
->SrcRegisterInd
.Index
;
1261 /* get current value of address register[swizzle] */
1262 swizzle
= tgsi_util_get_src_register_swizzle( ®
->SrcRegisterInd
, CHAN_X
);
1263 fetch_src_file_channel(
1265 reg
->SrcRegisterInd
.File
,
1270 /* add value of address register to the offset */
1271 index
.i
[0] += (int) indir_index
.f
[0];
1272 index
.i
[1] += (int) indir_index
.f
[1];
1273 index
.i
[2] += (int) indir_index
.f
[2];
1274 index
.i
[3] += (int) indir_index
.f
[3];
1276 /* for disabled execution channels, zero-out the index to
1277 * avoid using a potential garbage value.
1279 for (i
= 0; i
< QUAD_SIZE
; i
++) {
1280 if ((execmask
& (1 << i
)) == 0)
1285 /* There is an extra source register that is a second
1286 * subscript to a register file. Effectively it means that
1287 * the register file is actually a 2D array of registers.
1289 * file[1][3] == file[1*sizeof(file[1])+3],
1291 * [3] = SrcRegisterDim.Index
1293 if (reg
->SrcRegister
.Dimension
) {
1294 /* The size of the first-order array depends on the register file type.
1295 * We need to multiply the index to the first array to get an effective,
1296 * "flat" index that points to the beginning of the second-order array.
1298 switch (reg
->SrcRegister
.File
) {
1299 case TGSI_FILE_INPUT
:
1300 index
.i
[0] *= TGSI_EXEC_MAX_INPUT_ATTRIBS
;
1301 index
.i
[1] *= TGSI_EXEC_MAX_INPUT_ATTRIBS
;
1302 index
.i
[2] *= TGSI_EXEC_MAX_INPUT_ATTRIBS
;
1303 index
.i
[3] *= TGSI_EXEC_MAX_INPUT_ATTRIBS
;
1305 case TGSI_FILE_CONSTANT
:
1306 index
.i
[0] *= TGSI_EXEC_MAX_CONST_BUFFER
;
1307 index
.i
[1] *= TGSI_EXEC_MAX_CONST_BUFFER
;
1308 index
.i
[2] *= TGSI_EXEC_MAX_CONST_BUFFER
;
1309 index
.i
[3] *= TGSI_EXEC_MAX_CONST_BUFFER
;
1315 index
.i
[0] += reg
->SrcRegisterDim
.Index
;
1316 index
.i
[1] += reg
->SrcRegisterDim
.Index
;
1317 index
.i
[2] += reg
->SrcRegisterDim
.Index
;
1318 index
.i
[3] += reg
->SrcRegisterDim
.Index
;
1320 /* Again, the second subscript index can be addressed indirectly
1321 * identically to the first one.
1322 * Nothing stops us from indirectly addressing the indirect register,
1323 * but there is no need for that, so we won't exercise it.
1325 * file[1][ind[4].y+3],
1327 * ind = SrcRegisterDimInd.File
1328 * [4] = SrcRegisterDimInd.Index
1329 * .y = SrcRegisterDimInd.SwizzleX
1331 if (reg
->SrcRegisterDim
.Indirect
) {
1332 union tgsi_exec_channel index2
;
1333 union tgsi_exec_channel indir_index
;
1334 const uint execmask
= mach
->ExecMask
;
1340 index2
.i
[3] = reg
->SrcRegisterDimInd
.Index
;
1342 swizzle
= tgsi_util_get_src_register_swizzle( ®
->SrcRegisterDimInd
, CHAN_X
);
1343 fetch_src_file_channel(
1345 reg
->SrcRegisterDimInd
.File
,
1350 index
.i
[0] += (int) indir_index
.f
[0];
1351 index
.i
[1] += (int) indir_index
.f
[1];
1352 index
.i
[2] += (int) indir_index
.f
[2];
1353 index
.i
[3] += (int) indir_index
.f
[3];
1355 /* for disabled execution channels, zero-out the index to
1356 * avoid using a potential garbage value.
1358 for (i
= 0; i
< QUAD_SIZE
; i
++) {
1359 if ((execmask
& (1 << i
)) == 0)
1364 /* If by any chance there was a need for a 3D array of register
1365 * files, we would have to check whether SrcRegisterDim is followed
1366 * by a dimension register and continue the saga.
1370 swizzle
= tgsi_util_get_full_src_register_extswizzle( reg
, chan_index
);
1371 fetch_src_file_channel(
1373 reg
->SrcRegister
.File
,
1378 switch (tgsi_util_get_full_src_register_sign_mode( reg
, chan_index
)) {
1379 case TGSI_UTIL_SIGN_CLEAR
:
1380 micro_abs( chan
, chan
);
1383 case TGSI_UTIL_SIGN_SET
:
1384 micro_abs( chan
, chan
);
1385 micro_neg( chan
, chan
);
1388 case TGSI_UTIL_SIGN_TOGGLE
:
1389 micro_neg( chan
, chan
);
1392 case TGSI_UTIL_SIGN_KEEP
:
1396 if (reg
->SrcRegisterExtMod
.Complement
) {
1397 micro_sub( chan
, &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], chan
);
1403 struct tgsi_exec_machine
*mach
,
1404 const union tgsi_exec_channel
*chan
,
1405 const struct tgsi_full_dst_register
*reg
,
1406 const struct tgsi_full_instruction
*inst
,
1410 union tgsi_exec_channel null
;
1411 union tgsi_exec_channel
*dst
;
1412 uint execmask
= mach
->ExecMask
;
1413 int offset
= 0; /* indirection offset */
1417 check_inf_or_nan(chan
);
1420 /* There is an extra source register that indirectly subscripts
1421 * a register file. The direct index now becomes an offset
1422 * that is being added to the indirect register.
1426 * ind = DstRegisterInd.File
1427 * [2] = DstRegisterInd.Index
1428 * .x = DstRegisterInd.SwizzleX
1430 if (reg
->DstRegister
.Indirect
) {
1431 union tgsi_exec_channel index
;
1432 union tgsi_exec_channel indir_index
;
1435 /* which address register (always zero for now) */
1439 index
.i
[3] = reg
->DstRegisterInd
.Index
;
1441 /* get current value of address register[swizzle] */
1442 swizzle
= tgsi_util_get_src_register_swizzle( ®
->DstRegisterInd
, CHAN_X
);
1444 /* fetch values from the address/indirection register */
1445 fetch_src_file_channel(
1447 reg
->DstRegisterInd
.File
,
1452 /* save indirection offset */
1453 offset
= (int) indir_index
.f
[0];
1456 switch (reg
->DstRegister
.File
) {
1457 case TGSI_FILE_NULL
:
1461 case TGSI_FILE_OUTPUT
:
1462 index
= mach
->Temps
[TEMP_OUTPUT_I
].xyzw
[TEMP_OUTPUT_C
].u
[0]
1463 + reg
->DstRegister
.Index
;
1464 dst
= &mach
->Outputs
[offset
+ index
].xyzw
[chan_index
];
1467 case TGSI_FILE_TEMPORARY
:
1468 index
= reg
->DstRegister
.Index
;
1469 assert( index
< TGSI_EXEC_NUM_TEMPS
);
1470 dst
= &mach
->Temps
[offset
+ index
].xyzw
[chan_index
];
1473 case TGSI_FILE_ADDRESS
:
1474 index
= reg
->DstRegister
.Index
;
1475 dst
= &mach
->Addrs
[index
].xyzw
[chan_index
];
1483 if (inst
->InstructionExtNv
.CondFlowEnable
) {
1484 union tgsi_exec_channel
*cc
= &mach
->Temps
[TEMP_CC_I
].xyzw
[TEMP_CC_C
];
1490 /* Only CC0 supported.
1492 assert( inst
->InstructionExtNv
.CondFlowIndex
< 1 );
1494 switch (chan_index
) {
1496 swizzle
= inst
->InstructionExtNv
.CondSwizzleX
;
1499 swizzle
= inst
->InstructionExtNv
.CondSwizzleY
;
1502 swizzle
= inst
->InstructionExtNv
.CondSwizzleZ
;
1505 swizzle
= inst
->InstructionExtNv
.CondSwizzleW
;
1513 case TGSI_SWIZZLE_X
:
1514 shift
= TGSI_EXEC_CC_X_SHIFT
;
1515 mask
= TGSI_EXEC_CC_X_MASK
;
1517 case TGSI_SWIZZLE_Y
:
1518 shift
= TGSI_EXEC_CC_Y_SHIFT
;
1519 mask
= TGSI_EXEC_CC_Y_MASK
;
1521 case TGSI_SWIZZLE_Z
:
1522 shift
= TGSI_EXEC_CC_Z_SHIFT
;
1523 mask
= TGSI_EXEC_CC_Z_MASK
;
1525 case TGSI_SWIZZLE_W
:
1526 shift
= TGSI_EXEC_CC_W_SHIFT
;
1527 mask
= TGSI_EXEC_CC_W_MASK
;
1534 switch (inst
->InstructionExtNv
.CondMask
) {
1536 test
= ~(TGSI_EXEC_CC_GT
<< shift
) & mask
;
1537 for (i
= 0; i
< QUAD_SIZE
; i
++)
1538 if (cc
->u
[i
] & test
)
1539 execmask
&= ~(1 << i
);
1543 test
= ~(TGSI_EXEC_CC_EQ
<< shift
) & mask
;
1544 for (i
= 0; i
< QUAD_SIZE
; i
++)
1545 if (cc
->u
[i
] & test
)
1546 execmask
&= ~(1 << i
);
1550 test
= ~(TGSI_EXEC_CC_LT
<< shift
) & mask
;
1551 for (i
= 0; i
< QUAD_SIZE
; i
++)
1552 if (cc
->u
[i
] & test
)
1553 execmask
&= ~(1 << i
);
1557 test
= ~((TGSI_EXEC_CC_GT
| TGSI_EXEC_CC_EQ
) << shift
) & mask
;
1558 for (i
= 0; i
< QUAD_SIZE
; i
++)
1559 if (cc
->u
[i
] & test
)
1560 execmask
&= ~(1 << i
);
1564 test
= ~((TGSI_EXEC_CC_LT
| TGSI_EXEC_CC_EQ
) << shift
) & mask
;
1565 for (i
= 0; i
< QUAD_SIZE
; i
++)
1566 if (cc
->u
[i
] & test
)
1567 execmask
&= ~(1 << i
);
1571 test
= ~((TGSI_EXEC_CC_GT
| TGSI_EXEC_CC_LT
| TGSI_EXEC_CC_UN
) << shift
) & mask
;
1572 for (i
= 0; i
< QUAD_SIZE
; i
++)
1573 if (cc
->u
[i
] & test
)
1574 execmask
&= ~(1 << i
);
1581 for (i
= 0; i
< QUAD_SIZE
; i
++)
1582 execmask
&= ~(1 << i
);
1591 switch (inst
->Instruction
.Saturate
) {
1593 for (i
= 0; i
< QUAD_SIZE
; i
++)
1594 if (execmask
& (1 << i
))
1595 dst
->i
[i
] = chan
->i
[i
];
1598 case TGSI_SAT_ZERO_ONE
:
1599 for (i
= 0; i
< QUAD_SIZE
; i
++)
1600 if (execmask
& (1 << i
)) {
1601 if (chan
->f
[i
] < 0.0f
)
1603 else if (chan
->f
[i
] > 1.0f
)
1606 dst
->i
[i
] = chan
->i
[i
];
1610 case TGSI_SAT_MINUS_PLUS_ONE
:
1611 for (i
= 0; i
< QUAD_SIZE
; i
++)
1612 if (execmask
& (1 << i
)) {
1613 if (chan
->f
[i
] < -1.0f
)
1615 else if (chan
->f
[i
] > 1.0f
)
1618 dst
->i
[i
] = chan
->i
[i
];
1626 if (inst
->InstructionExtNv
.CondDstUpdate
) {
1627 union tgsi_exec_channel
*cc
= &mach
->Temps
[TEMP_CC_I
].xyzw
[TEMP_CC_C
];
1631 /* Only CC0 supported.
1633 assert( inst
->InstructionExtNv
.CondDstIndex
< 1 );
1635 switch (chan_index
) {
1637 shift
= TGSI_EXEC_CC_X_SHIFT
;
1638 mask
= ~TGSI_EXEC_CC_X_MASK
;
1641 shift
= TGSI_EXEC_CC_Y_SHIFT
;
1642 mask
= ~TGSI_EXEC_CC_Y_MASK
;
1645 shift
= TGSI_EXEC_CC_Z_SHIFT
;
1646 mask
= ~TGSI_EXEC_CC_Z_MASK
;
1649 shift
= TGSI_EXEC_CC_W_SHIFT
;
1650 mask
= ~TGSI_EXEC_CC_W_MASK
;
1657 for (i
= 0; i
< QUAD_SIZE
; i
++)
1658 if (execmask
& (1 << i
)) {
1660 if (dst
->f
[i
] < 0.0f
)
1661 cc
->u
[i
] |= TGSI_EXEC_CC_LT
<< shift
;
1662 else if (dst
->f
[i
] > 0.0f
)
1663 cc
->u
[i
] |= TGSI_EXEC_CC_GT
<< shift
;
1664 else if (dst
->f
[i
] == 0.0f
)
1665 cc
->u
[i
] |= TGSI_EXEC_CC_EQ
<< shift
;
1667 cc
->u
[i
] |= TGSI_EXEC_CC_UN
<< shift
;
1672 #define FETCH(VAL,INDEX,CHAN)\
1673 fetch_source (mach, VAL, &inst->FullSrcRegisters[INDEX], CHAN)
1675 #define STORE(VAL,INDEX,CHAN)\
1676 store_dest (mach, VAL, &inst->FullDstRegisters[INDEX], inst, CHAN )
1680 * Execute ARB-style KIL which is predicated by a src register.
1681 * Kill fragment if any of the four values is less than zero.
1684 exec_kil(struct tgsi_exec_machine
*mach
,
1685 const struct tgsi_full_instruction
*inst
)
1689 uint kilmask
= 0; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */
1690 union tgsi_exec_channel r
[1];
1692 /* This mask stores component bits that were already tested. Note that
1693 * we test if the value is less than zero, so 1.0 and 0.0 need not to be
1695 uniquemask
= (1 << TGSI_EXTSWIZZLE_ZERO
) | (1 << TGSI_EXTSWIZZLE_ONE
);
1697 for (chan_index
= 0; chan_index
< 4; chan_index
++)
1702 /* unswizzle channel */
1703 swizzle
= tgsi_util_get_full_src_register_extswizzle (
1704 &inst
->FullSrcRegisters
[0],
1707 /* check if the component has not been already tested */
1708 if (uniquemask
& (1 << swizzle
))
1710 uniquemask
|= 1 << swizzle
;
1712 FETCH(&r
[0], 0, chan_index
);
1713 for (i
= 0; i
< 4; i
++)
1714 if (r
[0].f
[i
] < 0.0f
)
1718 mach
->Temps
[TEMP_KILMASK_I
].xyzw
[TEMP_KILMASK_C
].u
[0] |= kilmask
;
1722 * Execute NVIDIA-style KIL which is predicated by a condition code.
1723 * Kill fragment if the condition code is TRUE.
1726 exec_kilp(struct tgsi_exec_machine
*mach
,
1727 const struct tgsi_full_instruction
*inst
)
1729 uint kilmask
; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */
1731 if (inst
->InstructionExtNv
.CondFlowEnable
) {
1737 swizzle
[0] = inst
->InstructionExtNv
.CondSwizzleX
;
1738 swizzle
[1] = inst
->InstructionExtNv
.CondSwizzleY
;
1739 swizzle
[2] = inst
->InstructionExtNv
.CondSwizzleZ
;
1740 swizzle
[3] = inst
->InstructionExtNv
.CondSwizzleW
;
1742 for (chan_index
= 0; chan_index
< 4; chan_index
++)
1746 for (i
= 0; i
< 4; i
++) {
1747 /* TODO: evaluate the condition code */
1754 /* "unconditional" kil */
1755 kilmask
= mach
->ExecMask
;
1757 mach
->Temps
[TEMP_KILMASK_I
].xyzw
[TEMP_KILMASK_C
].u
[0] |= kilmask
;
1762 * Fetch a four texture samples using STR texture coordinates.
1765 fetch_texel( struct tgsi_sampler
*sampler
,
1766 const union tgsi_exec_channel
*s
,
1767 const union tgsi_exec_channel
*t
,
1768 const union tgsi_exec_channel
*p
,
1769 float lodbias
, /* XXX should be float[4] */
1770 union tgsi_exec_channel
*r
,
1771 union tgsi_exec_channel
*g
,
1772 union tgsi_exec_channel
*b
,
1773 union tgsi_exec_channel
*a
)
1776 float rgba
[NUM_CHANNELS
][QUAD_SIZE
];
1778 sampler
->get_samples(sampler
, s
->f
, t
->f
, p
->f
, lodbias
, rgba
);
1780 for (j
= 0; j
< 4; j
++) {
1781 r
->f
[j
] = rgba
[0][j
];
1782 g
->f
[j
] = rgba
[1][j
];
1783 b
->f
[j
] = rgba
[2][j
];
1784 a
->f
[j
] = rgba
[3][j
];
1790 exec_tex(struct tgsi_exec_machine
*mach
,
1791 const struct tgsi_full_instruction
*inst
,
1795 const uint unit
= inst
->FullSrcRegisters
[1].SrcRegister
.Index
;
1796 union tgsi_exec_channel r
[4];
1800 /* debug_printf("Sampler %u unit %u\n", sampler, unit); */
1802 switch (inst
->InstructionExtTexture
.Texture
) {
1803 case TGSI_TEXTURE_1D
:
1804 case TGSI_TEXTURE_SHADOW1D
:
1806 FETCH(&r
[0], 0, CHAN_X
);
1809 FETCH(&r
[1], 0, CHAN_W
);
1810 micro_div( &r
[0], &r
[0], &r
[1] );
1814 FETCH(&r
[1], 0, CHAN_W
);
1815 lodBias
= r
[2].f
[0];
1820 fetch_texel(mach
->Samplers
[unit
],
1821 &r
[0], &ZeroVec
, &ZeroVec
, lodBias
, /* S, T, P, BIAS */
1822 &r
[0], &r
[1], &r
[2], &r
[3]); /* R, G, B, A */
1825 case TGSI_TEXTURE_2D
:
1826 case TGSI_TEXTURE_RECT
:
1827 case TGSI_TEXTURE_SHADOW2D
:
1828 case TGSI_TEXTURE_SHADOWRECT
:
1830 FETCH(&r
[0], 0, CHAN_X
);
1831 FETCH(&r
[1], 0, CHAN_Y
);
1832 FETCH(&r
[2], 0, CHAN_Z
);
1835 FETCH(&r
[3], 0, CHAN_W
);
1836 micro_div( &r
[0], &r
[0], &r
[3] );
1837 micro_div( &r
[1], &r
[1], &r
[3] );
1838 micro_div( &r
[2], &r
[2], &r
[3] );
1842 FETCH(&r
[3], 0, CHAN_W
);
1843 lodBias
= r
[3].f
[0];
1848 fetch_texel(mach
->Samplers
[unit
],
1849 &r
[0], &r
[1], &r
[2], lodBias
, /* inputs */
1850 &r
[0], &r
[1], &r
[2], &r
[3]); /* outputs */
1853 case TGSI_TEXTURE_3D
:
1854 case TGSI_TEXTURE_CUBE
:
1856 FETCH(&r
[0], 0, CHAN_X
);
1857 FETCH(&r
[1], 0, CHAN_Y
);
1858 FETCH(&r
[2], 0, CHAN_Z
);
1861 FETCH(&r
[3], 0, CHAN_W
);
1862 micro_div( &r
[0], &r
[0], &r
[3] );
1863 micro_div( &r
[1], &r
[1], &r
[3] );
1864 micro_div( &r
[2], &r
[2], &r
[3] );
1868 FETCH(&r
[3], 0, CHAN_W
);
1869 lodBias
= r
[3].f
[0];
1874 fetch_texel(mach
->Samplers
[unit
],
1875 &r
[0], &r
[1], &r
[2], lodBias
,
1876 &r
[0], &r
[1], &r
[2], &r
[3]);
1883 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
1884 STORE( &r
[chan_index
], 0, chan_index
);
1890 * Evaluate a constant-valued coefficient at the position of the
1895 struct tgsi_exec_machine
*mach
,
1901 for( i
= 0; i
< QUAD_SIZE
; i
++ ) {
1902 mach
->Inputs
[attrib
].xyzw
[chan
].f
[i
] = mach
->InterpCoefs
[attrib
].a0
[chan
];
1907 * Evaluate a linear-valued coefficient at the position of the
1912 struct tgsi_exec_machine
*mach
,
1916 const float x
= mach
->QuadPos
.xyzw
[0].f
[0];
1917 const float y
= mach
->QuadPos
.xyzw
[1].f
[0];
1918 const float dadx
= mach
->InterpCoefs
[attrib
].dadx
[chan
];
1919 const float dady
= mach
->InterpCoefs
[attrib
].dady
[chan
];
1920 const float a0
= mach
->InterpCoefs
[attrib
].a0
[chan
] + dadx
* x
+ dady
* y
;
1921 mach
->Inputs
[attrib
].xyzw
[chan
].f
[0] = a0
;
1922 mach
->Inputs
[attrib
].xyzw
[chan
].f
[1] = a0
+ dadx
;
1923 mach
->Inputs
[attrib
].xyzw
[chan
].f
[2] = a0
+ dady
;
1924 mach
->Inputs
[attrib
].xyzw
[chan
].f
[3] = a0
+ dadx
+ dady
;
1928 * Evaluate a perspective-valued coefficient at the position of the
1932 eval_perspective_coef(
1933 struct tgsi_exec_machine
*mach
,
1937 const float x
= mach
->QuadPos
.xyzw
[0].f
[0];
1938 const float y
= mach
->QuadPos
.xyzw
[1].f
[0];
1939 const float dadx
= mach
->InterpCoefs
[attrib
].dadx
[chan
];
1940 const float dady
= mach
->InterpCoefs
[attrib
].dady
[chan
];
1941 const float a0
= mach
->InterpCoefs
[attrib
].a0
[chan
] + dadx
* x
+ dady
* y
;
1942 const float *w
= mach
->QuadPos
.xyzw
[3].f
;
1943 /* divide by W here */
1944 mach
->Inputs
[attrib
].xyzw
[chan
].f
[0] = a0
/ w
[0];
1945 mach
->Inputs
[attrib
].xyzw
[chan
].f
[1] = (a0
+ dadx
) / w
[1];
1946 mach
->Inputs
[attrib
].xyzw
[chan
].f
[2] = (a0
+ dady
) / w
[2];
1947 mach
->Inputs
[attrib
].xyzw
[chan
].f
[3] = (a0
+ dadx
+ dady
) / w
[3];
1951 typedef void (* eval_coef_func
)(
1952 struct tgsi_exec_machine
*mach
,
1958 struct tgsi_exec_machine
*mach
,
1959 const struct tgsi_full_declaration
*decl
)
1961 if( mach
->Processor
== TGSI_PROCESSOR_FRAGMENT
) {
1962 if( decl
->Declaration
.File
== TGSI_FILE_INPUT
) {
1963 unsigned first
, last
, mask
;
1964 eval_coef_func eval
;
1966 first
= decl
->DeclarationRange
.First
;
1967 last
= decl
->DeclarationRange
.Last
;
1968 mask
= decl
->Declaration
.UsageMask
;
1970 switch( decl
->Declaration
.Interpolate
) {
1971 case TGSI_INTERPOLATE_CONSTANT
:
1972 eval
= eval_constant_coef
;
1975 case TGSI_INTERPOLATE_LINEAR
:
1976 eval
= eval_linear_coef
;
1979 case TGSI_INTERPOLATE_PERSPECTIVE
:
1980 eval
= eval_perspective_coef
;
1988 if( mask
== TGSI_WRITEMASK_XYZW
) {
1991 for( i
= first
; i
<= last
; i
++ ) {
1992 for( j
= 0; j
< NUM_CHANNELS
; j
++ ) {
2000 for( j
= 0; j
< NUM_CHANNELS
; j
++ ) {
2001 if( mask
& (1 << j
) ) {
2002 for( i
= first
; i
<= last
; i
++ ) {
2014 struct tgsi_exec_machine
*mach
,
2015 const struct tgsi_full_instruction
*inst
,
2019 union tgsi_exec_channel r
[10];
2023 switch (inst
->Instruction
.Opcode
) {
2024 case TGSI_OPCODE_ARL
:
2025 case TGSI_OPCODE_FLR
:
2026 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2027 FETCH( &r
[0], 0, chan_index
);
2028 micro_flr( &r
[0], &r
[0] );
2029 STORE( &r
[0], 0, chan_index
);
2033 case TGSI_OPCODE_MOV
:
2034 case TGSI_OPCODE_SWZ
:
2035 if (inst
->Flags
& SOA_DEPENDENCY_FLAG
) {
2036 /* Do all fetches into temp regs, then do all stores to avoid
2037 * intermediate/accidental clobbering. This could be done all the
2038 * time for MOV but for other instructions we'll need more temps...
2040 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2041 FETCH( &r
[chan_index
], 0, chan_index
);
2043 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2044 STORE( &r
[chan_index
], 0, chan_index
);
2048 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2049 FETCH( &r
[0], 0, chan_index
);
2050 STORE( &r
[0], 0, chan_index
);
2055 case TGSI_OPCODE_LIT
:
2056 if (IS_CHANNEL_ENABLED( *inst
, CHAN_X
)) {
2057 STORE( &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], 0, CHAN_X
);
2060 if (IS_CHANNEL_ENABLED( *inst
, CHAN_Y
) || IS_CHANNEL_ENABLED( *inst
, CHAN_Z
)) {
2061 FETCH( &r
[0], 0, CHAN_X
);
2062 if (IS_CHANNEL_ENABLED( *inst
, CHAN_Y
)) {
2063 micro_max( &r
[0], &r
[0], &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
] );
2064 STORE( &r
[0], 0, CHAN_Y
);
2067 if (IS_CHANNEL_ENABLED( *inst
, CHAN_Z
)) {
2068 FETCH( &r
[1], 0, CHAN_Y
);
2069 micro_max( &r
[1], &r
[1], &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
] );
2071 FETCH( &r
[2], 0, CHAN_W
);
2072 micro_min( &r
[2], &r
[2], &mach
->Temps
[TEMP_128_I
].xyzw
[TEMP_128_C
] );
2073 micro_max( &r
[2], &r
[2], &mach
->Temps
[TEMP_M128_I
].xyzw
[TEMP_M128_C
] );
2074 micro_pow( &r
[1], &r
[1], &r
[2] );
2075 micro_lt( &r
[0], &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
], &r
[0], &r
[1], &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
] );
2076 STORE( &r
[0], 0, CHAN_Z
);
2080 if (IS_CHANNEL_ENABLED( *inst
, CHAN_W
)) {
2081 STORE( &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], 0, CHAN_W
);
2085 case TGSI_OPCODE_RCP
:
2086 /* TGSI_OPCODE_RECIP */
2087 FETCH( &r
[0], 0, CHAN_X
);
2088 micro_div( &r
[0], &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], &r
[0] );
2089 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2090 STORE( &r
[0], 0, chan_index
);
2094 case TGSI_OPCODE_RSQ
:
2095 /* TGSI_OPCODE_RECIPSQRT */
2096 FETCH( &r
[0], 0, CHAN_X
);
2097 micro_abs( &r
[0], &r
[0] );
2098 micro_sqrt( &r
[0], &r
[0] );
2099 micro_div( &r
[0], &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], &r
[0] );
2100 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2101 STORE( &r
[0], 0, chan_index
);
2105 case TGSI_OPCODE_EXP
:
2106 FETCH( &r
[0], 0, CHAN_X
);
2107 micro_flr( &r
[1], &r
[0] ); /* r1 = floor(r0) */
2108 if (IS_CHANNEL_ENABLED( *inst
, CHAN_X
)) {
2109 micro_exp2( &r
[2], &r
[1] ); /* r2 = 2 ^ r1 */
2110 STORE( &r
[2], 0, CHAN_X
); /* store r2 */
2112 if (IS_CHANNEL_ENABLED( *inst
, CHAN_Y
)) {
2113 micro_sub( &r
[2], &r
[0], &r
[1] ); /* r2 = r0 - r1 */
2114 STORE( &r
[2], 0, CHAN_Y
); /* store r2 */
2116 if (IS_CHANNEL_ENABLED( *inst
, CHAN_Z
)) {
2117 micro_exp2( &r
[2], &r
[0] ); /* r2 = 2 ^ r0 */
2118 STORE( &r
[2], 0, CHAN_Z
); /* store r2 */
2120 if (IS_CHANNEL_ENABLED( *inst
, CHAN_W
)) {
2121 STORE( &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], 0, CHAN_W
);
2125 case TGSI_OPCODE_LOG
:
2126 FETCH( &r
[0], 0, CHAN_X
);
2127 micro_abs( &r
[2], &r
[0] ); /* r2 = abs(r0) */
2128 micro_lg2( &r
[1], &r
[2] ); /* r1 = lg2(r2) */
2129 micro_flr( &r
[0], &r
[1] ); /* r0 = floor(r1) */
2130 if (IS_CHANNEL_ENABLED( *inst
, CHAN_X
)) {
2131 STORE( &r
[0], 0, CHAN_X
);
2133 if (IS_CHANNEL_ENABLED( *inst
, CHAN_Y
)) {
2134 micro_exp2( &r
[0], &r
[0] ); /* r0 = 2 ^ r0 */
2135 micro_div( &r
[0], &r
[2], &r
[0] ); /* r0 = r2 / r0 */
2136 STORE( &r
[0], 0, CHAN_Y
);
2138 if (IS_CHANNEL_ENABLED( *inst
, CHAN_Z
)) {
2139 STORE( &r
[1], 0, CHAN_Z
);
2141 if (IS_CHANNEL_ENABLED( *inst
, CHAN_W
)) {
2142 STORE( &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], 0, CHAN_W
);
2146 case TGSI_OPCODE_MUL
:
2147 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
)
2149 FETCH(&r
[0], 0, chan_index
);
2150 FETCH(&r
[1], 1, chan_index
);
2152 micro_mul( &r
[0], &r
[0], &r
[1] );
2154 STORE(&r
[0], 0, chan_index
);
2158 case TGSI_OPCODE_ADD
:
2159 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2160 FETCH( &r
[0], 0, chan_index
);
2161 FETCH( &r
[1], 1, chan_index
);
2162 micro_add( &r
[0], &r
[0], &r
[1] );
2163 STORE( &r
[0], 0, chan_index
);
2167 case TGSI_OPCODE_DP3
:
2168 /* TGSI_OPCODE_DOT3 */
2169 FETCH( &r
[0], 0, CHAN_X
);
2170 FETCH( &r
[1], 1, CHAN_X
);
2171 micro_mul( &r
[0], &r
[0], &r
[1] );
2173 FETCH( &r
[1], 0, CHAN_Y
);
2174 FETCH( &r
[2], 1, CHAN_Y
);
2175 micro_mul( &r
[1], &r
[1], &r
[2] );
2176 micro_add( &r
[0], &r
[0], &r
[1] );
2178 FETCH( &r
[1], 0, CHAN_Z
);
2179 FETCH( &r
[2], 1, CHAN_Z
);
2180 micro_mul( &r
[1], &r
[1], &r
[2] );
2181 micro_add( &r
[0], &r
[0], &r
[1] );
2183 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2184 STORE( &r
[0], 0, chan_index
);
2188 case TGSI_OPCODE_DP4
:
2189 /* TGSI_OPCODE_DOT4 */
2190 FETCH(&r
[0], 0, CHAN_X
);
2191 FETCH(&r
[1], 1, CHAN_X
);
2193 micro_mul( &r
[0], &r
[0], &r
[1] );
2195 FETCH(&r
[1], 0, CHAN_Y
);
2196 FETCH(&r
[2], 1, CHAN_Y
);
2198 micro_mul( &r
[1], &r
[1], &r
[2] );
2199 micro_add( &r
[0], &r
[0], &r
[1] );
2201 FETCH(&r
[1], 0, CHAN_Z
);
2202 FETCH(&r
[2], 1, CHAN_Z
);
2204 micro_mul( &r
[1], &r
[1], &r
[2] );
2205 micro_add( &r
[0], &r
[0], &r
[1] );
2207 FETCH(&r
[1], 0, CHAN_W
);
2208 FETCH(&r
[2], 1, CHAN_W
);
2210 micro_mul( &r
[1], &r
[1], &r
[2] );
2211 micro_add( &r
[0], &r
[0], &r
[1] );
2213 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2214 STORE( &r
[0], 0, chan_index
);
2218 case TGSI_OPCODE_DST
:
2219 if (IS_CHANNEL_ENABLED( *inst
, CHAN_X
)) {
2220 STORE( &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], 0, CHAN_X
);
2223 if (IS_CHANNEL_ENABLED( *inst
, CHAN_Y
)) {
2224 FETCH( &r
[0], 0, CHAN_Y
);
2225 FETCH( &r
[1], 1, CHAN_Y
);
2226 micro_mul( &r
[0], &r
[0], &r
[1] );
2227 STORE( &r
[0], 0, CHAN_Y
);
2230 if (IS_CHANNEL_ENABLED( *inst
, CHAN_Z
)) {
2231 FETCH( &r
[0], 0, CHAN_Z
);
2232 STORE( &r
[0], 0, CHAN_Z
);
2235 if (IS_CHANNEL_ENABLED( *inst
, CHAN_W
)) {
2236 FETCH( &r
[0], 1, CHAN_W
);
2237 STORE( &r
[0], 0, CHAN_W
);
2241 case TGSI_OPCODE_MIN
:
2242 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2243 FETCH(&r
[0], 0, chan_index
);
2244 FETCH(&r
[1], 1, chan_index
);
2246 /* XXX use micro_min()?? */
2247 micro_lt( &r
[0], &r
[0], &r
[1], &r
[0], &r
[1] );
2249 STORE(&r
[0], 0, chan_index
);
2253 case TGSI_OPCODE_MAX
:
2254 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2255 FETCH(&r
[0], 0, chan_index
);
2256 FETCH(&r
[1], 1, chan_index
);
2258 /* XXX use micro_max()?? */
2259 micro_lt( &r
[0], &r
[0], &r
[1], &r
[1], &r
[0] );
2261 STORE(&r
[0], 0, chan_index
);
2265 case TGSI_OPCODE_SLT
:
2266 /* TGSI_OPCODE_SETLT */
2267 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2268 FETCH( &r
[0], 0, chan_index
);
2269 FETCH( &r
[1], 1, chan_index
);
2270 micro_lt( &r
[0], &r
[0], &r
[1], &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
] );
2271 STORE( &r
[0], 0, chan_index
);
2275 case TGSI_OPCODE_SGE
:
2276 /* TGSI_OPCODE_SETGE */
2277 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2278 FETCH( &r
[0], 0, chan_index
);
2279 FETCH( &r
[1], 1, chan_index
);
2280 micro_le( &r
[0], &r
[1], &r
[0], &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
] );
2281 STORE( &r
[0], 0, chan_index
);
2285 case TGSI_OPCODE_MAD
:
2286 /* TGSI_OPCODE_MADD */
2287 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2288 FETCH( &r
[0], 0, chan_index
);
2289 FETCH( &r
[1], 1, chan_index
);
2290 micro_mul( &r
[0], &r
[0], &r
[1] );
2291 FETCH( &r
[1], 2, chan_index
);
2292 micro_add( &r
[0], &r
[0], &r
[1] );
2293 STORE( &r
[0], 0, chan_index
);
2297 case TGSI_OPCODE_SUB
:
2298 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2299 FETCH(&r
[0], 0, chan_index
);
2300 FETCH(&r
[1], 1, chan_index
);
2302 micro_sub( &r
[0], &r
[0], &r
[1] );
2304 STORE(&r
[0], 0, chan_index
);
2308 case TGSI_OPCODE_LRP
:
2309 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2310 FETCH(&r
[0], 0, chan_index
);
2311 FETCH(&r
[1], 1, chan_index
);
2312 FETCH(&r
[2], 2, chan_index
);
2314 micro_sub( &r
[1], &r
[1], &r
[2] );
2315 micro_mul( &r
[0], &r
[0], &r
[1] );
2316 micro_add( &r
[0], &r
[0], &r
[2] );
2318 STORE(&r
[0], 0, chan_index
);
2322 case TGSI_OPCODE_CND
:
2323 FOR_EACH_ENABLED_CHANNEL(*inst
, chan_index
) {
2324 FETCH(&r
[0], 0, chan_index
);
2325 FETCH(&r
[1], 1, chan_index
);
2326 FETCH(&r
[2], 2, chan_index
);
2327 micro_lt(&r
[0], &mach
->Temps
[TEMP_HALF_I
].xyzw
[TEMP_HALF_C
], &r
[2], &r
[0], &r
[1]);
2328 STORE(&r
[0], 0, chan_index
);
2332 case TGSI_OPCODE_CND0
:
2333 FOR_EACH_ENABLED_CHANNEL(*inst
, chan_index
) {
2334 FETCH(&r
[0], 0, chan_index
);
2335 FETCH(&r
[1], 1, chan_index
);
2336 FETCH(&r
[2], 2, chan_index
);
2337 micro_le(&r
[0], &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
], &r
[2], &r
[0], &r
[1]);
2338 STORE(&r
[0], 0, chan_index
);
2342 case TGSI_OPCODE_DP2A
:
2343 FETCH( &r
[0], 0, CHAN_X
);
2344 FETCH( &r
[1], 1, CHAN_X
);
2345 micro_mul( &r
[0], &r
[0], &r
[1] );
2347 FETCH( &r
[1], 0, CHAN_Y
);
2348 FETCH( &r
[2], 1, CHAN_Y
);
2349 micro_mul( &r
[1], &r
[1], &r
[2] );
2350 micro_add( &r
[0], &r
[0], &r
[1] );
2352 FETCH( &r
[2], 2, CHAN_X
);
2353 micro_add( &r
[0], &r
[0], &r
[2] );
2355 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2356 STORE( &r
[0], 0, chan_index
);
2360 case TGSI_OPCODE_FRC
:
2361 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2362 FETCH( &r
[0], 0, chan_index
);
2363 micro_frc( &r
[0], &r
[0] );
2364 STORE( &r
[0], 0, chan_index
);
2368 case TGSI_OPCODE_CLAMP
:
2369 FOR_EACH_ENABLED_CHANNEL(*inst
, chan_index
) {
2370 FETCH(&r
[0], 0, chan_index
);
2371 FETCH(&r
[1], 1, chan_index
);
2372 micro_max(&r
[0], &r
[0], &r
[1]);
2373 FETCH(&r
[1], 2, chan_index
);
2374 micro_min(&r
[0], &r
[0], &r
[1]);
2375 STORE(&r
[0], 0, chan_index
);
2379 case TGSI_OPCODE_ROUND
:
2380 case TGSI_OPCODE_ARR
:
2381 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2382 FETCH( &r
[0], 0, chan_index
);
2383 micro_rnd( &r
[0], &r
[0] );
2384 STORE( &r
[0], 0, chan_index
);
2388 case TGSI_OPCODE_EX2
:
2389 FETCH(&r
[0], 0, CHAN_X
);
2392 micro_exp2( &r
[0], &r
[0] );
2394 micro_pow( &r
[0], &mach
->Temps
[TEMP_2_I
].xyzw
[TEMP_2_C
], &r
[0] );
2397 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2398 STORE( &r
[0], 0, chan_index
);
2402 case TGSI_OPCODE_LG2
:
2403 FETCH( &r
[0], 0, CHAN_X
);
2404 micro_lg2( &r
[0], &r
[0] );
2405 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2406 STORE( &r
[0], 0, chan_index
);
2410 case TGSI_OPCODE_POW
:
2411 FETCH(&r
[0], 0, CHAN_X
);
2412 FETCH(&r
[1], 1, CHAN_X
);
2414 micro_pow( &r
[0], &r
[0], &r
[1] );
2416 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2417 STORE( &r
[0], 0, chan_index
);
2421 case TGSI_OPCODE_XPD
:
2422 FETCH(&r
[0], 0, CHAN_Y
);
2423 FETCH(&r
[1], 1, CHAN_Z
);
2425 micro_mul( &r
[2], &r
[0], &r
[1] );
2427 FETCH(&r
[3], 0, CHAN_Z
);
2428 FETCH(&r
[4], 1, CHAN_Y
);
2430 micro_mul( &r
[5], &r
[3], &r
[4] );
2431 micro_sub( &r
[2], &r
[2], &r
[5] );
2433 if (IS_CHANNEL_ENABLED( *inst
, CHAN_X
)) {
2434 STORE( &r
[2], 0, CHAN_X
);
2437 FETCH(&r
[2], 1, CHAN_X
);
2439 micro_mul( &r
[3], &r
[3], &r
[2] );
2441 FETCH(&r
[5], 0, CHAN_X
);
2443 micro_mul( &r
[1], &r
[1], &r
[5] );
2444 micro_sub( &r
[3], &r
[3], &r
[1] );
2446 if (IS_CHANNEL_ENABLED( *inst
, CHAN_Y
)) {
2447 STORE( &r
[3], 0, CHAN_Y
);
2450 micro_mul( &r
[5], &r
[5], &r
[4] );
2451 micro_mul( &r
[0], &r
[0], &r
[2] );
2452 micro_sub( &r
[5], &r
[5], &r
[0] );
2454 if (IS_CHANNEL_ENABLED( *inst
, CHAN_Z
)) {
2455 STORE( &r
[5], 0, CHAN_Z
);
2458 if (IS_CHANNEL_ENABLED( *inst
, CHAN_W
)) {
2459 STORE( &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], 0, CHAN_W
);
2463 case TGSI_OPCODE_ABS
:
2464 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2465 FETCH(&r
[0], 0, chan_index
);
2467 micro_abs( &r
[0], &r
[0] );
2469 STORE(&r
[0], 0, chan_index
);
2473 case TGSI_OPCODE_RCC
:
2474 FETCH(&r
[0], 0, CHAN_X
);
2475 micro_div(&r
[0], &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], &r
[0]);
2476 micro_float_clamp(&r
[0], &r
[0]);
2477 FOR_EACH_ENABLED_CHANNEL(*inst
, chan_index
) {
2478 STORE(&r
[0], 0, chan_index
);
2482 case TGSI_OPCODE_DPH
:
2483 FETCH(&r
[0], 0, CHAN_X
);
2484 FETCH(&r
[1], 1, CHAN_X
);
2486 micro_mul( &r
[0], &r
[0], &r
[1] );
2488 FETCH(&r
[1], 0, CHAN_Y
);
2489 FETCH(&r
[2], 1, CHAN_Y
);
2491 micro_mul( &r
[1], &r
[1], &r
[2] );
2492 micro_add( &r
[0], &r
[0], &r
[1] );
2494 FETCH(&r
[1], 0, CHAN_Z
);
2495 FETCH(&r
[2], 1, CHAN_Z
);
2497 micro_mul( &r
[1], &r
[1], &r
[2] );
2498 micro_add( &r
[0], &r
[0], &r
[1] );
2500 FETCH(&r
[1], 1, CHAN_W
);
2502 micro_add( &r
[0], &r
[0], &r
[1] );
2504 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2505 STORE( &r
[0], 0, chan_index
);
2509 case TGSI_OPCODE_COS
:
2510 FETCH(&r
[0], 0, CHAN_X
);
2512 micro_cos( &r
[0], &r
[0] );
2514 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2515 STORE( &r
[0], 0, chan_index
);
2519 case TGSI_OPCODE_DDX
:
2520 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2521 FETCH( &r
[0], 0, chan_index
);
2522 micro_ddx( &r
[0], &r
[0] );
2523 STORE( &r
[0], 0, chan_index
);
2527 case TGSI_OPCODE_DDY
:
2528 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2529 FETCH( &r
[0], 0, chan_index
);
2530 micro_ddy( &r
[0], &r
[0] );
2531 STORE( &r
[0], 0, chan_index
);
2535 case TGSI_OPCODE_KILP
:
2536 exec_kilp (mach
, inst
);
2539 case TGSI_OPCODE_KIL
:
2540 exec_kil (mach
, inst
);
2543 case TGSI_OPCODE_PK2H
:
2547 case TGSI_OPCODE_PK2US
:
2551 case TGSI_OPCODE_PK4B
:
2555 case TGSI_OPCODE_PK4UB
:
2559 case TGSI_OPCODE_RFL
:
2560 if (IS_CHANNEL_ENABLED(*inst
, CHAN_X
) ||
2561 IS_CHANNEL_ENABLED(*inst
, CHAN_Y
) ||
2562 IS_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
2563 /* r0 = dp3(src0, src0) */
2564 FETCH(&r
[2], 0, CHAN_X
);
2565 micro_mul(&r
[0], &r
[2], &r
[2]);
2566 FETCH(&r
[4], 0, CHAN_Y
);
2567 micro_mul(&r
[8], &r
[4], &r
[4]);
2568 micro_add(&r
[0], &r
[0], &r
[8]);
2569 FETCH(&r
[6], 0, CHAN_Z
);
2570 micro_mul(&r
[8], &r
[6], &r
[6]);
2571 micro_add(&r
[0], &r
[0], &r
[8]);
2573 /* r1 = dp3(src0, src1) */
2574 FETCH(&r
[3], 1, CHAN_X
);
2575 micro_mul(&r
[1], &r
[2], &r
[3]);
2576 FETCH(&r
[5], 1, CHAN_Y
);
2577 micro_mul(&r
[8], &r
[4], &r
[5]);
2578 micro_add(&r
[1], &r
[1], &r
[8]);
2579 FETCH(&r
[7], 1, CHAN_Z
);
2580 micro_mul(&r
[8], &r
[6], &r
[7]);
2581 micro_add(&r
[1], &r
[1], &r
[8]);
2583 /* r1 = 2 * r1 / r0 */
2584 micro_add(&r
[1], &r
[1], &r
[1]);
2585 micro_div(&r
[1], &r
[1], &r
[0]);
2587 if (IS_CHANNEL_ENABLED(*inst
, CHAN_X
)) {
2588 micro_mul(&r
[2], &r
[2], &r
[1]);
2589 micro_sub(&r
[2], &r
[2], &r
[3]);
2590 STORE(&r
[2], 0, CHAN_X
);
2592 if (IS_CHANNEL_ENABLED(*inst
, CHAN_Y
)) {
2593 micro_mul(&r
[4], &r
[4], &r
[1]);
2594 micro_sub(&r
[4], &r
[4], &r
[5]);
2595 STORE(&r
[4], 0, CHAN_Y
);
2597 if (IS_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
2598 micro_mul(&r
[6], &r
[6], &r
[1]);
2599 micro_sub(&r
[6], &r
[6], &r
[7]);
2600 STORE(&r
[6], 0, CHAN_Z
);
2603 if (IS_CHANNEL_ENABLED(*inst
, CHAN_W
)) {
2604 STORE(&mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], 0, CHAN_W
);
2608 case TGSI_OPCODE_SEQ
:
2609 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2610 FETCH( &r
[0], 0, chan_index
);
2611 FETCH( &r
[1], 1, chan_index
);
2612 micro_eq( &r
[0], &r
[0], &r
[1],
2613 &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
],
2614 &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
] );
2615 STORE( &r
[0], 0, chan_index
);
2619 case TGSI_OPCODE_SFL
:
2620 FOR_EACH_ENABLED_CHANNEL(*inst
, chan_index
) {
2621 STORE(&mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
], 0, chan_index
);
2625 case TGSI_OPCODE_SGT
:
2626 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2627 FETCH( &r
[0], 0, chan_index
);
2628 FETCH( &r
[1], 1, chan_index
);
2629 micro_le( &r
[0], &r
[0], &r
[1], &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
], &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
] );
2630 STORE( &r
[0], 0, chan_index
);
2634 case TGSI_OPCODE_SIN
:
2635 FETCH( &r
[0], 0, CHAN_X
);
2636 micro_sin( &r
[0], &r
[0] );
2637 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2638 STORE( &r
[0], 0, chan_index
);
2642 case TGSI_OPCODE_SLE
:
2643 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2644 FETCH( &r
[0], 0, chan_index
);
2645 FETCH( &r
[1], 1, chan_index
);
2646 micro_le( &r
[0], &r
[0], &r
[1], &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
] );
2647 STORE( &r
[0], 0, chan_index
);
2651 case TGSI_OPCODE_SNE
:
2652 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2653 FETCH( &r
[0], 0, chan_index
);
2654 FETCH( &r
[1], 1, chan_index
);
2655 micro_eq( &r
[0], &r
[0], &r
[1], &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
], &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
] );
2656 STORE( &r
[0], 0, chan_index
);
2660 case TGSI_OPCODE_STR
:
2661 FOR_EACH_ENABLED_CHANNEL(*inst
, chan_index
) {
2662 STORE(&mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], 0, chan_index
);
2666 case TGSI_OPCODE_TEX
:
2667 /* simple texture lookup */
2668 /* src[0] = texcoord */
2669 /* src[1] = sampler unit */
2670 exec_tex(mach
, inst
, FALSE
, FALSE
);
2673 case TGSI_OPCODE_TXB
:
2674 /* Texture lookup with lod bias */
2675 /* src[0] = texcoord (src[0].w = LOD bias) */
2676 /* src[1] = sampler unit */
2677 exec_tex(mach
, inst
, TRUE
, FALSE
);
2680 case TGSI_OPCODE_TXD
:
2681 /* Texture lookup with explict partial derivatives */
2682 /* src[0] = texcoord */
2683 /* src[1] = d[strq]/dx */
2684 /* src[2] = d[strq]/dy */
2685 /* src[3] = sampler unit */
2689 case TGSI_OPCODE_TXL
:
2690 /* Texture lookup with explit LOD */
2691 /* src[0] = texcoord (src[0].w = LOD) */
2692 /* src[1] = sampler unit */
2693 exec_tex(mach
, inst
, TRUE
, FALSE
);
2696 case TGSI_OPCODE_TXP
:
2697 /* Texture lookup with projection */
2698 /* src[0] = texcoord (src[0].w = projection) */
2699 /* src[1] = sampler unit */
2700 exec_tex(mach
, inst
, FALSE
, TRUE
);
2703 case TGSI_OPCODE_UP2H
:
2707 case TGSI_OPCODE_UP2US
:
2711 case TGSI_OPCODE_UP4B
:
2715 case TGSI_OPCODE_UP4UB
:
2719 case TGSI_OPCODE_X2D
:
2720 FETCH(&r
[0], 1, CHAN_X
);
2721 FETCH(&r
[1], 1, CHAN_Y
);
2722 if (IS_CHANNEL_ENABLED(*inst
, CHAN_X
) ||
2723 IS_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
2724 FETCH(&r
[2], 2, CHAN_X
);
2725 micro_mul(&r
[2], &r
[2], &r
[0]);
2726 FETCH(&r
[3], 2, CHAN_Y
);
2727 micro_mul(&r
[3], &r
[3], &r
[1]);
2728 micro_add(&r
[2], &r
[2], &r
[3]);
2729 FETCH(&r
[3], 0, CHAN_X
);
2730 micro_add(&r
[2], &r
[2], &r
[3]);
2731 if (IS_CHANNEL_ENABLED(*inst
, CHAN_X
)) {
2732 STORE(&r
[2], 0, CHAN_X
);
2734 if (IS_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
2735 STORE(&r
[2], 0, CHAN_Z
);
2738 if (IS_CHANNEL_ENABLED(*inst
, CHAN_Y
) ||
2739 IS_CHANNEL_ENABLED(*inst
, CHAN_W
)) {
2740 FETCH(&r
[2], 2, CHAN_Z
);
2741 micro_mul(&r
[2], &r
[2], &r
[0]);
2742 FETCH(&r
[3], 2, CHAN_W
);
2743 micro_mul(&r
[3], &r
[3], &r
[1]);
2744 micro_add(&r
[2], &r
[2], &r
[3]);
2745 FETCH(&r
[3], 0, CHAN_Y
);
2746 micro_add(&r
[2], &r
[2], &r
[3]);
2747 if (IS_CHANNEL_ENABLED(*inst
, CHAN_Y
)) {
2748 STORE(&r
[2], 0, CHAN_Y
);
2750 if (IS_CHANNEL_ENABLED(*inst
, CHAN_W
)) {
2751 STORE(&r
[2], 0, CHAN_W
);
2756 case TGSI_OPCODE_ARA
:
2760 case TGSI_OPCODE_BRA
:
2764 case TGSI_OPCODE_CAL
:
2765 /* skip the call if no execution channels are enabled */
2766 if (mach
->ExecMask
) {
2769 /* push the Cond, Loop, Cont stacks */
2770 assert(mach
->CondStackTop
< TGSI_EXEC_MAX_COND_NESTING
);
2771 mach
->CondStack
[mach
->CondStackTop
++] = mach
->CondMask
;
2772 assert(mach
->LoopStackTop
< TGSI_EXEC_MAX_LOOP_NESTING
);
2773 mach
->LoopStack
[mach
->LoopStackTop
++] = mach
->LoopMask
;
2774 assert(mach
->ContStackTop
< TGSI_EXEC_MAX_LOOP_NESTING
);
2775 mach
->ContStack
[mach
->ContStackTop
++] = mach
->ContMask
;
2777 assert(mach
->FuncStackTop
< TGSI_EXEC_MAX_CALL_NESTING
);
2778 mach
->FuncStack
[mach
->FuncStackTop
++] = mach
->FuncMask
;
2780 /* note that PC was already incremented above */
2781 mach
->CallStack
[mach
->CallStackTop
++] = *pc
;
2782 *pc
= inst
->InstructionExtLabel
.Label
;
2786 case TGSI_OPCODE_RET
:
2787 mach
->FuncMask
&= ~mach
->ExecMask
;
2788 UPDATE_EXEC_MASK(mach
);
2790 if (mach
->FuncMask
== 0x0) {
2791 /* really return now (otherwise, keep executing */
2793 if (mach
->CallStackTop
== 0) {
2794 /* returning from main() */
2798 *pc
= mach
->CallStack
[--mach
->CallStackTop
];
2800 /* pop the Cond, Loop, Cont stacks */
2801 assert(mach
->CondStackTop
> 0);
2802 mach
->CondMask
= mach
->CondStack
[--mach
->CondStackTop
];
2803 assert(mach
->LoopStackTop
> 0);
2804 mach
->LoopMask
= mach
->LoopStack
[--mach
->LoopStackTop
];
2805 assert(mach
->ContStackTop
> 0);
2806 mach
->ContMask
= mach
->ContStack
[--mach
->ContStackTop
];
2807 assert(mach
->FuncStackTop
> 0);
2808 mach
->FuncMask
= mach
->FuncStack
[--mach
->FuncStackTop
];
2810 UPDATE_EXEC_MASK(mach
);
2814 case TGSI_OPCODE_SSG
:
2815 /* TGSI_OPCODE_SGN */
2816 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2817 FETCH( &r
[0], 0, chan_index
);
2818 micro_sgn( &r
[0], &r
[0] );
2819 STORE( &r
[0], 0, chan_index
);
2823 case TGSI_OPCODE_CMP
:
2824 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2825 FETCH(&r
[0], 0, chan_index
);
2826 FETCH(&r
[1], 1, chan_index
);
2827 FETCH(&r
[2], 2, chan_index
);
2829 micro_lt( &r
[0], &r
[0], &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
], &r
[1], &r
[2] );
2831 STORE(&r
[0], 0, chan_index
);
2835 case TGSI_OPCODE_SCS
:
2836 if( IS_CHANNEL_ENABLED( *inst
, CHAN_X
) || IS_CHANNEL_ENABLED( *inst
, CHAN_Y
) ) {
2837 FETCH( &r
[0], 0, CHAN_X
);
2838 if (IS_CHANNEL_ENABLED(*inst
, CHAN_X
)) {
2839 micro_cos(&r
[1], &r
[0]);
2840 STORE(&r
[1], 0, CHAN_X
);
2842 if (IS_CHANNEL_ENABLED(*inst
, CHAN_Y
)) {
2843 micro_sin(&r
[1], &r
[0]);
2844 STORE(&r
[1], 0, CHAN_Y
);
2847 if( IS_CHANNEL_ENABLED( *inst
, CHAN_Z
) ) {
2848 STORE( &mach
->Temps
[TEMP_0_I
].xyzw
[TEMP_0_C
], 0, CHAN_Z
);
2850 if( IS_CHANNEL_ENABLED( *inst
, CHAN_W
) ) {
2851 STORE( &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], 0, CHAN_W
);
2855 case TGSI_OPCODE_NRM
:
2856 /* 3-component vector normalize */
2857 if(IS_CHANNEL_ENABLED(*inst
, CHAN_X
) ||
2858 IS_CHANNEL_ENABLED(*inst
, CHAN_Y
) ||
2859 IS_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
2860 /* r3 = sqrt(dp3(src0, src0)) */
2861 FETCH(&r
[0], 0, CHAN_X
);
2862 micro_mul(&r
[3], &r
[0], &r
[0]);
2863 FETCH(&r
[1], 0, CHAN_Y
);
2864 micro_mul(&r
[4], &r
[1], &r
[1]);
2865 micro_add(&r
[3], &r
[3], &r
[4]);
2866 FETCH(&r
[2], 0, CHAN_Z
);
2867 micro_mul(&r
[4], &r
[2], &r
[2]);
2868 micro_add(&r
[3], &r
[3], &r
[4]);
2869 micro_sqrt(&r
[3], &r
[3]);
2871 if (IS_CHANNEL_ENABLED(*inst
, CHAN_X
)) {
2872 micro_div(&r
[0], &r
[0], &r
[3]);
2873 STORE(&r
[0], 0, CHAN_X
);
2875 if (IS_CHANNEL_ENABLED(*inst
, CHAN_Y
)) {
2876 micro_div(&r
[1], &r
[1], &r
[3]);
2877 STORE(&r
[1], 0, CHAN_Y
);
2879 if (IS_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
2880 micro_div(&r
[2], &r
[2], &r
[3]);
2881 STORE(&r
[2], 0, CHAN_Z
);
2884 if (IS_CHANNEL_ENABLED(*inst
, CHAN_W
)) {
2885 STORE(&mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], 0, CHAN_W
);
2889 case TGSI_OPCODE_NRM4
:
2890 /* 4-component vector normalize */
2892 union tgsi_exec_channel tmp
, dot
;
2894 /* tmp = dp4(src0, src0): */
2895 FETCH( &r
[0], 0, CHAN_X
);
2896 micro_mul( &tmp
, &r
[0], &r
[0] );
2898 FETCH( &r
[1], 0, CHAN_Y
);
2899 micro_mul( &dot
, &r
[1], &r
[1] );
2900 micro_add( &tmp
, &tmp
, &dot
);
2902 FETCH( &r
[2], 0, CHAN_Z
);
2903 micro_mul( &dot
, &r
[2], &r
[2] );
2904 micro_add( &tmp
, &tmp
, &dot
);
2906 FETCH( &r
[3], 0, CHAN_W
);
2907 micro_mul( &dot
, &r
[3], &r
[3] );
2908 micro_add( &tmp
, &tmp
, &dot
);
2910 /* tmp = 1 / sqrt(tmp) */
2911 micro_sqrt( &tmp
, &tmp
);
2912 micro_div( &tmp
, &mach
->Temps
[TEMP_1_I
].xyzw
[TEMP_1_C
], &tmp
);
2914 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2915 /* chan = chan * tmp */
2916 micro_mul( &r
[chan_index
], &tmp
, &r
[chan_index
] );
2917 STORE( &r
[chan_index
], 0, chan_index
);
2922 case TGSI_OPCODE_DIV
:
2926 case TGSI_OPCODE_DP2
:
2927 FETCH( &r
[0], 0, CHAN_X
);
2928 FETCH( &r
[1], 1, CHAN_X
);
2929 micro_mul( &r
[0], &r
[0], &r
[1] );
2931 FETCH( &r
[1], 0, CHAN_Y
);
2932 FETCH( &r
[2], 1, CHAN_Y
);
2933 micro_mul( &r
[1], &r
[1], &r
[2] );
2934 micro_add( &r
[0], &r
[0], &r
[1] );
2936 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
2937 STORE( &r
[0], 0, chan_index
);
2941 case TGSI_OPCODE_IF
:
2943 assert(mach
->CondStackTop
< TGSI_EXEC_MAX_COND_NESTING
);
2944 mach
->CondStack
[mach
->CondStackTop
++] = mach
->CondMask
;
2945 FETCH( &r
[0], 0, CHAN_X
);
2946 /* update CondMask */
2948 mach
->CondMask
&= ~0x1;
2951 mach
->CondMask
&= ~0x2;
2954 mach
->CondMask
&= ~0x4;
2957 mach
->CondMask
&= ~0x8;
2959 UPDATE_EXEC_MASK(mach
);
2960 /* Todo: If CondMask==0, jump to ELSE */
2963 case TGSI_OPCODE_ELSE
:
2964 /* invert CondMask wrt previous mask */
2967 assert(mach
->CondStackTop
> 0);
2968 prevMask
= mach
->CondStack
[mach
->CondStackTop
- 1];
2969 mach
->CondMask
= ~mach
->CondMask
& prevMask
;
2970 UPDATE_EXEC_MASK(mach
);
2971 /* Todo: If CondMask==0, jump to ENDIF */
2975 case TGSI_OPCODE_ENDIF
:
2977 assert(mach
->CondStackTop
> 0);
2978 mach
->CondMask
= mach
->CondStack
[--mach
->CondStackTop
];
2979 UPDATE_EXEC_MASK(mach
);
2982 case TGSI_OPCODE_END
:
2983 /* halt execution */
2987 case TGSI_OPCODE_REP
:
2991 case TGSI_OPCODE_ENDREP
:
2995 case TGSI_OPCODE_PUSHA
:
2999 case TGSI_OPCODE_POPA
:
3003 case TGSI_OPCODE_CEIL
:
3004 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
3005 FETCH( &r
[0], 0, chan_index
);
3006 micro_ceil( &r
[0], &r
[0] );
3007 STORE( &r
[0], 0, chan_index
);
3011 case TGSI_OPCODE_I2F
:
3012 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
3013 FETCH( &r
[0], 0, chan_index
);
3014 micro_i2f( &r
[0], &r
[0] );
3015 STORE( &r
[0], 0, chan_index
);
3019 case TGSI_OPCODE_NOT
:
3020 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
3021 FETCH( &r
[0], 0, chan_index
);
3022 micro_not( &r
[0], &r
[0] );
3023 STORE( &r
[0], 0, chan_index
);
3027 case TGSI_OPCODE_TRUNC
:
3028 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
3029 FETCH( &r
[0], 0, chan_index
);
3030 micro_trunc( &r
[0], &r
[0] );
3031 STORE( &r
[0], 0, chan_index
);
3035 case TGSI_OPCODE_SHL
:
3036 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
3037 FETCH( &r
[0], 0, chan_index
);
3038 FETCH( &r
[1], 1, chan_index
);
3039 micro_shl( &r
[0], &r
[0], &r
[1] );
3040 STORE( &r
[0], 0, chan_index
);
3044 case TGSI_OPCODE_SHR
:
3045 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
3046 FETCH( &r
[0], 0, chan_index
);
3047 FETCH( &r
[1], 1, chan_index
);
3048 micro_ishr( &r
[0], &r
[0], &r
[1] );
3049 STORE( &r
[0], 0, chan_index
);
3053 case TGSI_OPCODE_AND
:
3054 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
3055 FETCH( &r
[0], 0, chan_index
);
3056 FETCH( &r
[1], 1, chan_index
);
3057 micro_and( &r
[0], &r
[0], &r
[1] );
3058 STORE( &r
[0], 0, chan_index
);
3062 case TGSI_OPCODE_OR
:
3063 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
3064 FETCH( &r
[0], 0, chan_index
);
3065 FETCH( &r
[1], 1, chan_index
);
3066 micro_or( &r
[0], &r
[0], &r
[1] );
3067 STORE( &r
[0], 0, chan_index
);
3071 case TGSI_OPCODE_MOD
:
3075 case TGSI_OPCODE_XOR
:
3076 FOR_EACH_ENABLED_CHANNEL( *inst
, chan_index
) {
3077 FETCH( &r
[0], 0, chan_index
);
3078 FETCH( &r
[1], 1, chan_index
);
3079 micro_xor( &r
[0], &r
[0], &r
[1] );
3080 STORE( &r
[0], 0, chan_index
);
3084 case TGSI_OPCODE_SAD
:
3088 case TGSI_OPCODE_TXF
:
3092 case TGSI_OPCODE_TXQ
:
3096 case TGSI_OPCODE_EMIT
:
3097 mach
->Temps
[TEMP_OUTPUT_I
].xyzw
[TEMP_OUTPUT_C
].u
[0] += 16;
3098 mach
->Primitives
[mach
->Temps
[TEMP_PRIMITIVE_I
].xyzw
[TEMP_PRIMITIVE_C
].u
[0]]++;
3101 case TGSI_OPCODE_ENDPRIM
:
3102 mach
->Temps
[TEMP_PRIMITIVE_I
].xyzw
[TEMP_PRIMITIVE_C
].u
[0]++;
3103 mach
->Primitives
[mach
->Temps
[TEMP_PRIMITIVE_I
].xyzw
[TEMP_PRIMITIVE_C
].u
[0]] = 0;
3106 case TGSI_OPCODE_BGNFOR
:
3107 /* fall-through (for now) */
3108 case TGSI_OPCODE_BGNLOOP
:
3109 /* push LoopMask and ContMasks */
3110 assert(mach
->LoopStackTop
< TGSI_EXEC_MAX_LOOP_NESTING
);
3111 mach
->LoopStack
[mach
->LoopStackTop
++] = mach
->LoopMask
;
3112 assert(mach
->ContStackTop
< TGSI_EXEC_MAX_LOOP_NESTING
);
3113 mach
->ContStack
[mach
->ContStackTop
++] = mach
->ContMask
;
3116 case TGSI_OPCODE_ENDFOR
:
3117 /* fall-through (for now at least) */
3118 case TGSI_OPCODE_ENDLOOP
:
3119 /* Restore ContMask, but don't pop */
3120 assert(mach
->ContStackTop
> 0);
3121 mach
->ContMask
= mach
->ContStack
[mach
->ContStackTop
- 1];
3122 UPDATE_EXEC_MASK(mach
);
3123 if (mach
->ExecMask
) {
3124 /* repeat loop: jump to instruction just past BGNLOOP */
3125 *pc
= inst
->InstructionExtLabel
.Label
+ 1;
3128 /* exit loop: pop LoopMask */
3129 assert(mach
->LoopStackTop
> 0);
3130 mach
->LoopMask
= mach
->LoopStack
[--mach
->LoopStackTop
];
3132 assert(mach
->ContStackTop
> 0);
3133 mach
->ContMask
= mach
->ContStack
[--mach
->ContStackTop
];
3135 UPDATE_EXEC_MASK(mach
);
3138 case TGSI_OPCODE_BRK
:
3139 /* turn off loop channels for each enabled exec channel */
3140 mach
->LoopMask
&= ~mach
->ExecMask
;
3141 /* Todo: if mach->LoopMask == 0, jump to end of loop */
3142 UPDATE_EXEC_MASK(mach
);
3145 case TGSI_OPCODE_CONT
:
3146 /* turn off cont channels for each enabled exec channel */
3147 mach
->ContMask
&= ~mach
->ExecMask
;
3148 /* Todo: if mach->LoopMask == 0, jump to end of loop */
3149 UPDATE_EXEC_MASK(mach
);
3152 case TGSI_OPCODE_BGNSUB
:
3156 case TGSI_OPCODE_ENDSUB
:
3160 case TGSI_OPCODE_NOISE1
:
3164 case TGSI_OPCODE_NOISE2
:
3168 case TGSI_OPCODE_NOISE3
:
3172 case TGSI_OPCODE_NOISE4
:
3176 case TGSI_OPCODE_NOP
:
3186 * Run TGSI interpreter.
3187 * \return bitmask of "alive" quad components
3190 tgsi_exec_machine_run( struct tgsi_exec_machine
*mach
)
3195 mach
->CondMask
= 0xf;
3196 mach
->LoopMask
= 0xf;
3197 mach
->ContMask
= 0xf;
3198 mach
->FuncMask
= 0xf;
3199 mach
->ExecMask
= 0xf;
3201 mach
->CondStackTop
= 0; /* temporarily subvert this assertion */
3202 assert(mach
->CondStackTop
== 0);
3203 assert(mach
->LoopStackTop
== 0);
3204 assert(mach
->ContStackTop
== 0);
3205 assert(mach
->CallStackTop
== 0);
3207 mach
->Temps
[TEMP_KILMASK_I
].xyzw
[TEMP_KILMASK_C
].u
[0] = 0;
3208 mach
->Temps
[TEMP_OUTPUT_I
].xyzw
[TEMP_OUTPUT_C
].u
[0] = 0;
3210 if( mach
->Processor
== TGSI_PROCESSOR_GEOMETRY
) {
3211 mach
->Temps
[TEMP_PRIMITIVE_I
].xyzw
[TEMP_PRIMITIVE_C
].u
[0] = 0;
3212 mach
->Primitives
[0] = 0;
3215 for (i
= 0; i
< QUAD_SIZE
; i
++) {
3216 mach
->Temps
[TEMP_CC_I
].xyzw
[TEMP_CC_C
].u
[i
] =
3217 (TGSI_EXEC_CC_EQ
<< TGSI_EXEC_CC_X_SHIFT
) |
3218 (TGSI_EXEC_CC_EQ
<< TGSI_EXEC_CC_Y_SHIFT
) |
3219 (TGSI_EXEC_CC_EQ
<< TGSI_EXEC_CC_Z_SHIFT
) |
3220 (TGSI_EXEC_CC_EQ
<< TGSI_EXEC_CC_W_SHIFT
);
3223 /* execute declarations (interpolants) */
3224 for (i
= 0; i
< mach
->NumDeclarations
; i
++) {
3225 exec_declaration( mach
, mach
->Declarations
+i
);
3228 /* execute instructions, until pc is set to -1 */
3230 assert(pc
< (int) mach
->NumInstructions
);
3231 exec_instruction( mach
, mach
->Instructions
+ pc
, &pc
);
3235 /* we scale from floats in [0,1] to Zbuffer ints in sp_quad_depth_test.c */
3236 if (mach
->Processor
== TGSI_PROCESSOR_FRAGMENT
) {
3238 * Scale back depth component.
3240 for (i
= 0; i
< 4; i
++)
3241 mach
->Outputs
[0].xyzw
[2].f
[i
] *= ctx
->DrawBuffer
->_DepthMaxF
;
3245 return ~mach
->Temps
[TEMP_KILMASK_I
].xyzw
[TEMP_KILMASK_C
].u
[0];