1 /**************************************************************************
3 * Copyright 2007 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 **************************************************************************/
28 #include "pipe/p_util.h"
29 #include "pipe/p_shader_tokens.h"
30 #include "pipe/tgsi/util/tgsi_parse.h"
31 #include "pipe/tgsi/util/tgsi_util.h"
32 #include "tgsi_exec.h"
33 #include "tgsi_sse2.h"
35 #include "x86/rtasm/x86sse.h"
37 #if defined(__i386__) || defined(__386__)
47 if (reg
.mod
!= mod_REG
)
54 debug_printf( "EAX" );
57 debug_printf( "ECX" );
60 debug_printf( "EDX" );
63 debug_printf( "EBX" );
66 debug_printf( "ESP" );
69 debug_printf( "EBP" );
72 debug_printf( "ESI" );
75 debug_printf( "EDI" );
83 debug_printf( "XMM%u", reg
.idx
);
90 if (reg
.mod
== mod_DISP8
||
91 reg
.mod
== mod_DISP32
)
92 debug_printf("+%d", reg
.disp
);
94 if (reg
.mod
!= mod_REG
)
102 unsigned count
= 10 - strlen( op
);
109 #define DUMP_START() debug_printf( "\nsse-dump start ----------------" )
110 #define DUMP_END() debug_printf( "\nsse-dump end ----------------\n" )
111 #define DUMP( OP ) debug_printf( "\n%s", OP )
112 #define DUMP_I( OP, I ) do {\
113 debug_printf( "\n%s", OP );\
115 debug_printf( "%u", I ); } while( 0 )
116 #define DUMP_R( OP, R0 ) do {\
117 debug_printf( "\n%s", OP );\
119 _print_reg( R0 ); } while( 0 )
120 #define DUMP_RR( OP, R0, R1 ) do {\
121 debug_printf( "\n%s", OP );\
124 debug_printf( ", " );\
125 _print_reg( R1 ); } while( 0 )
126 #define DUMP_RRI( OP, R0, R1, I ) do {\
127 debug_printf( "\n%s", OP );\
130 debug_printf( ", " );\
132 debug_printf( ", " );\
133 debug_printf( "%u", I ); } while( 0 )
140 #define DUMP_I( OP, I )
141 #define DUMP_R( OP, R0 )
142 #define DUMP_RR( OP, R0, R1 )
143 #define DUMP_RRI( OP, R0, R1, I )
147 #define FOR_EACH_CHANNEL( CHAN )\
148 for( CHAN = 0; CHAN < 4; CHAN++ )
150 #define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
151 ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
153 #define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
154 if( IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
156 #define FOR_EACH_DST0_ENABLED_CHANNEL( INST, CHAN )\
157 FOR_EACH_CHANNEL( CHAN )\
158 IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )
165 #define TEMP_R0 TGSI_EXEC_TEMP_R0
168 * X86 utility functions.
171 static struct x86_reg
177 (enum x86_reg_name
) xmm
);
181 * X86 register mapping helpers.
184 static struct x86_reg
185 get_const_base( void )
192 static struct x86_reg
193 get_input_base( void )
200 static struct x86_reg
201 get_output_base( void )
208 static struct x86_reg
209 get_temp_base( void )
222 static struct x86_reg
223 get_coef_base( void )
225 return get_output_base();
229 * Data access helpers.
232 static struct x86_reg
236 return x86_make_disp(
237 x86_make_reg( file_REG32
, reg_SP
),
241 static struct x86_reg
246 return x86_make_disp(
248 (vec
* 4 + chan
) * 4 );
251 static struct x86_reg
256 return x86_make_disp(
258 (vec
* 4 + chan
) * 16 );
261 static struct x86_reg
266 return x86_make_disp(
268 (vec
* 4 + chan
) * 16 );
271 static struct x86_reg
276 return x86_make_disp(
278 (vec
* 4 + chan
) * 16 );
281 static struct x86_reg
287 return x86_make_disp(
289 ((vec
* 3 + member
) * 4 + chan
) * 4 );
293 * X86 rtasm wrappers.
298 struct x86_function
*func
,
302 DUMP_RR( "ADDPS", dst
, src
);
303 sse_addps( func
, dst
, src
);
308 struct x86_function
*func
,
312 DUMP_RR( "ANDNPS", dst
, src
);
313 sse_andnps( func
, dst
, src
);
318 struct x86_function
*func
,
322 DUMP_RR( "ANDPS", dst
, src
);
323 sse_andps( func
, dst
, src
);
328 struct x86_function
*func
,
331 DUMP_I( "CALL", addr
);
332 x86_call( func
, addr
);
337 struct x86_function
*func
,
342 DUMP_RRI( "CMPPS", dst
, src
, cc
);
343 sse_cmpps( func
, dst
, src
, cc
);
348 struct x86_function
*func
,
352 DUMP_RR( "CVTTPS2DQ", dst
, src
);
353 sse2_cvttps2dq( func
, dst
, src
);
358 struct x86_function
*func
,
362 DUMP_RR( "MAXPS", dst
, src
);
363 sse_maxps( func
, dst
, src
);
368 struct x86_function
*func
,
372 DUMP_RR( "MINPS", dst
, src
);
373 sse_minps( func
, dst
, src
);
378 struct x86_function
*func
,
382 DUMP_RR( "MOV", dst
, src
);
383 x86_mov( func
, dst
, src
);
388 struct x86_function
*func
,
392 DUMP_RR( "MOVAPS", dst
, src
);
393 sse_movaps( func
, dst
, src
);
398 struct x86_function
*func
,
402 DUMP_RR( "MOVSS", dst
, src
);
403 sse_movss( func
, dst
, src
);
408 struct x86_function
*func
,
412 DUMP_RR( "MOVUPS", dst
, src
);
413 sse_movups( func
, dst
, src
);
418 struct x86_function
*func
,
422 DUMP_RR( "MULPS", dst
, src
);
423 sse_mulps( func
, dst
, src
);
428 struct x86_function
*func
,
432 DUMP_RR( "OR", dst
, src
);
433 x86_or( func
, dst
, src
);
438 struct x86_function
*func
,
442 DUMP_RR( "ORPS", dst
, src
);
443 sse_orps( func
, dst
, src
);
448 struct x86_function
*func
,
452 DUMP_RR( "PMOVMSKB", dst
, src
);
453 sse_pmovmskb( func
, dst
, src
);
458 struct x86_function
*func
,
461 DUMP_R( "POP", dst
);
462 x86_pop( func
, dst
);
467 struct x86_function
*func
,
470 DUMP_R( "PUSH", dst
);
471 x86_push( func
, dst
);
476 struct x86_function
*func
,
480 DUMP_RR( "RCPPS", dst
, src
);
481 sse2_rcpps( func
, dst
, src
);
487 struct x86_function
*func
,
490 DUMP_I( "RET", size
);
491 x86_retw( func
, size
);
496 struct x86_function
*func
)
505 struct x86_function
*func
,
509 DUMP_RR( "RSQRTPS", dst
, src
);
510 sse_rsqrtps( func
, dst
, src
);
515 struct x86_function
*func
,
520 DUMP_RRI( "SHUFPS", dst
, src
, shuf
);
521 sse_shufps( func
, dst
, src
, shuf
);
526 struct x86_function
*func
,
530 DUMP_RR( "SUBPS", dst
, src
);
531 sse_subps( func
, dst
, src
);
536 struct x86_function
*func
,
540 DUMP_RR( "XORPS", dst
, src
);
541 sse_xorps( func
, dst
, src
);
545 * Data fetch helpers.
550 struct x86_function
*func
,
558 get_const( vec
, chan
) );
563 SHUF( 0, 0, 0, 0 ) );
568 struct x86_function
*func
,
576 get_input( vec
, chan
) );
581 struct x86_function
*func
,
588 get_output( vec
, chan
),
594 struct x86_function
*func
,
602 get_temp( vec
, chan
) );
607 struct x86_function
*func
,
616 get_coef( vec
, chan
, member
) );
621 SHUF( 0, 0, 0, 0 ) );
625 * Data store helpers.
630 struct x86_function
*func
,
637 get_input( vec
, chan
),
643 struct x86_function
*func
,
650 get_temp( vec
, chan
),
656 struct x86_function
*func
,
664 vec
+ TGSI_EXEC_NUM_TEMPS
,
669 * Coefficent fetch helpers.
674 struct x86_function
*func
,
689 struct x86_function
*func
,
704 struct x86_function
*func
,
718 * Function call helpers.
723 struct x86_function
*func
)
735 /* It is important on non-win32 platforms that temp base is pushed last.
744 struct x86_function
*func
)
746 /* Restore GP registers in a reverse order.
764 struct x86_function
*func
,
770 get_temp( TEMP_R0
, 0 ),
771 make_xmm( xmm_dst
) );
779 get_temp( TEMP_R0
, 0 ) );
792 get_temp( TEMP_R0
, 0 ) );
796 emit_func_call_dst_src(
797 struct x86_function
*func
,
804 get_temp( TEMP_R0
, 1 ),
805 make_xmm( xmm_src
) );
814 * Low-level instruction translators.
819 struct x86_function
*func
,
826 TGSI_EXEC_TEMP_7FFFFFFF_I
,
827 TGSI_EXEC_TEMP_7FFFFFFF_C
) );
832 struct x86_function
*func
,
839 make_xmm( xmm_src
) );
847 store
[0] = (float) cos( (double) store
[0] );
848 store
[1] = (float) cos( (double) store
[1] );
849 store
[2] = (float) cos( (double) store
[2] );
850 store
[3] = (float) cos( (double) store
[3] );
852 const unsigned X
= TEMP_R0
* 16;
853 store
[X
+ 0] = cosf( store
[X
+ 0] );
854 store
[X
+ 1] = cosf( store
[X
+ 1] );
855 store
[X
+ 2] = cosf( store
[X
+ 2] );
856 store
[X
+ 3] = cosf( store
[X
+ 3] );
862 struct x86_function
*func
,
876 store
[0] = (float) pow( 2.0, (double) store
[0] );
877 store
[1] = (float) pow( 2.0, (double) store
[1] );
878 store
[2] = (float) pow( 2.0, (double) store
[2] );
879 store
[3] = (float) pow( 2.0, (double) store
[3] );
881 const unsigned X
= TEMP_R0
* 16;
882 store
[X
+ 0] = powf( 2.0f
, store
[X
+ 0] );
883 store
[X
+ 1] = powf( 2.0f
, store
[X
+ 1] );
884 store
[X
+ 2] = powf( 2.0f
, store
[X
+ 2] );
885 store
[X
+ 3] = powf( 2.0f
, store
[X
+ 3] );
891 struct x86_function
*func
,
902 struct x86_function
*func
,
916 const unsigned X
= 0;
918 const unsigned X
= TEMP_R0
* 16;
920 store
[X
+ 0] = (float) floor( (double) store
[X
+ 0] );
921 store
[X
+ 1] = (float) floor( (double) store
[X
+ 1] );
922 store
[X
+ 2] = (float) floor( (double) store
[X
+ 2] );
923 store
[X
+ 3] = (float) floor( (double) store
[X
+ 3] );
928 struct x86_function
*func
,
942 const unsigned X
= 0;
944 const unsigned X
= TEMP_R0
* 16;
946 store
[X
+ 0] -= (float) floor( (double) store
[X
+ 0] );
947 store
[X
+ 1] -= (float) floor( (double) store
[X
+ 1] );
948 store
[X
+ 2] -= (float) floor( (double) store
[X
+ 2] );
949 store
[X
+ 3] -= (float) floor( (double) store
[X
+ 3] );
954 struct x86_function
*func
,
968 const unsigned X
= 0;
970 const unsigned X
= TEMP_R0
* 16;
972 store
[X
+ 0] = LOG2( store
[X
+ 0] );
973 store
[X
+ 1] = LOG2( store
[X
+ 1] );
974 store
[X
+ 2] = LOG2( store
[X
+ 2] );
975 store
[X
+ 3] = LOG2( store
[X
+ 3] );
980 struct x86_function
*func
,
991 struct x86_function
*func
,
998 make_xmm( xmm_src
) );
1002 emit_mul (struct x86_function
*func
,
1008 make_xmm( xmm_dst
),
1009 make_xmm( xmm_src
) );
1014 struct x86_function
*func
,
1021 TGSI_EXEC_TEMP_80000000_I
,
1022 TGSI_EXEC_TEMP_80000000_C
) );
1025 static void XSTDCALL
1030 store
[0] = (float) pow( (double) store
[0], (double) store
[4] );
1031 store
[1] = (float) pow( (double) store
[1], (double) store
[5] );
1032 store
[2] = (float) pow( (double) store
[2], (double) store
[6] );
1033 store
[3] = (float) pow( (double) store
[3], (double) store
[7] );
1035 const unsigned X
= TEMP_R0
* 16;
1036 store
[X
+ 0] = powf( store
[X
+ 0], store
[X
+ 4] );
1037 store
[X
+ 1] = powf( store
[X
+ 1], store
[X
+ 5] );
1038 store
[X
+ 2] = powf( store
[X
+ 2], store
[X
+ 6] );
1039 store
[X
+ 3] = powf( store
[X
+ 3], store
[X
+ 7] );
1045 struct x86_function
*func
,
1049 emit_func_call_dst_src(
1058 struct x86_function
*func
,
1064 make_xmm( xmm_dst
),
1065 make_xmm( xmm_src
) );
1070 struct x86_function
*func
,
1076 make_xmm( xmm_dst
),
1077 make_xmm( xmm_src
) );
1082 struct x86_function
*func
,
1089 TGSI_EXEC_TEMP_80000000_I
,
1090 TGSI_EXEC_TEMP_80000000_C
) );
1093 static void XSTDCALL
1098 store
[0] = (float) sin( (double) store
[0] );
1099 store
[1] = (float) sin( (double) store
[1] );
1100 store
[2] = (float) sin( (double) store
[2] );
1101 store
[3] = (float) sin( (double) store
[3] );
1103 const unsigned X
= TEMP_R0
* 16;
1104 store
[X
+ 0] = sinf( store
[X
+ 0] );
1105 store
[X
+ 1] = sinf( store
[X
+ 1] );
1106 store
[X
+ 2] = sinf( store
[X
+ 2] );
1107 store
[X
+ 3] = sinf( store
[X
+ 3] );
1112 emit_sin (struct x86_function
*func
,
1123 struct x86_function
*func
,
1129 make_xmm( xmm_dst
),
1130 make_xmm( xmm_src
) );
1139 struct x86_function
*func
,
1141 const struct tgsi_full_src_register
*reg
,
1142 const unsigned chan_index
)
1144 unsigned swizzle
= tgsi_util_get_full_src_register_extswizzle( reg
, chan_index
);
1147 case TGSI_EXTSWIZZLE_X
:
1148 case TGSI_EXTSWIZZLE_Y
:
1149 case TGSI_EXTSWIZZLE_Z
:
1150 case TGSI_EXTSWIZZLE_W
:
1151 switch( reg
->SrcRegister
.File
) {
1152 case TGSI_FILE_CONSTANT
:
1156 reg
->SrcRegister
.Index
,
1160 case TGSI_FILE_INPUT
:
1164 reg
->SrcRegister
.Index
,
1168 case TGSI_FILE_TEMPORARY
:
1172 reg
->SrcRegister
.Index
,
1181 case TGSI_EXTSWIZZLE_ZERO
:
1185 TGSI_EXEC_TEMP_00000000_I
,
1186 TGSI_EXEC_TEMP_00000000_C
);
1189 case TGSI_EXTSWIZZLE_ONE
:
1193 TGSI_EXEC_TEMP_ONE_I
,
1194 TGSI_EXEC_TEMP_ONE_C
);
1201 switch( tgsi_util_get_full_src_register_sign_mode( reg
, chan_index
) ) {
1202 case TGSI_UTIL_SIGN_CLEAR
:
1203 emit_abs( func
, xmm
);
1206 case TGSI_UTIL_SIGN_SET
:
1207 emit_setsign( func
, xmm
);
1210 case TGSI_UTIL_SIGN_TOGGLE
:
1211 emit_neg( func
, xmm
);
1214 case TGSI_UTIL_SIGN_KEEP
:
1219 #define FETCH( FUNC, INST, XMM, INDEX, CHAN )\
1220 emit_fetch( FUNC, XMM, &(INST).FullSrcRegisters[INDEX], CHAN )
1228 struct x86_function
*func
,
1230 const struct tgsi_full_dst_register
*reg
,
1231 const struct tgsi_full_instruction
*inst
,
1232 unsigned chan_index
)
1234 switch( reg
->DstRegister
.File
) {
1235 case TGSI_FILE_OUTPUT
:
1239 reg
->DstRegister
.Index
,
1243 case TGSI_FILE_TEMPORARY
:
1247 reg
->DstRegister
.Index
,
1251 case TGSI_FILE_ADDRESS
:
1255 reg
->DstRegister
.Index
,
1263 switch( inst
->Instruction
.Saturate
) {
1267 case TGSI_SAT_ZERO_ONE
:
1271 case TGSI_SAT_MINUS_PLUS_ONE
:
1277 #define STORE( FUNC, INST, XMM, INDEX, CHAN )\
1278 emit_store( FUNC, XMM, &(INST).FullDstRegisters[INDEX], &(INST), CHAN )
1281 * High-level instruction translators.
1286 struct x86_function
*func
,
1287 const struct tgsi_full_src_register
*reg
)
1289 unsigned uniquemask
;
1290 unsigned registers
[4];
1291 unsigned nextregister
= 0;
1292 unsigned firstchan
= ~0;
1293 unsigned chan_index
;
1295 /* This mask stores component bits that were already tested. Note that
1296 * we test if the value is less than zero, so 1.0 and 0.0 need not to be
1298 uniquemask
= (1 << TGSI_EXTSWIZZLE_ZERO
) | (1 << TGSI_EXTSWIZZLE_ONE
);
1300 FOR_EACH_CHANNEL( chan_index
) {
1303 /* unswizzle channel */
1304 swizzle
= tgsi_util_get_full_src_register_extswizzle(
1308 /* check if the component has not been already tested */
1309 if( !(uniquemask
& (1 << swizzle
)) ) {
1310 uniquemask
|= 1 << swizzle
;
1312 /* allocate register */
1313 registers
[chan_index
] = nextregister
;
1321 /* mark the first channel used */
1322 if( firstchan
== ~0 ) {
1323 firstchan
= chan_index
;
1330 x86_make_reg( file_REG32
, reg_AX
) );
1333 x86_make_reg( file_REG32
, reg_DX
) );
1335 FOR_EACH_CHANNEL( chan_index
) {
1336 if( uniquemask
& (1 << chan_index
) ) {
1339 make_xmm( registers
[chan_index
] ),
1341 TGSI_EXEC_TEMP_00000000_I
,
1342 TGSI_EXEC_TEMP_00000000_C
),
1345 if( chan_index
== firstchan
) {
1348 x86_make_reg( file_REG32
, reg_AX
),
1349 make_xmm( registers
[chan_index
] ) );
1354 x86_make_reg( file_REG32
, reg_DX
),
1355 make_xmm( registers
[chan_index
] ) );
1358 x86_make_reg( file_REG32
, reg_AX
),
1359 x86_make_reg( file_REG32
, reg_DX
) );
1367 TGSI_EXEC_TEMP_KILMASK_I
,
1368 TGSI_EXEC_TEMP_KILMASK_C
),
1369 x86_make_reg( file_REG32
, reg_AX
) );
1373 x86_make_reg( file_REG32
, reg_DX
) );
1376 x86_make_reg( file_REG32
, reg_AX
) );
1381 struct x86_function
*func
,
1382 struct tgsi_full_instruction
*inst
,
1385 unsigned chan_index
;
1387 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1388 FETCH( func
, *inst
, 0, 0, chan_index
);
1389 FETCH( func
, *inst
, 1, 1, chan_index
);
1399 TGSI_EXEC_TEMP_ONE_I
,
1400 TGSI_EXEC_TEMP_ONE_C
) );
1401 STORE( func
, *inst
, 0, 0, chan_index
);
1407 struct x86_function
*func
,
1408 struct tgsi_full_instruction
*inst
)
1410 unsigned chan_index
;
1412 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1413 FETCH( func
, *inst
, 0, 0, chan_index
);
1414 FETCH( func
, *inst
, 1, 1, chan_index
);
1415 FETCH( func
, *inst
, 2, 2, chan_index
);
1420 TGSI_EXEC_TEMP_00000000_I
,
1421 TGSI_EXEC_TEMP_00000000_C
),
1435 STORE( func
, *inst
, 0, 0, chan_index
);
1441 struct x86_function
*func
,
1442 struct tgsi_full_instruction
*inst
)
1444 unsigned chan_index
;
1446 switch( inst
->Instruction
.Opcode
) {
1447 case TGSI_OPCODE_ARL
:
1448 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1449 FETCH( func
, *inst
, 0, 0, chan_index
);
1450 emit_f2it( func
, 0 );
1451 STORE( func
, *inst
, 0, 0, chan_index
);
1455 case TGSI_OPCODE_MOV
:
1456 /* TGSI_OPCODE_SWZ */
1457 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1458 FETCH( func
, *inst
, 0, 0, chan_index
);
1459 STORE( func
, *inst
, 0, 0, chan_index
);
1463 case TGSI_OPCODE_LIT
:
1464 if( IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_X
) ||
1465 IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_W
) ) {
1469 TGSI_EXEC_TEMP_ONE_I
,
1470 TGSI_EXEC_TEMP_ONE_C
);
1471 if( IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_X
) ) {
1472 STORE( func
, *inst
, 0, 0, CHAN_X
);
1474 if( IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_W
) ) {
1475 STORE( func
, *inst
, 0, 0, CHAN_W
);
1478 if( IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Y
) ||
1479 IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Z
) ) {
1480 if( IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Y
) ) {
1481 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1486 TGSI_EXEC_TEMP_00000000_I
,
1487 TGSI_EXEC_TEMP_00000000_C
) );
1488 STORE( func
, *inst
, 0, 0, CHAN_Y
);
1490 if( IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Z
) ) {
1491 FETCH( func
, *inst
, 1, 0, CHAN_Y
);
1496 TGSI_EXEC_TEMP_00000000_I
,
1497 TGSI_EXEC_TEMP_00000000_C
) );
1498 FETCH( func
, *inst
, 2, 0, CHAN_W
);
1503 TGSI_EXEC_TEMP_128_I
,
1504 TGSI_EXEC_TEMP_128_C
) );
1509 TGSI_EXEC_TEMP_MINUS_128_I
,
1510 TGSI_EXEC_TEMP_MINUS_128_C
) );
1511 emit_pow( func
, 1, 2 );
1512 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1526 STORE( func
, *inst
, 2, 0, CHAN_Z
);
1531 case TGSI_OPCODE_RCP
:
1532 /* TGSI_OPCODE_RECIP */
1533 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1534 emit_rcp( func
, 0, 0 );
1535 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1536 STORE( func
, *inst
, 0, 0, chan_index
);
1540 case TGSI_OPCODE_RSQ
:
1541 /* TGSI_OPCODE_RECIPSQRT */
1542 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1543 emit_rsqrt( func
, 0, 0 );
1544 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1545 STORE( func
, *inst
, 0, 0, chan_index
);
1549 case TGSI_OPCODE_EXP
:
1553 case TGSI_OPCODE_LOG
:
1557 case TGSI_OPCODE_MUL
:
1558 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1559 FETCH( func
, *inst
, 0, 0, chan_index
);
1560 FETCH( func
, *inst
, 1, 1, chan_index
);
1561 emit_mul( func
, 0, 1 );
1562 STORE( func
, *inst
, 0, 0, chan_index
);
1566 case TGSI_OPCODE_ADD
:
1567 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1568 FETCH( func
, *inst
, 0, 0, chan_index
);
1569 FETCH( func
, *inst
, 1, 1, chan_index
);
1570 emit_add( func
, 0, 1 );
1571 STORE( func
, *inst
, 0, 0, chan_index
);
1575 case TGSI_OPCODE_DP3
:
1576 /* TGSI_OPCODE_DOT3 */
1577 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1578 FETCH( func
, *inst
, 1, 1, CHAN_X
);
1579 emit_mul( func
, 0, 1 );
1580 FETCH( func
, *inst
, 1, 0, CHAN_Y
);
1581 FETCH( func
, *inst
, 2, 1, CHAN_Y
);
1582 emit_mul( func
, 1, 2 );
1583 emit_add( func
, 0, 1 );
1584 FETCH( func
, *inst
, 1, 0, CHAN_Z
);
1585 FETCH( func
, *inst
, 2, 1, CHAN_Z
);
1586 emit_mul( func
, 1, 2 );
1587 emit_add( func
, 0, 1 );
1588 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1589 STORE( func
, *inst
, 0, 0, chan_index
);
1593 case TGSI_OPCODE_DP4
:
1594 /* TGSI_OPCODE_DOT4 */
1595 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1596 FETCH( func
, *inst
, 1, 1, CHAN_X
);
1597 emit_mul( func
, 0, 1 );
1598 FETCH( func
, *inst
, 1, 0, CHAN_Y
);
1599 FETCH( func
, *inst
, 2, 1, CHAN_Y
);
1600 emit_mul( func
, 1, 2 );
1601 emit_add( func
, 0, 1 );
1602 FETCH( func
, *inst
, 1, 0, CHAN_Z
);
1603 FETCH( func
, *inst
, 2, 1, CHAN_Z
);
1604 emit_mul(func
, 1, 2 );
1605 emit_add(func
, 0, 1 );
1606 FETCH( func
, *inst
, 1, 0, CHAN_W
);
1607 FETCH( func
, *inst
, 2, 1, CHAN_W
);
1608 emit_mul( func
, 1, 2 );
1609 emit_add( func
, 0, 1 );
1610 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1611 STORE( func
, *inst
, 0, 0, chan_index
);
1615 case TGSI_OPCODE_DST
:
1616 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_X
) {
1620 TGSI_EXEC_TEMP_ONE_I
,
1621 TGSI_EXEC_TEMP_ONE_C
);
1622 STORE( func
, *inst
, 0, 0, CHAN_X
);
1624 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Y
) {
1625 FETCH( func
, *inst
, 0, 0, CHAN_Y
);
1626 FETCH( func
, *inst
, 1, 1, CHAN_Y
);
1627 emit_mul( func
, 0, 1 );
1628 STORE( func
, *inst
, 0, 0, CHAN_Y
);
1630 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Z
) {
1631 FETCH( func
, *inst
, 0, 0, CHAN_Z
);
1632 STORE( func
, *inst
, 0, 0, CHAN_Z
);
1634 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_W
) {
1635 FETCH( func
, *inst
, 0, 1, CHAN_W
);
1636 STORE( func
, *inst
, 0, 0, CHAN_W
);
1640 case TGSI_OPCODE_MIN
:
1641 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1642 FETCH( func
, *inst
, 0, 0, chan_index
);
1643 FETCH( func
, *inst
, 1, 1, chan_index
);
1648 STORE( func
, *inst
, 0, 0, chan_index
);
1652 case TGSI_OPCODE_MAX
:
1653 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1654 FETCH( func
, *inst
, 0, 0, chan_index
);
1655 FETCH( func
, *inst
, 1, 1, chan_index
);
1660 STORE( func
, *inst
, 0, 0, chan_index
);
1664 case TGSI_OPCODE_SLT
:
1665 /* TGSI_OPCODE_SETLT */
1666 emit_setcc( func
, inst
, cc_LessThan
);
1669 case TGSI_OPCODE_SGE
:
1670 /* TGSI_OPCODE_SETGE */
1671 emit_setcc( func
, inst
, cc_NotLessThan
);
1674 case TGSI_OPCODE_MAD
:
1675 /* TGSI_OPCODE_MADD */
1676 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1677 FETCH( func
, *inst
, 0, 0, chan_index
);
1678 FETCH( func
, *inst
, 1, 1, chan_index
);
1679 FETCH( func
, *inst
, 2, 2, chan_index
);
1680 emit_mul( func
, 0, 1 );
1681 emit_add( func
, 0, 2 );
1682 STORE( func
, *inst
, 0, 0, chan_index
);
1686 case TGSI_OPCODE_SUB
:
1687 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1688 FETCH( func
, *inst
, 0, 0, chan_index
);
1689 FETCH( func
, *inst
, 1, 1, chan_index
);
1690 emit_sub( func
, 0, 1 );
1691 STORE( func
, *inst
, 0, 0, chan_index
);
1695 case TGSI_OPCODE_LERP
:
1696 /* TGSI_OPCODE_LRP */
1697 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1698 FETCH( func
, *inst
, 0, 0, chan_index
);
1699 FETCH( func
, *inst
, 1, 1, chan_index
);
1700 FETCH( func
, *inst
, 2, 2, chan_index
);
1701 emit_sub( func
, 1, 2 );
1702 emit_mul( func
, 0, 1 );
1703 emit_add( func
, 0, 2 );
1704 STORE( func
, *inst
, 0, 0, chan_index
);
1708 case TGSI_OPCODE_CND
:
1712 case TGSI_OPCODE_CND0
:
1716 case TGSI_OPCODE_DOT2ADD
:
1717 /* TGSI_OPCODE_DP2A */
1721 case TGSI_OPCODE_INDEX
:
1725 case TGSI_OPCODE_NEGATE
:
1729 case TGSI_OPCODE_FRAC
:
1730 /* TGSI_OPCODE_FRC */
1731 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1732 FETCH( func
, *inst
, 0, 0, chan_index
);
1733 emit_frc( func
, 0 );
1734 STORE( func
, *inst
, 0, 0, chan_index
);
1738 case TGSI_OPCODE_CLAMP
:
1742 case TGSI_OPCODE_FLOOR
:
1743 /* TGSI_OPCODE_FLR */
1744 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1745 FETCH( func
, *inst
, 0, 0, chan_index
);
1746 emit_flr( func
, 0 );
1747 STORE( func
, *inst
, 0, 0, chan_index
);
1751 case TGSI_OPCODE_ROUND
:
1755 case TGSI_OPCODE_EXPBASE2
:
1756 /* TGSI_OPCODE_EX2 */
1757 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1758 emit_ex2( func
, 0 );
1759 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1760 STORE( func
, *inst
, 0, 0, chan_index
);
1764 case TGSI_OPCODE_LOGBASE2
:
1765 /* TGSI_OPCODE_LG2 */
1766 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1767 emit_lg2( func
, 0 );
1768 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1769 STORE( func
, *inst
, 0, 0, chan_index
);
1773 case TGSI_OPCODE_POWER
:
1774 /* TGSI_OPCODE_POW */
1775 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1776 FETCH( func
, *inst
, 1, 1, CHAN_X
);
1777 emit_pow( func
, 0, 1 );
1778 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1779 STORE( func
, *inst
, 0, 0, chan_index
);
1783 case TGSI_OPCODE_CROSSPRODUCT
:
1784 /* TGSI_OPCODE_XPD */
1785 if( IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_X
) ||
1786 IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Y
) ) {
1787 FETCH( func
, *inst
, 1, 1, CHAN_Z
);
1788 FETCH( func
, *inst
, 3, 0, CHAN_Z
);
1790 if( IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_X
) ||
1791 IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Z
) ) {
1792 FETCH( func
, *inst
, 0, 0, CHAN_Y
);
1793 FETCH( func
, *inst
, 4, 1, CHAN_Y
);
1795 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_X
) {
1796 emit_MOV( func
, 2, 0 );
1797 emit_mul( func
, 2, 1 );
1798 emit_MOV( func
, 5, 3 );
1799 emit_mul( func
, 5, 4 );
1800 emit_sub( func
, 2, 5 );
1801 STORE( func
, *inst
, 2, 0, CHAN_X
);
1803 if( IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Y
) ||
1804 IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Z
) ) {
1805 FETCH( func
, *inst
, 2, 1, CHAN_X
);
1806 FETCH( func
, *inst
, 5, 0, CHAN_X
);
1808 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Y
) {
1809 emit_mul( func
, 3, 2 );
1810 emit_mul( func
, 1, 5 );
1811 emit_sub( func
, 3, 1 );
1812 STORE( func
, *inst
, 3, 0, CHAN_Y
);
1814 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Z
) {
1815 emit_mul( func
, 5, 4 );
1816 emit_mul( func
, 0, 2 );
1817 emit_sub( func
, 5, 0 );
1818 STORE( func
, *inst
, 5, 0, CHAN_Z
);
1820 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_W
) {
1821 FETCH( func
, *inst
, 0, TGSI_EXEC_TEMP_ONE_I
, TGSI_EXEC_TEMP_ONE_C
);
1822 STORE( func
, *inst
, 0, 0, CHAN_W
);
1826 case TGSI_OPCODE_MULTIPLYMATRIX
:
1830 case TGSI_OPCODE_ABS
:
1831 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1832 FETCH( func
, *inst
, 0, 0, chan_index
);
1833 emit_abs( func
, 0) ;
1835 STORE( func
, *inst
, 0, 0, chan_index
);
1839 case TGSI_OPCODE_RCC
:
1843 case TGSI_OPCODE_DPH
:
1844 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1845 FETCH( func
, *inst
, 1, 1, CHAN_X
);
1846 emit_mul( func
, 0, 1 );
1847 FETCH( func
, *inst
, 1, 0, CHAN_Y
);
1848 FETCH( func
, *inst
, 2, 1, CHAN_Y
);
1849 emit_mul( func
, 1, 2 );
1850 emit_add( func
, 0, 1 );
1851 FETCH( func
, *inst
, 1, 0, CHAN_Z
);
1852 FETCH( func
, *inst
, 2, 1, CHAN_Z
);
1853 emit_mul( func
, 1, 2 );
1854 emit_add( func
, 0, 1 );
1855 FETCH( func
, *inst
, 1, 1, CHAN_W
);
1856 emit_add( func
, 0, 1 );
1857 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1858 STORE( func
, *inst
, 0, 0, chan_index
);
1862 case TGSI_OPCODE_COS
:
1863 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1864 emit_cos( func
, 0 );
1865 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1866 STORE( func
, *inst
, 0, 0, chan_index
);
1870 case TGSI_OPCODE_DDX
:
1874 case TGSI_OPCODE_DDY
:
1878 case TGSI_OPCODE_KIL
:
1879 emit_kil( func
, &inst
->FullSrcRegisters
[0] );
1882 case TGSI_OPCODE_PK2H
:
1886 case TGSI_OPCODE_PK2US
:
1890 case TGSI_OPCODE_PK4B
:
1894 case TGSI_OPCODE_PK4UB
:
1898 case TGSI_OPCODE_RFL
:
1902 case TGSI_OPCODE_SEQ
:
1906 case TGSI_OPCODE_SFL
:
1910 case TGSI_OPCODE_SGT
:
1914 case TGSI_OPCODE_SIN
:
1915 FETCH( func
, *inst
, 0, 0, CHAN_X
);
1916 emit_sin( func
, 0 );
1917 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1918 STORE( func
, *inst
, 0, 0, chan_index
);
1922 case TGSI_OPCODE_SLE
:
1926 case TGSI_OPCODE_SNE
:
1930 case TGSI_OPCODE_STR
:
1934 case TGSI_OPCODE_TEX
:
1938 TGSI_EXEC_TEMP_ONE_I
,
1939 TGSI_EXEC_TEMP_ONE_C
);
1940 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
1941 STORE( func
, *inst
, 0, 0, chan_index
);
1945 case TGSI_OPCODE_TXD
:
1949 case TGSI_OPCODE_UP2H
:
1953 case TGSI_OPCODE_UP2US
:
1957 case TGSI_OPCODE_UP4B
:
1961 case TGSI_OPCODE_UP4UB
:
1965 case TGSI_OPCODE_X2D
:
1969 case TGSI_OPCODE_ARA
:
1973 case TGSI_OPCODE_ARR
:
1977 case TGSI_OPCODE_BRA
:
1981 case TGSI_OPCODE_CAL
:
1985 case TGSI_OPCODE_RET
:
1986 case TGSI_OPCODE_END
:
1988 emit_retw( func
, 16 );
1994 case TGSI_OPCODE_SSG
:
1998 case TGSI_OPCODE_CMP
:
1999 emit_cmp (func
, inst
);
2002 case TGSI_OPCODE_SCS
:
2003 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_X
) {
2004 FETCH( func
, *inst
, 0, 0, CHAN_X
);
2005 emit_cos( func
, 0 );
2006 STORE( func
, *inst
, 0, 0, CHAN_X
);
2008 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Y
) {
2009 FETCH( func
, *inst
, 0, 0, CHAN_Y
);
2010 emit_sin( func
, 0 );
2011 STORE( func
, *inst
, 0, 0, CHAN_Y
);
2013 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_Z
) {
2014 FETCH( func
, *inst
, 0, TGSI_EXEC_TEMP_00000000_I
, TGSI_EXEC_TEMP_00000000_C
);
2015 STORE( func
, *inst
, 0, 0, CHAN_Z
);
2017 IF_IS_DST0_CHANNEL_ENABLED( *inst
, CHAN_W
) {
2018 FETCH( func
, *inst
, 0, TGSI_EXEC_TEMP_ONE_I
, TGSI_EXEC_TEMP_ONE_C
);
2019 STORE( func
, *inst
, 0, 0, CHAN_W
);
2023 case TGSI_OPCODE_TXB
:
2027 case TGSI_OPCODE_NRM
:
2031 case TGSI_OPCODE_DIV
:
2035 case TGSI_OPCODE_DP2
:
2039 case TGSI_OPCODE_TXL
:
2043 case TGSI_OPCODE_BRK
:
2047 case TGSI_OPCODE_IF
:
2051 case TGSI_OPCODE_LOOP
:
2055 case TGSI_OPCODE_REP
:
2059 case TGSI_OPCODE_ELSE
:
2063 case TGSI_OPCODE_ENDIF
:
2067 case TGSI_OPCODE_ENDLOOP
:
2071 case TGSI_OPCODE_ENDREP
:
2075 case TGSI_OPCODE_PUSHA
:
2079 case TGSI_OPCODE_POPA
:
2083 case TGSI_OPCODE_CEIL
:
2087 case TGSI_OPCODE_I2F
:
2091 case TGSI_OPCODE_NOT
:
2095 case TGSI_OPCODE_TRUNC
:
2099 case TGSI_OPCODE_SHL
:
2103 case TGSI_OPCODE_SHR
:
2107 case TGSI_OPCODE_AND
:
2111 case TGSI_OPCODE_OR
:
2115 case TGSI_OPCODE_MOD
:
2119 case TGSI_OPCODE_XOR
:
2123 case TGSI_OPCODE_SAD
:
2127 case TGSI_OPCODE_TXF
:
2131 case TGSI_OPCODE_TXQ
:
2135 case TGSI_OPCODE_CONT
:
2139 case TGSI_OPCODE_EMIT
:
2143 case TGSI_OPCODE_ENDPRIM
:
2154 struct x86_function
*func
,
2155 struct tgsi_full_declaration
*decl
)
2157 if( decl
->Declaration
.File
== TGSI_FILE_INPUT
) {
2158 unsigned first
, last
, mask
;
2161 assert( decl
->Declaration
.Declare
== TGSI_DECLARE_RANGE
);
2163 first
= decl
->u
.DeclarationRange
.First
;
2164 last
= decl
->u
.DeclarationRange
.Last
;
2165 mask
= decl
->Declaration
.UsageMask
;
2167 /* Do not touch WPOS.xy */
2169 mask
&= ~TGSI_WRITEMASK_XY
;
2170 if( mask
== TGSI_WRITEMASK_NONE
) {
2175 for( i
= first
; i
<= last
; i
++ ) {
2176 for( j
= 0; j
< NUM_CHANNELS
; j
++ ) {
2177 if( mask
& (1 << j
) ) {
2178 switch( decl
->Interpolation
.Interpolate
) {
2179 case TGSI_INTERPOLATE_CONSTANT
:
2180 emit_coef_a0( func
, 0, i
, j
);
2181 emit_inputs( func
, 0, i
, j
);
2184 case TGSI_INTERPOLATE_LINEAR
:
2185 emit_inputf( func
, 0, 0, TGSI_SWIZZLE_X
);
2186 emit_coef_dadx( func
, 1, i
, j
);
2187 emit_inputf( func
, 2, 0, TGSI_SWIZZLE_Y
);
2188 emit_coef_dady( func
, 3, i
, j
);
2189 emit_mul( func
, 0, 1 ); /* x * dadx */
2190 emit_coef_a0( func
, 4, i
, j
);
2191 emit_mul( func
, 2, 3 ); /* y * dady */
2192 emit_add( func
, 0, 4 ); /* x * dadx + a0 */
2193 emit_add( func
, 0, 2 ); /* x * dadx + y * dady + a0 */
2194 emit_inputs( func
, 0, i
, j
);
2197 case TGSI_INTERPOLATE_PERSPECTIVE
:
2198 emit_inputf( func
, 0, 0, TGSI_SWIZZLE_X
);
2199 emit_coef_dadx( func
, 1, i
, j
);
2200 emit_inputf( func
, 2, 0, TGSI_SWIZZLE_Y
);
2201 emit_coef_dady( func
, 3, i
, j
);
2202 emit_mul( func
, 0, 1 ); /* x * dadx */
2203 emit_inputf( func
, 4, 0, TGSI_SWIZZLE_W
);
2204 emit_coef_a0( func
, 5, i
, j
);
2205 emit_rcp( func
, 4, 4 ); /* 1.0 / w */
2206 emit_mul( func
, 2, 3 ); /* y * dady */
2207 emit_add( func
, 0, 5 ); /* x * dadx + a0 */
2208 emit_add( func
, 0, 2 ); /* x * dadx + y * dady + a0 */
2209 emit_mul( func
, 0, 4 ); /* (x * dadx + y * dady + a0) / w */
2210 emit_inputs( func
, 0, i
, j
);
2224 struct tgsi_token
*tokens
,
2225 struct x86_function
*func
)
2227 struct tgsi_parse_context parse
;
2231 func
->csr
= func
->store
;
2236 get_argument( 0 ) );
2240 get_argument( 1 ) );
2244 get_argument( 2 ) );
2248 get_argument( 3 ) );
2250 tgsi_parse_init( &parse
, tokens
);
2252 while( !tgsi_parse_end_of_tokens( &parse
) ) {
2253 tgsi_parse_token( &parse
);
2255 switch( parse
.FullToken
.Token
.Type
) {
2256 case TGSI_TOKEN_TYPE_DECLARATION
:
2259 case TGSI_TOKEN_TYPE_INSTRUCTION
:
2262 &parse
.FullToken
.FullInstruction
);
2265 case TGSI_TOKEN_TYPE_IMMEDIATE
:
2266 /* XXX implement this */
2274 tgsi_parse_free( &parse
);
2282 * Fragment shaders are responsible for interpolating shader inputs. Because on
2283 * x86 we have only 4 GP registers, and here we have 5 shader arguments (input,
2284 * output, const, temp and coef), the code is split into two phases --
2285 * DECLARATION and INSTRUCTION phase.
2286 * GP register holding the output argument is aliased with the coeff argument,
2287 * as outputs are not needed in the DECLARATION phase.
2291 struct tgsi_token
*tokens
,
2292 struct x86_function
*func
)
2294 struct tgsi_parse_context parse
;
2295 boolean instruction_phase
= FALSE
;
2299 func
->csr
= func
->store
;
2301 /* DECLARATION phase, do not load output argument. */
2305 get_argument( 0 ) );
2309 get_argument( 2 ) );
2313 get_argument( 3 ) );
2317 get_argument( 4 ) );
2319 tgsi_parse_init( &parse
, tokens
);
2321 while( !tgsi_parse_end_of_tokens( &parse
) ) {
2322 tgsi_parse_token( &parse
);
2324 switch( parse
.FullToken
.Token
.Type
) {
2325 case TGSI_TOKEN_TYPE_DECLARATION
:
2328 &parse
.FullToken
.FullDeclaration
);
2331 case TGSI_TOKEN_TYPE_INSTRUCTION
:
2332 if( !instruction_phase
) {
2333 /* INSTRUCTION phase, overwrite coeff with output. */
2334 instruction_phase
= TRUE
;
2338 get_argument( 1 ) );
2342 &parse
.FullToken
.FullInstruction
);
2345 case TGSI_TOKEN_TYPE_IMMEDIATE
:
2346 /* XXX implement this */
2355 tgsi_parse_free( &parse
);