2 * Mesa 3-D graphics library
5 * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * \file slang_execute.c
27 * intermediate code interpreter
32 #include "slang_compile.h"
33 #include "slang_execute.h"
34 #include "slang_library_noise.h"
35 #include "slang_library_texsample.h"
39 GLvoid
slang_machine_ctr (slang_machine
*self
)
41 slang_machine_init (self
);
43 #if defined(USE_X86_ASM) || defined(SLANG_X86)
44 self
->x86
.compiled_func
= NULL
;
48 GLvoid
slang_machine_dtr (slang_machine
*self
)
50 if (self
->infolog
!= NULL
) {
51 slang_info_log_destruct (self
->infolog
);
52 slang_alloc_free (self
->infolog
);
54 #if defined(USE_X86_ASM) || defined(SLANG_X86)
55 if (self
->x86
.compiled_func
!= NULL
)
56 _mesa_exec_free (self
->x86
.compiled_func
);
60 void slang_machine_init (slang_machine
*mach
)
63 mach
->sp
= SLANG_MACHINE_STACK_SIZE
;
71 static void dump_instruction (FILE *f
, slang_assembly
*a
, unsigned int i
)
73 fprintf (f
, "%.5u:\t", i
);
81 case slang_asm_float_copy
:
82 fprintf (f
, "float_copy\t%d, %d", a
->param
[0], a
->param
[1]);
84 case slang_asm_float_move
:
85 fprintf (f
, "float_move\t%d, %d", a
->param
[0], a
->param
[1]);
87 case slang_asm_float_push
:
88 fprintf (f
, "float_push\t%f", a
->literal
);
90 case slang_asm_float_deref
:
91 fprintf (f
, "float_deref");
93 case slang_asm_float_add
:
94 fprintf (f
, "float_add");
96 case slang_asm_float_multiply
:
97 fprintf (f
, "float_multiply");
99 case slang_asm_float_divide
:
100 fprintf (f
, "float_divide");
102 case slang_asm_float_negate
:
103 fprintf (f
, "float_negate");
105 case slang_asm_float_less
:
106 fprintf (f
, "float_less");
108 case slang_asm_float_equal_exp
:
109 fprintf (f
, "float_equal");
111 case slang_asm_float_equal_int
:
112 fprintf (f
, "float_equal\t%d, %d", a
->param
[0], a
->param
[1]);
114 case slang_asm_float_to_int
:
115 fprintf (f
, "float_to_int");
117 case slang_asm_float_sine
:
118 fprintf (f
, "float_sine");
120 case slang_asm_float_arcsine
:
121 fprintf (f
, "float_arcsine");
123 case slang_asm_float_arctan
:
124 fprintf (f
, "float_arctan");
126 case slang_asm_float_power
:
127 fprintf (f
, "float_power");
129 case slang_asm_float_log2
:
130 fprintf (f
, "float_log2");
132 case slang_asm_float_floor
:
133 fprintf (f
, "float_floor");
135 case slang_asm_float_ceil
:
136 fprintf (f
, "float_ceil");
138 case slang_asm_float_noise1
:
139 fprintf (f
, "float_noise1");
141 case slang_asm_float_noise2
:
142 fprintf (f
, "float_noise2");
144 case slang_asm_float_noise3
:
145 fprintf (f
, "float_noise3");
147 case slang_asm_float_noise4
:
148 fprintf (f
, "float_noise4");
150 case slang_asm_int_copy
:
151 fprintf (f
, "int_copy\t%d, %d", a
->param
[0], a
->param
[1]);
153 case slang_asm_int_move
:
154 fprintf (f
, "int_move\t%d, %d", a
->param
[0], a
->param
[1]);
156 case slang_asm_int_push
:
157 fprintf (f
, "int_push\t%d", (GLint
) a
->literal
);
159 case slang_asm_int_deref
:
160 fprintf (f
, "int_deref");
162 case slang_asm_int_to_float
:
163 fprintf (f
, "int_to_float");
165 case slang_asm_int_to_addr
:
166 fprintf (f
, "int_to_addr");
168 case slang_asm_bool_copy
:
169 fprintf (f
, "bool_copy\t%d, %d", a
->param
[0], a
->param
[1]);
171 case slang_asm_bool_move
:
172 fprintf (f
, "bool_move\t%d, %d", a
->param
[0], a
->param
[1]);
174 case slang_asm_bool_push
:
175 fprintf (f
, "bool_push\t%d", a
->literal
!= 0.0f
);
177 case slang_asm_bool_deref
:
178 fprintf (f
, "bool_deref");
180 case slang_asm_addr_copy
:
181 fprintf (f
, "addr_copy");
183 case slang_asm_addr_push
:
184 fprintf (f
, "addr_push\t%u", a
->param
[0]);
186 case slang_asm_addr_deref
:
187 fprintf (f
, "addr_deref");
189 case slang_asm_addr_add
:
190 fprintf (f
, "addr_add");
192 case slang_asm_addr_multiply
:
193 fprintf (f
, "addr_multiply");
195 case slang_asm_vec4_tex1d
:
196 fprintf (f
, "vec4_tex1d");
198 case slang_asm_vec4_tex2d
:
199 fprintf (f
, "vec4_tex2d");
201 case slang_asm_vec4_tex3d
:
202 fprintf (f
, "vec4_tex3d");
204 case slang_asm_vec4_texcube
:
205 fprintf (f
, "vec4_texcube");
207 case slang_asm_vec4_shad1d
:
208 fprintf (f
, "vec4_shad1d");
210 case slang_asm_vec4_shad2d
:
211 fprintf (f
, "vec4_shad2d");
214 fprintf (f
, "jump\t%u", a
->param
[0]);
216 case slang_asm_jump_if_zero
:
217 fprintf (f
, "jump_if_zero\t%u", a
->param
[0]);
219 case slang_asm_enter
:
220 fprintf (f
, "enter\t%u", a
->param
[0]);
222 case slang_asm_leave
:
223 fprintf (f
, "leave");
225 case slang_asm_local_alloc
:
226 fprintf (f
, "local_alloc\t%u", a
->param
[0]);
228 case slang_asm_local_free
:
229 fprintf (f
, "local_free\t%u", a
->param
[0]);
231 case slang_asm_local_addr
:
232 fprintf (f
, "local_addr\t%u, %u", a
->param
[0], a
->param
[1]);
234 case slang_asm_global_addr
:
235 fprintf (f
, "global_addr\t%u", a
->param
[0]);
238 fprintf (f
, "call\t%u", a
->param
[0]);
240 case slang_asm_return
:
241 fprintf (f
, "return");
243 case slang_asm_discard
:
244 fprintf (f
, "discard");
249 /* GL_MESA_shader_debug */
250 case slang_asm_float_print
:
251 fprintf (f
, "float_print");
253 case slang_asm_int_print
:
254 fprintf (f
, "int_print");
256 case slang_asm_bool_print
:
257 fprintf (f
, "bool_print");
260 case slang_asm_float_to_vec4
:
261 fprintf (f
, "float_to_vec4");
263 case slang_asm_vec4_add
:
264 fprintf (f
, "vec4_add");
266 case slang_asm_vec4_subtract
:
267 fprintf (f
, "vec4_subtract");
269 case slang_asm_vec4_multiply
:
270 fprintf (f
, "vec4_multiply");
272 case slang_asm_vec4_divide
:
273 fprintf (f
, "vec4_divide");
275 case slang_asm_vec4_negate
:
276 fprintf (f
, "vec4_negate");
278 case slang_asm_vec4_dot
:
279 fprintf (f
, "vec4_dot");
281 case slang_asm_vec4_copy
:
282 fprintf (f
, "vec4_copy");
284 case slang_asm_vec4_deref
:
285 fprintf (f
, "vec4_deref");
287 case slang_asm_vec4_equal_int
:
288 fprintf (f
, "vec4_equal");
297 static void dump (const slang_assembly_file
*file
)
300 static unsigned int counter
= 0;
305 _mesa_sprintf (filename
, "~mesa-slang-assembly-dump-(%u).txt", counter
);
306 f
= fopen (filename
, "w");
310 for (i
= 0; i
< file
->count
; i
++)
311 dump_instruction (f
, file
->code
+ i
, i
);
319 ensure_infolog_created (slang_info_log
**infolog
)
321 if (*infolog
== NULL
) {
322 *infolog
= slang_alloc_malloc (sizeof (slang_info_log
));
323 if (*infolog
== NULL
)
325 slang_info_log_construct (*infolog
);
330 _slang_execute2 (const slang_assembly_file
*file
, slang_machine
*mach
)
332 slang_machine_slot
*stack
;
335 static unsigned int counter
= 0;
340 /* assume 32-bit floats and uints; should work fine also on 64-bit platforms */
341 static_assert(sizeof (GLfloat
) == 4);
342 static_assert(sizeof (GLuint
) == 4);
347 _mesa_sprintf (filename
, "~mesa-slang-assembly-exec-(%u).txt", counter
);
348 f
= fopen (filename
, "w");
351 #if defined(USE_X86_ASM) || defined(SLANG_X86)
352 if (mach
->x86
.compiled_func
!= NULL
)
354 mach
->x86
.compiled_func (mach
);
359 stack
= mach
->mem
+ SLANG_MACHINE_GLOBAL_SIZE
;
363 slang_assembly
*a
= &file
->code
[mach
->ip
];
366 if (f
!= NULL
&& a
->type
!= slang_asm_none
)
370 dump_instruction (f
, file
->code
+ mach
->ip
, mach
->ip
);
371 fprintf (f
, "\t\tsp=%u bp=%u\n", mach
->sp
, mach
->bp
);
372 for (i
= mach
->sp
; i
< SLANG_MACHINE_STACK_SIZE
; i
++)
373 fprintf (f
, "\t%.5u\t%6f\t%u\n", i
, stack
[i
]._float
, stack
[i
]._addr
);
385 case slang_asm_float_copy
:
386 case slang_asm_int_copy
:
387 case slang_asm_bool_copy
:
388 mach
->mem
[(stack
[mach
->sp
+ a
->param
[0] / 4]._addr
+ a
->param
[1]) / 4]._float
=
389 stack
[mach
->sp
]._float
;
392 case slang_asm_float_move
:
393 case slang_asm_int_move
:
394 case slang_asm_bool_move
:
395 stack
[mach
->sp
+ a
->param
[0] / 4]._float
=
396 stack
[mach
->sp
+ (stack
[mach
->sp
]._addr
+ a
->param
[1]) / 4]._float
;
398 case slang_asm_float_push
:
399 case slang_asm_int_push
:
400 case slang_asm_bool_push
:
402 stack
[mach
->sp
]._float
= a
->literal
;
404 case slang_asm_float_deref
:
405 case slang_asm_int_deref
:
406 case slang_asm_bool_deref
:
407 stack
[mach
->sp
]._float
= mach
->mem
[stack
[mach
->sp
]._addr
/ 4]._float
;
409 case slang_asm_float_add
:
410 stack
[mach
->sp
+ 1]._float
+= stack
[mach
->sp
]._float
;
413 case slang_asm_float_multiply
:
414 stack
[mach
->sp
+ 1]._float
*= stack
[mach
->sp
]._float
;
417 case slang_asm_float_divide
:
418 stack
[mach
->sp
+ 1]._float
/= stack
[mach
->sp
]._float
;
421 case slang_asm_float_negate
:
422 stack
[mach
->sp
]._float
= -stack
[mach
->sp
]._float
;
424 case slang_asm_float_less
:
425 stack
[mach
->sp
+ 1]._float
=
426 stack
[mach
->sp
+ 1]._float
< stack
[mach
->sp
]._float
? (GLfloat
) 1 : (GLfloat
) 0;
429 case slang_asm_float_equal_exp
:
430 stack
[mach
->sp
+ 1]._float
=
431 stack
[mach
->sp
+ 1]._float
== stack
[mach
->sp
]._float
? (GLfloat
) 1 : (GLfloat
) 0;
434 case slang_asm_float_equal_int
:
436 stack
[mach
->sp
]._float
= stack
[mach
->sp
+ 1 + a
->param
[0] / 4]._float
==
437 stack
[mach
->sp
+ 1 + a
->param
[1] / 4]._float
? (GLfloat
) 1 : (GLfloat
) 0;
439 case slang_asm_float_to_int
:
440 stack
[mach
->sp
]._float
= (GLfloat
) (GLint
) stack
[mach
->sp
]._float
;
442 case slang_asm_float_sine
:
443 stack
[mach
->sp
]._float
= (GLfloat
) _mesa_sin (stack
[mach
->sp
]._float
);
445 case slang_asm_float_arcsine
:
446 stack
[mach
->sp
]._float
= _mesa_asinf (stack
[mach
->sp
]._float
);
448 case slang_asm_float_arctan
:
449 stack
[mach
->sp
]._float
= _mesa_atanf (stack
[mach
->sp
]._float
);
451 case slang_asm_float_power
:
452 stack
[mach
->sp
+ 1]._float
=
453 (GLfloat
) _mesa_pow (stack
[mach
->sp
+ 1]._float
, stack
[mach
->sp
]._float
);
456 case slang_asm_float_log2
:
457 stack
[mach
->sp
]._float
= LOG2 (stack
[mach
->sp
]._float
);
459 case slang_asm_float_floor
:
460 stack
[mach
->sp
]._float
= FLOORF (stack
[mach
->sp
]._float
);
462 case slang_asm_float_ceil
:
463 stack
[mach
->sp
]._float
= CEILF (stack
[mach
->sp
]._float
);
465 case slang_asm_float_noise1
:
466 stack
[mach
->sp
]._float
= _slang_library_noise1 (stack
[mach
->sp
]._float
);
468 case slang_asm_float_noise2
:
469 stack
[mach
->sp
+ 1]._float
= _slang_library_noise2 (stack
[mach
->sp
]._float
,
470 stack
[mach
->sp
+ 1]._float
);
473 case slang_asm_float_noise3
:
474 stack
[mach
->sp
+ 2]._float
= _slang_library_noise3 (stack
[mach
->sp
]._float
,
475 stack
[mach
->sp
+ 1]._float
, stack
[mach
->sp
+ 2]._float
);
478 case slang_asm_float_noise4
:
479 stack
[mach
->sp
+ 3]._float
= _slang_library_noise4 (stack
[mach
->sp
]._float
,
480 stack
[mach
->sp
+ 1]._float
, stack
[mach
->sp
+ 2]._float
, stack
[mach
->sp
+ 3]._float
);
483 case slang_asm_int_to_float
:
485 case slang_asm_int_to_addr
:
486 stack
[mach
->sp
]._addr
= (GLuint
) (GLint
) stack
[mach
->sp
]._float
;
488 case slang_asm_addr_copy
:
489 mach
->mem
[stack
[mach
->sp
+ 1]._addr
/ 4]._addr
= stack
[mach
->sp
]._addr
;
492 case slang_asm_addr_push
:
493 case slang_asm_global_addr
:
495 stack
[mach
->sp
]._addr
= a
->param
[0];
497 case slang_asm_addr_deref
:
498 stack
[mach
->sp
]._addr
= mach
->mem
[stack
[mach
->sp
]._addr
/ 4]._addr
;
500 case slang_asm_addr_add
:
501 stack
[mach
->sp
+ 1]._addr
+= stack
[mach
->sp
]._addr
;
504 case slang_asm_addr_multiply
:
505 stack
[mach
->sp
+ 1]._addr
*= stack
[mach
->sp
]._addr
;
508 case slang_asm_vec4_tex1d
:
509 _slang_library_tex1d (stack
[mach
->sp
]._float
, stack
[mach
->sp
+ 1]._float
,
510 stack
[mach
->sp
+ 2]._float
, &mach
->mem
[stack
[mach
->sp
+ 3]._addr
/ 4]._float
);
513 case slang_asm_vec4_tex2d
:
514 _slang_library_tex2d (stack
[mach
->sp
]._float
, stack
[mach
->sp
+ 1]._float
,
515 stack
[mach
->sp
+ 2]._float
, stack
[mach
->sp
+ 3]._float
,
516 &mach
->mem
[stack
[mach
->sp
+ 4]._addr
/ 4]._float
);
519 case slang_asm_vec4_tex3d
:
520 _slang_library_tex3d (stack
[mach
->sp
]._float
, stack
[mach
->sp
+ 1]._float
,
521 stack
[mach
->sp
+ 2]._float
, stack
[mach
->sp
+ 3]._float
, stack
[mach
->sp
+ 4]._float
,
522 &mach
->mem
[stack
[mach
->sp
+ 5]._addr
/ 4]._float
);
525 case slang_asm_vec4_texcube
:
526 _slang_library_texcube (stack
[mach
->sp
]._float
, stack
[mach
->sp
+ 1]._float
,
527 stack
[mach
->sp
+ 2]._float
, stack
[mach
->sp
+ 3]._float
, stack
[mach
->sp
+ 4]._float
,
528 &mach
->mem
[stack
[mach
->sp
+ 5]._addr
/ 4]._float
);
531 case slang_asm_vec4_shad1d
:
532 _slang_library_shad1d (stack
[mach
->sp
]._float
, stack
[mach
->sp
+ 1]._float
,
533 stack
[mach
->sp
+ 2]._float
, stack
[mach
->sp
+ 3]._float
, stack
[mach
->sp
+ 4]._float
,
534 &mach
->mem
[stack
[mach
->sp
+ 5]._addr
/ 4]._float
);
537 case slang_asm_vec4_shad2d
:
538 _slang_library_shad2d (stack
[mach
->sp
]._float
, stack
[mach
->sp
+ 1]._float
,
539 stack
[mach
->sp
+ 2]._float
, stack
[mach
->sp
+ 3]._float
, stack
[mach
->sp
+ 4]._float
,
540 &mach
->mem
[stack
[mach
->sp
+ 5]._addr
/ 4]._float
);
544 mach
->ip
= a
->param
[0];
546 case slang_asm_jump_if_zero
:
547 if (stack
[mach
->sp
]._float
== 0.0f
)
548 mach
->ip
= a
->param
[0];
551 case slang_asm_enter
:
553 stack
[mach
->sp
]._addr
= mach
->bp
;
554 mach
->bp
= mach
->sp
+ a
->param
[0] / 4;
556 case slang_asm_leave
:
557 mach
->bp
= stack
[mach
->sp
]._addr
;
560 case slang_asm_local_alloc
:
561 mach
->sp
-= a
->param
[0] / 4;
563 case slang_asm_local_free
:
564 mach
->sp
+= a
->param
[0] / 4;
566 case slang_asm_local_addr
:
568 stack
[mach
->sp
]._addr
= SLANG_MACHINE_GLOBAL_SIZE
* 4 + mach
->bp
* 4 -
569 (a
->param
[0] + a
->param
[1]) + 4;
573 stack
[mach
->sp
]._addr
= mach
->ip
;
574 mach
->ip
= a
->param
[0];
576 case slang_asm_return
:
577 mach
->ip
= stack
[mach
->sp
]._addr
;
580 case slang_asm_discard
:
586 /* GL_MESA_shader_debug */
587 case slang_asm_float_print
:
588 _mesa_printf ("slang print: %f\n", stack
[mach
->sp
]._float
);
589 ensure_infolog_created (&mach
->infolog
);
590 slang_info_log_print (mach
->infolog
, "%f", stack
[mach
->sp
]._float
);
592 case slang_asm_int_print
:
593 _mesa_printf ("slang print: %d\n", (GLint
) stack
[mach
->sp
]._float
);
594 ensure_infolog_created (&mach
->infolog
);
595 slang_info_log_print (mach
->infolog
, "%d", (GLint
) (stack
[mach
->sp
]._float
));
597 case slang_asm_bool_print
:
598 _mesa_printf ("slang print: %s\n", (GLint
) stack
[mach
->sp
]._float
? "true" : "false");
599 ensure_infolog_created (&mach
->infolog
);
600 slang_info_log_print (mach
->infolog
, "%s",
601 (GLint
) (stack
[mach
->sp
]._float
) ? "true" : "false");
604 case slang_asm_float_to_vec4
:
605 /* [vec4] | float > [vec4] */
607 GLuint da
= stack
[mach
->sp
+ 1]._addr
;
608 mach
->mem
[da
/ 4]._float
= stack
[mach
->sp
]._float
;
612 case slang_asm_vec4_add
:
613 /* [vec4] | vec4 > [vec4] */
615 GLuint da
= stack
[mach
->sp
+ 4]._addr
;
616 mach
->mem
[da
/ 4]._float
+= stack
[mach
->sp
]._float
;
617 mach
->mem
[(da
+ 4) / 4]._float
+= stack
[mach
->sp
+ 1]._float
;
618 mach
->mem
[(da
+ 8) / 4]._float
+= stack
[mach
->sp
+ 2]._float
;
619 mach
->mem
[(da
+ 12) / 4]._float
+= stack
[mach
->sp
+ 3]._float
;
623 case slang_asm_vec4_subtract
:
624 /* [vec4] | vec4 > [vec4] */
626 GLuint da
= stack
[mach
->sp
+ 4]._addr
;
627 mach
->mem
[da
/ 4]._float
-= stack
[mach
->sp
]._float
;
628 mach
->mem
[(da
+ 4) / 4]._float
-= stack
[mach
->sp
+ 1]._float
;
629 mach
->mem
[(da
+ 8) / 4]._float
-= stack
[mach
->sp
+ 2]._float
;
630 mach
->mem
[(da
+ 12) / 4]._float
-= stack
[mach
->sp
+ 3]._float
;
634 case slang_asm_vec4_multiply
:
635 /* [vec4] | vec4 > [vec4] */
637 GLuint da
= stack
[mach
->sp
+ 4]._addr
;
638 mach
->mem
[da
/ 4]._float
*= stack
[mach
->sp
]._float
;
639 mach
->mem
[(da
+ 4) / 4]._float
*= stack
[mach
->sp
+ 1]._float
;
640 mach
->mem
[(da
+ 8) / 4]._float
*= stack
[mach
->sp
+ 2]._float
;
641 mach
->mem
[(da
+ 12) / 4]._float
*= stack
[mach
->sp
+ 3]._float
;
645 case slang_asm_vec4_divide
:
646 /* [vec4] | vec4 > [vec4] */
648 GLuint da
= stack
[mach
->sp
+ 4]._addr
;
649 mach
->mem
[da
/ 4]._float
/= stack
[mach
->sp
]._float
;
650 mach
->mem
[(da
+ 4) / 4]._float
/= stack
[mach
->sp
+ 1]._float
;
651 mach
->mem
[(da
+ 8) / 4]._float
/= stack
[mach
->sp
+ 2]._float
;
652 mach
->mem
[(da
+ 12) / 4]._float
/= stack
[mach
->sp
+ 3]._float
;
656 case slang_asm_vec4_negate
:
657 /* [vec4] > [vec4] */
659 GLuint da
= stack
[mach
->sp
]._addr
;
660 mach
->mem
[da
/ 4]._float
= -mach
->mem
[da
/ 4]._float
;
661 mach
->mem
[(da
+ 4) / 4]._float
= -mach
->mem
[(da
+ 4) / 4]._float
;
662 mach
->mem
[(da
+ 8) / 4]._float
= -mach
->mem
[(da
+ 8) / 4]._float
;
663 mach
->mem
[(da
+ 12) / 4]._float
= -mach
->mem
[(da
+ 12) / 4]._float
;
666 case slang_asm_vec4_dot
:
667 /* [vec4] | vec4 > [float] */
669 GLuint da
= stack
[mach
->sp
+ 4]._addr
;
670 mach
->mem
[da
/ 4]._float
=
671 mach
->mem
[da
/ 4]._float
* stack
[mach
->sp
]._float
+
672 mach
->mem
[(da
+ 4) / 4]._float
* stack
[mach
->sp
+ 1]._float
+
673 mach
->mem
[(da
+ 8) / 4]._float
* stack
[mach
->sp
+ 2]._float
+
674 mach
->mem
[(da
+ 12) / 4]._float
* stack
[mach
->sp
+ 3]._float
;
678 case slang_asm_vec4_copy
:
679 /* [vec4] | vec4 > [vec4] */
681 GLuint da
= stack
[mach
->sp
+ a
->param
[0] / 4]._addr
+ a
->param
[1];
682 mach
->mem
[da
/ 4]._float
= stack
[mach
->sp
]._float
;
683 mach
->mem
[(da
+ 4) / 4]._float
= stack
[mach
->sp
+ 1]._float
;
684 mach
->mem
[(da
+ 8) / 4]._float
= stack
[mach
->sp
+ 2]._float
;
685 mach
->mem
[(da
+ 12) / 4]._float
= stack
[mach
->sp
+ 3]._float
;
689 case slang_asm_vec4_deref
:
692 GLuint sa
= stack
[mach
->sp
]._addr
;
694 stack
[mach
->sp
]._float
= mach
->mem
[sa
/ 4]._float
;
695 stack
[mach
->sp
+ 1]._float
= mach
->mem
[(sa
+ 4) / 4]._float
;
696 stack
[mach
->sp
+ 2]._float
= mach
->mem
[(sa
+ 8) / 4]._float
;
697 stack
[mach
->sp
+ 3]._float
= mach
->mem
[(sa
+ 12) / 4]._float
;
700 case slang_asm_vec4_equal_int
:
702 GLuint sp0
= mach
->sp
+ a
->param
[0] / 4;
703 GLuint sp1
= mach
->sp
+ a
->param
[1] / 4;
705 if (stack
[sp0
]._float
== stack
[sp1
]._float
&&
706 stack
[sp0
+ 1]._float
== stack
[sp1
+ 1]._float
&&
707 stack
[sp0
+ 2]._float
== stack
[sp1
+ 2]._float
&&
708 stack
[sp0
+ 3]._float
== stack
[sp1
+ 3]._float
) {
709 stack
[mach
->sp
]._float
= 1.0f
;
712 stack
[mach
->sp
]._float
= 0.0f
;
717 _mesa_problem(NULL
, "bad slang opcode 0x%x", a
->type
);