glsl: fix the type of ir_constant_data::u16
[mesa.git] / src / compiler / glsl / builtin_functions.cpp
1 /*
2 * Copyright © 2013 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24 /**
25 * \file builtin_functions.cpp
26 *
27 * Support for GLSL built-in functions.
28 *
29 * This file is split into several main components:
30 *
31 * 1. Availability predicates
32 *
33 * A series of small functions that check whether the current shader
34 * supports the version/extensions required to expose a built-in.
35 *
36 * 2. Core builtin_builder class functionality
37 *
38 * 3. Lists of built-in functions
39 *
40 * The builtin_builder::create_builtins() function contains lists of all
41 * built-in function signatures, where they're available, what types they
42 * take, and so on.
43 *
44 * 4. Implementations of built-in function signatures
45 *
46 * A series of functions which create ir_function_signatures and emit IR
47 * via ir_builder to implement them.
48 *
49 * 5. External API
50 *
51 * A few functions the rest of the compiler can use to interact with the
52 * built-in function module. For example, searching for a built-in by
53 * name and parameters.
54 */
55
56
57 /**
58 * Unfortunately, some versions of MinGW produce bad code if this file
59 * is compiled with -O2 or -O3. The resulting driver will crash in random
60 * places if the app uses GLSL.
61 * The work-around is to disable optimizations for just this file. Luckily,
62 * this code is basically just executed once.
63 *
64 * MinGW 4.6.3 (in Ubuntu 13.10) does not have this bug.
65 * MinGW 5.3.1 (in Ubuntu 16.04) definitely has this bug.
66 * MinGW 6.2.0 (in Ubuntu 16.10) definitely has this bug.
67 * MinGW x.y.z - don't know. Assume versions after 4.6.x are buggy
68 */
69
70 #if defined(__MINGW32__) && ((__GNUC__ * 100) + __GNUC_MINOR >= 407)
71 #warning "disabling optimizations for this file to work around compiler bug"
72 #pragma GCC optimize("O1")
73 #endif
74
75
76 #include <stdarg.h>
77 #include <stdio.h>
78 #include "main/mtypes.h"
79 #include "main/shaderobj.h"
80 #include "ir_builder.h"
81 #include "glsl_parser_extras.h"
82 #include "program/prog_instruction.h"
83 #include <math.h>
84 #include "builtin_functions.h"
85 #include "util/hash_table.h"
86
87 #define M_PIf ((float) M_PI)
88 #define M_PI_2f ((float) M_PI_2)
89 #define M_PI_4f ((float) M_PI_4)
90
91 using namespace ir_builder;
92
93 /**
94 * Availability predicates:
95 * @{
96 */
97 static bool
98 always_available(const _mesa_glsl_parse_state *)
99 {
100 return true;
101 }
102
103 static bool
104 compatibility_vs_only(const _mesa_glsl_parse_state *state)
105 {
106 return state->stage == MESA_SHADER_VERTEX &&
107 (state->compat_shader || state->ARB_compatibility_enable) &&
108 !state->es_shader;
109 }
110
111 static bool
112 derivatives_only(const _mesa_glsl_parse_state *state)
113 {
114 return state->stage == MESA_SHADER_FRAGMENT ||
115 (state->stage == MESA_SHADER_COMPUTE &&
116 state->NV_compute_shader_derivatives_enable);
117 }
118
119 static bool
120 gs_only(const _mesa_glsl_parse_state *state)
121 {
122 return state->stage == MESA_SHADER_GEOMETRY;
123 }
124
125 static bool
126 v110(const _mesa_glsl_parse_state *state)
127 {
128 return !state->es_shader;
129 }
130
131 static bool
132 v110_derivatives_only(const _mesa_glsl_parse_state *state)
133 {
134 return !state->es_shader &&
135 derivatives_only(state);
136 }
137
138 static bool
139 v120(const _mesa_glsl_parse_state *state)
140 {
141 return state->is_version(120, 300);
142 }
143
144 static bool
145 v130(const _mesa_glsl_parse_state *state)
146 {
147 return state->is_version(130, 300);
148 }
149
150 static bool
151 v130_desktop(const _mesa_glsl_parse_state *state)
152 {
153 return state->is_version(130, 0);
154 }
155
156 static bool
157 v460_desktop(const _mesa_glsl_parse_state *state)
158 {
159 return state->is_version(460, 0);
160 }
161
162 static bool
163 v130_derivatives_only(const _mesa_glsl_parse_state *state)
164 {
165 return state->is_version(130, 300) &&
166 derivatives_only(state);
167 }
168
169 static bool
170 v140_or_es3(const _mesa_glsl_parse_state *state)
171 {
172 return state->is_version(140, 300);
173 }
174
175 static bool
176 v400_derivatives_only(const _mesa_glsl_parse_state *state)
177 {
178 return state->is_version(400, 0) &&
179 derivatives_only(state);
180 }
181
182 static bool
183 texture_rectangle(const _mesa_glsl_parse_state *state)
184 {
185 return state->ARB_texture_rectangle_enable;
186 }
187
188 static bool
189 texture_external(const _mesa_glsl_parse_state *state)
190 {
191 return state->OES_EGL_image_external_enable;
192 }
193
194 static bool
195 texture_external_es3(const _mesa_glsl_parse_state *state)
196 {
197 return state->OES_EGL_image_external_essl3_enable &&
198 state->es_shader &&
199 state->is_version(0, 300);
200 }
201
202 /** True if texturing functions with explicit LOD are allowed. */
203 static bool
204 lod_exists_in_stage(const _mesa_glsl_parse_state *state)
205 {
206 /* Texturing functions with "Lod" in their name exist:
207 * - In the vertex shader stage (for all languages)
208 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
209 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
210 *
211 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
212 * don't need to explicitly check state->es_shader.
213 */
214 return state->stage == MESA_SHADER_VERTEX ||
215 state->is_version(130, 300) ||
216 state->ARB_shader_texture_lod_enable ||
217 state->EXT_gpu_shader4_enable;
218 }
219
220 static bool
221 v110_lod(const _mesa_glsl_parse_state *state)
222 {
223 return !state->es_shader && lod_exists_in_stage(state);
224 }
225
226 static bool
227 texture_buffer(const _mesa_glsl_parse_state *state)
228 {
229 return state->is_version(140, 320) ||
230 state->EXT_texture_buffer_enable ||
231 state->OES_texture_buffer_enable;
232 }
233
234 static bool
235 shader_texture_lod(const _mesa_glsl_parse_state *state)
236 {
237 return state->ARB_shader_texture_lod_enable;
238 }
239
240 static bool
241 shader_texture_lod_and_rect(const _mesa_glsl_parse_state *state)
242 {
243 return state->ARB_shader_texture_lod_enable &&
244 state->ARB_texture_rectangle_enable;
245 }
246
247 static bool
248 shader_bit_encoding(const _mesa_glsl_parse_state *state)
249 {
250 return state->is_version(330, 300) ||
251 state->ARB_shader_bit_encoding_enable ||
252 state->ARB_gpu_shader5_enable;
253 }
254
255 static bool
256 shader_integer_mix(const _mesa_glsl_parse_state *state)
257 {
258 return state->is_version(450, 310) ||
259 state->ARB_ES3_1_compatibility_enable ||
260 (v130(state) && state->EXT_shader_integer_mix_enable);
261 }
262
263 static bool
264 shader_packing_or_es3(const _mesa_glsl_parse_state *state)
265 {
266 return state->ARB_shading_language_packing_enable ||
267 state->is_version(420, 300);
268 }
269
270 static bool
271 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state *state)
272 {
273 return state->ARB_shading_language_packing_enable ||
274 state->ARB_gpu_shader5_enable ||
275 state->is_version(400, 300);
276 }
277
278 static bool
279 gpu_shader4(const _mesa_glsl_parse_state *state)
280 {
281 return state->EXT_gpu_shader4_enable;
282 }
283
284 static bool
285 gpu_shader4_integer(const _mesa_glsl_parse_state *state)
286 {
287 return state->EXT_gpu_shader4_enable &&
288 state->ctx->Extensions.EXT_texture_integer;
289 }
290
291 static bool
292 gpu_shader4_array(const _mesa_glsl_parse_state *state)
293 {
294 return state->EXT_gpu_shader4_enable &&
295 state->ctx->Extensions.EXT_texture_array;
296 }
297
298 static bool
299 gpu_shader4_array_integer(const _mesa_glsl_parse_state *state)
300 {
301 return gpu_shader4_array(state) &&
302 state->ctx->Extensions.EXT_texture_integer;
303 }
304
305 static bool
306 gpu_shader4_rect(const _mesa_glsl_parse_state *state)
307 {
308 return state->EXT_gpu_shader4_enable &&
309 state->ctx->Extensions.NV_texture_rectangle;
310 }
311
312 static bool
313 gpu_shader4_rect_integer(const _mesa_glsl_parse_state *state)
314 {
315 return gpu_shader4_rect(state) &&
316 state->ctx->Extensions.EXT_texture_integer;
317 }
318
319 static bool
320 gpu_shader4_tbo(const _mesa_glsl_parse_state *state)
321 {
322 return state->EXT_gpu_shader4_enable &&
323 state->ctx->Extensions.EXT_texture_buffer_object;
324 }
325
326 static bool
327 gpu_shader4_tbo_integer(const _mesa_glsl_parse_state *state)
328 {
329 return gpu_shader4_tbo(state) &&
330 state->ctx->Extensions.EXT_texture_integer;
331 }
332
333 static bool
334 gpu_shader4_derivs_only(const _mesa_glsl_parse_state *state)
335 {
336 return state->EXT_gpu_shader4_enable &&
337 derivatives_only(state);
338 }
339
340 static bool
341 gpu_shader4_integer_derivs_only(const _mesa_glsl_parse_state *state)
342 {
343 return gpu_shader4_derivs_only(state) &&
344 state->ctx->Extensions.EXT_texture_integer;
345 }
346
347 static bool
348 gpu_shader4_array_derivs_only(const _mesa_glsl_parse_state *state)
349 {
350 return gpu_shader4_derivs_only(state) &&
351 state->ctx->Extensions.EXT_texture_array;
352 }
353
354 static bool
355 gpu_shader4_array_integer_derivs_only(const _mesa_glsl_parse_state *state)
356 {
357 return gpu_shader4_array_derivs_only(state) &&
358 state->ctx->Extensions.EXT_texture_integer;
359 }
360
361 static bool
362 v130_or_gpu_shader4(const _mesa_glsl_parse_state *state)
363 {
364 return state->is_version(130, 300) || state->EXT_gpu_shader4_enable;
365 }
366
367 static bool
368 v130_or_gpu_shader4_and_tex_shadow_lod(const _mesa_glsl_parse_state *state)
369 {
370 return v130_or_gpu_shader4(state) &&
371 state->EXT_texture_shadow_lod_enable;
372 }
373
374 static bool
375 gpu_shader5(const _mesa_glsl_parse_state *state)
376 {
377 return state->is_version(400, 0) || state->ARB_gpu_shader5_enable;
378 }
379
380 static bool
381 gpu_shader5_es(const _mesa_glsl_parse_state *state)
382 {
383 return state->is_version(400, 320) ||
384 state->ARB_gpu_shader5_enable ||
385 state->EXT_gpu_shader5_enable ||
386 state->OES_gpu_shader5_enable;
387 }
388
389 static bool
390 gpu_shader5_or_OES_texture_cube_map_array(const _mesa_glsl_parse_state *state)
391 {
392 return state->is_version(400, 320) ||
393 state->ARB_gpu_shader5_enable ||
394 state->EXT_texture_cube_map_array_enable ||
395 state->OES_texture_cube_map_array_enable;
396 }
397
398 static bool
399 es31_not_gs5(const _mesa_glsl_parse_state *state)
400 {
401 return state->is_version(0, 310) && !gpu_shader5_es(state);
402 }
403
404 static bool
405 gpu_shader5_or_es31(const _mesa_glsl_parse_state *state)
406 {
407 return state->is_version(400, 310) || state->ARB_gpu_shader5_enable;
408 }
409
410 static bool
411 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state *state)
412 {
413 return state->ARB_shading_language_packing_enable ||
414 state->ARB_gpu_shader5_enable ||
415 state->is_version(400, 310);
416 }
417
418 static bool
419 gpu_shader5_or_es31_or_integer_functions(const _mesa_glsl_parse_state *state)
420 {
421 return gpu_shader5_or_es31(state) ||
422 state->MESA_shader_integer_functions_enable;
423 }
424
425 static bool
426 fs_interpolate_at(const _mesa_glsl_parse_state *state)
427 {
428 return state->stage == MESA_SHADER_FRAGMENT &&
429 (state->is_version(400, 320) ||
430 state->ARB_gpu_shader5_enable ||
431 state->OES_shader_multisample_interpolation_enable);
432 }
433
434
435 static bool
436 texture_array_lod(const _mesa_glsl_parse_state *state)
437 {
438 return lod_exists_in_stage(state) &&
439 (state->EXT_texture_array_enable ||
440 (state->EXT_gpu_shader4_enable &&
441 state->ctx->Extensions.EXT_texture_array));
442 }
443
444 static bool
445 texture_array(const _mesa_glsl_parse_state *state)
446 {
447 return state->EXT_texture_array_enable ||
448 (state->EXT_gpu_shader4_enable &&
449 state->ctx->Extensions.EXT_texture_array);
450 }
451
452 static bool
453 texture_array_derivs_only(const _mesa_glsl_parse_state *state)
454 {
455 return derivatives_only(state) &&
456 texture_array(state);
457 }
458
459 static bool
460 texture_multisample(const _mesa_glsl_parse_state *state)
461 {
462 return state->is_version(150, 310) ||
463 state->ARB_texture_multisample_enable;
464 }
465
466 static bool
467 texture_multisample_array(const _mesa_glsl_parse_state *state)
468 {
469 return state->is_version(150, 320) ||
470 state->ARB_texture_multisample_enable ||
471 state->OES_texture_storage_multisample_2d_array_enable;
472 }
473
474 static bool
475 texture_samples_identical(const _mesa_glsl_parse_state *state)
476 {
477 return texture_multisample(state) &&
478 state->EXT_shader_samples_identical_enable;
479 }
480
481 static bool
482 texture_samples_identical_array(const _mesa_glsl_parse_state *state)
483 {
484 return texture_multisample_array(state) &&
485 state->EXT_shader_samples_identical_enable;
486 }
487
488 static bool
489 derivatives_texture_cube_map_array(const _mesa_glsl_parse_state *state)
490 {
491 return state->has_texture_cube_map_array() &&
492 derivatives_only(state);
493 }
494
495 static bool
496 texture_cube_map_array(const _mesa_glsl_parse_state *state)
497 {
498 return state->has_texture_cube_map_array();
499 }
500
501 static bool
502 v130_or_gpu_shader4_and_tex_cube_map_array(const _mesa_glsl_parse_state *state)
503 {
504 return texture_cube_map_array(state) &&
505 v130_or_gpu_shader4(state) &&
506 state->EXT_texture_shadow_lod_enable;
507 }
508
509 static bool
510 texture_query_levels(const _mesa_glsl_parse_state *state)
511 {
512 return state->is_version(430, 0) ||
513 state->ARB_texture_query_levels_enable;
514 }
515
516 static bool
517 texture_query_lod(const _mesa_glsl_parse_state *state)
518 {
519 return derivatives_only(state) &&
520 (state->ARB_texture_query_lod_enable ||
521 state->EXT_texture_query_lod_enable);
522 }
523
524 static bool
525 texture_gather_cube_map_array(const _mesa_glsl_parse_state *state)
526 {
527 return state->is_version(400, 320) ||
528 state->ARB_texture_gather_enable ||
529 state->ARB_gpu_shader5_enable ||
530 state->EXT_texture_cube_map_array_enable ||
531 state->OES_texture_cube_map_array_enable;
532 }
533
534 static bool
535 texture_texture4(const _mesa_glsl_parse_state *state)
536 {
537 return state->AMD_texture_texture4_enable;
538 }
539
540 static bool
541 texture_gather_or_es31(const _mesa_glsl_parse_state *state)
542 {
543 return state->is_version(400, 310) ||
544 state->ARB_texture_gather_enable ||
545 state->ARB_gpu_shader5_enable;
546 }
547
548 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
549 * used for relaxation of const offset requirements.
550 */
551 static bool
552 texture_gather_only_or_es31(const _mesa_glsl_parse_state *state)
553 {
554 return !state->is_version(400, 320) &&
555 !state->ARB_gpu_shader5_enable &&
556 !state->EXT_gpu_shader5_enable &&
557 !state->OES_gpu_shader5_enable &&
558 (state->ARB_texture_gather_enable ||
559 state->is_version(0, 310));
560 }
561
562 /* Desktop GL or OES_standard_derivatives */
563 static bool
564 derivatives(const _mesa_glsl_parse_state *state)
565 {
566 return derivatives_only(state) &&
567 (state->is_version(110, 300) ||
568 state->OES_standard_derivatives_enable ||
569 state->ctx->Const.AllowGLSLRelaxedES);
570 }
571
572 static bool
573 derivative_control(const _mesa_glsl_parse_state *state)
574 {
575 return derivatives_only(state) &&
576 (state->is_version(450, 0) ||
577 state->ARB_derivative_control_enable);
578 }
579
580 static bool
581 tex1d_lod(const _mesa_glsl_parse_state *state)
582 {
583 return !state->es_shader && lod_exists_in_stage(state);
584 }
585
586 /** True if sampler3D exists */
587 static bool
588 tex3d(const _mesa_glsl_parse_state *state)
589 {
590 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
591 * OES_texture_3D extension, and in GLSL ES 3.00.
592 */
593 return !state->es_shader ||
594 state->OES_texture_3D_enable ||
595 state->language_version >= 300;
596 }
597
598 static bool
599 derivatives_tex3d(const _mesa_glsl_parse_state *state)
600 {
601 return (!state->es_shader || state->OES_texture_3D_enable) &&
602 derivatives_only(state);
603 }
604
605 static bool
606 tex3d_lod(const _mesa_glsl_parse_state *state)
607 {
608 return tex3d(state) && lod_exists_in_stage(state);
609 }
610
611 static bool
612 shader_atomic_counters(const _mesa_glsl_parse_state *state)
613 {
614 return state->has_atomic_counters();
615 }
616
617 static bool
618 shader_atomic_counter_ops(const _mesa_glsl_parse_state *state)
619 {
620 return state->ARB_shader_atomic_counter_ops_enable;
621 }
622
623 static bool
624 shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state *state)
625 {
626 return state->ARB_shader_atomic_counter_ops_enable || v460_desktop(state);
627 }
628
629 static bool
630 shader_ballot(const _mesa_glsl_parse_state *state)
631 {
632 return state->ARB_shader_ballot_enable;
633 }
634
635 static bool
636 supports_arb_fragment_shader_interlock(const _mesa_glsl_parse_state *state)
637 {
638 return state->ARB_fragment_shader_interlock_enable;
639 }
640
641 static bool
642 supports_nv_fragment_shader_interlock(const _mesa_glsl_parse_state *state)
643 {
644 return state->NV_fragment_shader_interlock_enable;
645 }
646
647 static bool
648 shader_clock(const _mesa_glsl_parse_state *state)
649 {
650 return state->ARB_shader_clock_enable;
651 }
652
653 static bool
654 shader_clock_int64(const _mesa_glsl_parse_state *state)
655 {
656 return state->ARB_shader_clock_enable &&
657 (state->ARB_gpu_shader_int64_enable ||
658 state->AMD_gpu_shader_int64_enable);
659 }
660
661 static bool
662 shader_storage_buffer_object(const _mesa_glsl_parse_state *state)
663 {
664 return state->has_shader_storage_buffer_objects();
665 }
666
667 static bool
668 shader_trinary_minmax(const _mesa_glsl_parse_state *state)
669 {
670 return state->AMD_shader_trinary_minmax_enable;
671 }
672
673 static bool
674 shader_image_load_store(const _mesa_glsl_parse_state *state)
675 {
676 return (state->is_version(420, 310) ||
677 state->ARB_shader_image_load_store_enable ||
678 state->EXT_shader_image_load_store_enable);
679 }
680
681 static bool
682 shader_image_load_store_ext(const _mesa_glsl_parse_state *state)
683 {
684 return state->EXT_shader_image_load_store_enable;
685 }
686
687 static bool
688 shader_image_atomic(const _mesa_glsl_parse_state *state)
689 {
690 return (state->is_version(420, 320) ||
691 state->ARB_shader_image_load_store_enable ||
692 state->EXT_shader_image_load_store_enable ||
693 state->OES_shader_image_atomic_enable);
694 }
695
696 static bool
697 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state *state)
698 {
699 return (state->is_version(450, 320) ||
700 state->ARB_ES3_1_compatibility_enable ||
701 state->OES_shader_image_atomic_enable ||
702 state->NV_shader_atomic_float_enable);
703 }
704
705 static bool
706 shader_image_atomic_add_float(const _mesa_glsl_parse_state *state)
707 {
708 return state->NV_shader_atomic_float_enable;
709 }
710
711 static bool
712 shader_image_size(const _mesa_glsl_parse_state *state)
713 {
714 return state->is_version(430, 310) ||
715 state->ARB_shader_image_size_enable;
716 }
717
718 static bool
719 shader_samples(const _mesa_glsl_parse_state *state)
720 {
721 return state->is_version(450, 0) ||
722 state->ARB_shader_texture_image_samples_enable;
723 }
724
725 static bool
726 gs_streams(const _mesa_glsl_parse_state *state)
727 {
728 return gpu_shader5(state) && gs_only(state);
729 }
730
731 static bool
732 fp64(const _mesa_glsl_parse_state *state)
733 {
734 return state->has_double();
735 }
736
737 static bool
738 int64(const _mesa_glsl_parse_state *state)
739 {
740 return state->has_int64();
741 }
742
743 static bool
744 int64_fp64(const _mesa_glsl_parse_state *state)
745 {
746 return state->has_int64() && state->has_double();
747 }
748
749 static bool
750 compute_shader(const _mesa_glsl_parse_state *state)
751 {
752 return state->stage == MESA_SHADER_COMPUTE;
753 }
754
755 static bool
756 compute_shader_supported(const _mesa_glsl_parse_state *state)
757 {
758 return state->has_compute_shader();
759 }
760
761 static bool
762 buffer_atomics_supported(const _mesa_glsl_parse_state *state)
763 {
764 return compute_shader(state) || shader_storage_buffer_object(state);
765 }
766
767 static bool
768 barrier_supported(const _mesa_glsl_parse_state *state)
769 {
770 return compute_shader(state) ||
771 state->stage == MESA_SHADER_TESS_CTRL;
772 }
773
774 static bool
775 vote(const _mesa_glsl_parse_state *state)
776 {
777 return state->ARB_shader_group_vote_enable;
778 }
779
780 static bool
781 vote_ext(const _mesa_glsl_parse_state *state)
782 {
783 return state->EXT_shader_group_vote_enable;
784 }
785
786 static bool
787 vote_or_v460_desktop(const _mesa_glsl_parse_state *state)
788 {
789 return state->EXT_shader_group_vote_enable || state->ARB_shader_group_vote_enable || v460_desktop(state);
790 }
791
792 static bool
793 integer_functions_supported(const _mesa_glsl_parse_state *state)
794 {
795 return state->extensions->MESA_shader_integer_functions;
796 }
797
798 static bool
799 NV_shader_atomic_float_supported(const _mesa_glsl_parse_state *state)
800 {
801 return state->extensions->NV_shader_atomic_float;
802 }
803
804 static bool
805 shader_atomic_float_add(const _mesa_glsl_parse_state *state)
806 {
807 return state->NV_shader_atomic_float_enable;
808 }
809
810 static bool
811 shader_atomic_float_exchange(const _mesa_glsl_parse_state *state)
812 {
813 return state->NV_shader_atomic_float_enable ||
814 state->INTEL_shader_atomic_float_minmax_enable;
815 }
816
817 static bool
818 INTEL_shader_atomic_float_minmax_supported(const _mesa_glsl_parse_state *state)
819 {
820 return state->extensions->INTEL_shader_atomic_float_minmax;
821 }
822
823 static bool
824 shader_atomic_float_minmax(const _mesa_glsl_parse_state *state)
825 {
826 return state->INTEL_shader_atomic_float_minmax_enable;
827 }
828
829 static bool
830 demote_to_helper_invocation(const _mesa_glsl_parse_state *state)
831 {
832 return state->EXT_demote_to_helper_invocation_enable;
833 }
834
835 static bool
836 shader_integer_functions2(const _mesa_glsl_parse_state *state)
837 {
838 return state->INTEL_shader_integer_functions2_enable;
839 }
840
841 static bool
842 shader_integer_functions2_int64(const _mesa_glsl_parse_state *state)
843 {
844 return state->INTEL_shader_integer_functions2_enable && state->has_int64();
845 }
846
847 static bool
848 is_nir(const _mesa_glsl_parse_state *state)
849 {
850 return state->ctx->Const.ShaderCompilerOptions[state->stage].NirOptions;
851 }
852
853 static bool
854 is_not_nir(const _mesa_glsl_parse_state *state)
855 {
856 return !is_nir(state);
857 }
858
859 /** @} */
860
861 /******************************************************************************/
862
863 namespace {
864
865 /**
866 * builtin_builder: A singleton object representing the core of the built-in
867 * function module.
868 *
869 * It generates IR for every built-in function signature, and organizes them
870 * into functions.
871 */
872 class builtin_builder {
873 public:
874 builtin_builder();
875 ~builtin_builder();
876
877 void initialize();
878 void release();
879 ir_function_signature *find(_mesa_glsl_parse_state *state,
880 const char *name, exec_list *actual_parameters);
881
882 /**
883 * A shader to hold all the built-in signatures; created by this module.
884 *
885 * This includes signatures for every built-in, regardless of version or
886 * enabled extensions. The availability predicate associated with each
887 * signature allows matching_signature() to filter out the irrelevant ones.
888 */
889 gl_shader *shader;
890
891 private:
892 void *mem_ctx;
893
894 void create_shader();
895 void create_intrinsics();
896 void create_builtins();
897
898 /**
899 * IR builder helpers:
900 *
901 * These convenience functions assist in emitting IR, but don't necessarily
902 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
903 * member available.
904 */
905 ir_variable *in_var(const glsl_type *type, const char *name);
906 ir_variable *out_var(const glsl_type *type, const char *name);
907 ir_constant *imm(float f, unsigned vector_elements=1);
908 ir_constant *imm(bool b, unsigned vector_elements=1);
909 ir_constant *imm(int i, unsigned vector_elements=1);
910 ir_constant *imm(unsigned u, unsigned vector_elements=1);
911 ir_constant *imm(double d, unsigned vector_elements=1);
912 ir_constant *imm(const glsl_type *type, const ir_constant_data &);
913 ir_dereference_variable *var_ref(ir_variable *var);
914 ir_dereference_array *array_ref(ir_variable *var, int i);
915 ir_swizzle *matrix_elt(ir_variable *var, int col, int row);
916
917 ir_expression *asin_expr(ir_variable *x, float p0, float p1);
918 void do_atan(ir_factory &body, const glsl_type *type, ir_variable *res, operand y_over_x);
919
920 /**
921 * Call function \param f with parameters specified as the linked
922 * list \param params of \c ir_variable objects. \param ret should
923 * point to the ir_variable that will hold the function return
924 * value, or be \c NULL if the function has void return type.
925 */
926 ir_call *call(ir_function *f, ir_variable *ret, exec_list params);
927
928 /** Create a new function and add the given signatures. */
929 void add_function(const char *name, ...);
930
931 typedef ir_function_signature *(builtin_builder::*image_prototype_ctr)(const glsl_type *image_type,
932 unsigned num_arguments,
933 unsigned flags);
934
935 /**
936 * Create a new image built-in function for all known image types.
937 * \p flags is a bitfield of \c image_function_flags flags.
938 */
939 void add_image_function(const char *name,
940 const char *intrinsic_name,
941 image_prototype_ctr prototype,
942 unsigned num_arguments,
943 unsigned flags,
944 enum ir_intrinsic_id id);
945
946 /**
947 * Create new functions for all known image built-ins and types.
948 * If \p glsl is \c true, use the GLSL built-in names and emit code
949 * to call into the actual compiler intrinsic. If \p glsl is
950 * false, emit a function prototype with no body for each image
951 * intrinsic name.
952 */
953 void add_image_functions(bool glsl);
954
955 ir_function_signature *new_sig(const glsl_type *return_type,
956 builtin_available_predicate avail,
957 int num_params, ...);
958
959 /**
960 * Function signature generators:
961 * @{
962 */
963 ir_function_signature *unop(builtin_available_predicate avail,
964 ir_expression_operation opcode,
965 const glsl_type *return_type,
966 const glsl_type *param_type);
967 ir_function_signature *binop(builtin_available_predicate avail,
968 ir_expression_operation opcode,
969 const glsl_type *return_type,
970 const glsl_type *param0_type,
971 const glsl_type *param1_type,
972 bool swap_operands = false);
973
974 #define B0(X) ir_function_signature *_##X();
975 #define B1(X) ir_function_signature *_##X(const glsl_type *);
976 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
977 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
978 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
979 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
980 B1(radians)
981 B1(degrees)
982 B1(sin)
983 B1(cos)
984 B1(tan)
985 B1(asin)
986 B1(acos)
987 B1(atan2)
988 B1(atan)
989 B1(atan2_op)
990 B1(atan_op)
991 B1(sinh)
992 B1(cosh)
993 B1(tanh)
994 B1(asinh)
995 B1(acosh)
996 B1(atanh)
997 B1(pow)
998 B1(exp)
999 B1(log)
1000 B1(exp2)
1001 B1(log2)
1002 BA1(sqrt)
1003 BA1(inversesqrt)
1004 BA1(abs)
1005 BA1(sign)
1006 BA1(floor)
1007 BA1(truncate)
1008 BA1(trunc)
1009 BA1(round)
1010 BA1(roundEven)
1011 BA1(ceil)
1012 BA1(fract)
1013 BA2(mod)
1014 BA1(modf)
1015 BA2(min)
1016 BA2(max)
1017 BA2(clamp)
1018 BA2(mix_lrp)
1019 ir_function_signature *_mix_sel(builtin_available_predicate avail,
1020 const glsl_type *val_type,
1021 const glsl_type *blend_type);
1022 BA2(step)
1023 BA2(smoothstep)
1024 BA1(isnan)
1025 BA1(isinf)
1026 B1(floatBitsToInt)
1027 B1(floatBitsToUint)
1028 B1(intBitsToFloat)
1029 B1(uintBitsToFloat)
1030
1031 BA1(doubleBitsToInt64)
1032 BA1(doubleBitsToUint64)
1033 BA1(int64BitsToDouble)
1034 BA1(uint64BitsToDouble)
1035
1036 ir_function_signature *_packUnorm2x16(builtin_available_predicate avail);
1037 ir_function_signature *_packSnorm2x16(builtin_available_predicate avail);
1038 ir_function_signature *_packUnorm4x8(builtin_available_predicate avail);
1039 ir_function_signature *_packSnorm4x8(builtin_available_predicate avail);
1040 ir_function_signature *_unpackUnorm2x16(builtin_available_predicate avail);
1041 ir_function_signature *_unpackSnorm2x16(builtin_available_predicate avail);
1042 ir_function_signature *_unpackUnorm4x8(builtin_available_predicate avail);
1043 ir_function_signature *_unpackSnorm4x8(builtin_available_predicate avail);
1044 ir_function_signature *_packHalf2x16(builtin_available_predicate avail);
1045 ir_function_signature *_unpackHalf2x16(builtin_available_predicate avail);
1046 ir_function_signature *_packDouble2x32(builtin_available_predicate avail);
1047 ir_function_signature *_unpackDouble2x32(builtin_available_predicate avail);
1048 ir_function_signature *_packInt2x32(builtin_available_predicate avail);
1049 ir_function_signature *_unpackInt2x32(builtin_available_predicate avail);
1050 ir_function_signature *_packUint2x32(builtin_available_predicate avail);
1051 ir_function_signature *_unpackUint2x32(builtin_available_predicate avail);
1052
1053 BA1(length)
1054 BA1(distance);
1055 BA1(dot);
1056 BA1(cross);
1057 BA1(normalize);
1058 B0(ftransform);
1059 BA1(faceforward);
1060 BA1(reflect);
1061 BA1(refract);
1062 BA1(matrixCompMult);
1063 BA1(outerProduct);
1064 BA1(determinant_mat2);
1065 BA1(determinant_mat3);
1066 BA1(determinant_mat4);
1067 BA1(inverse_mat2);
1068 BA1(inverse_mat3);
1069 BA1(inverse_mat4);
1070 BA1(transpose);
1071 BA1(lessThan);
1072 BA1(lessThanEqual);
1073 BA1(greaterThan);
1074 BA1(greaterThanEqual);
1075 BA1(equal);
1076 BA1(notEqual);
1077 B1(any);
1078 B1(all);
1079 B1(not);
1080 BA2(textureSize);
1081 BA1(textureSamples);
1082
1083 /** Flags to _texture() */
1084 #define TEX_PROJECT 1
1085 #define TEX_OFFSET 2
1086 #define TEX_COMPONENT 4
1087 #define TEX_OFFSET_NONCONST 8
1088 #define TEX_OFFSET_ARRAY 16
1089
1090 ir_function_signature *_texture(ir_texture_opcode opcode,
1091 builtin_available_predicate avail,
1092 const glsl_type *return_type,
1093 const glsl_type *sampler_type,
1094 const glsl_type *coord_type,
1095 int flags = 0);
1096 ir_function_signature *_textureCubeArrayShadow(ir_texture_opcode opcode,
1097 builtin_available_predicate avail,
1098 const glsl_type *x);
1099 ir_function_signature *_texelFetch(builtin_available_predicate avail,
1100 const glsl_type *return_type,
1101 const glsl_type *sampler_type,
1102 const glsl_type *coord_type,
1103 const glsl_type *offset_type = NULL);
1104
1105 B0(EmitVertex)
1106 B0(EndPrimitive)
1107 ir_function_signature *_EmitStreamVertex(builtin_available_predicate avail,
1108 const glsl_type *stream_type);
1109 ir_function_signature *_EndStreamPrimitive(builtin_available_predicate avail,
1110 const glsl_type *stream_type);
1111 B0(barrier)
1112
1113 BA2(textureQueryLod);
1114 BA1(textureQueryLevels);
1115 BA2(textureSamplesIdentical);
1116 B1(dFdx);
1117 B1(dFdy);
1118 B1(fwidth);
1119 B1(dFdxCoarse);
1120 B1(dFdyCoarse);
1121 B1(fwidthCoarse);
1122 B1(dFdxFine);
1123 B1(dFdyFine);
1124 B1(fwidthFine);
1125 B1(noise1);
1126 B1(noise2);
1127 B1(noise3);
1128 B1(noise4);
1129
1130 B1(bitfieldExtract)
1131 B1(bitfieldInsert)
1132 B1(bitfieldReverse)
1133 B1(bitCount)
1134 B1(findLSB)
1135 B1(findMSB)
1136 BA1(countLeadingZeros)
1137 BA1(countTrailingZeros)
1138 BA1(fma)
1139 B2(ldexp)
1140 B2(frexp)
1141 B2(dfrexp)
1142 B1(uaddCarry)
1143 B1(usubBorrow)
1144 BA1(addSaturate)
1145 BA1(subtractSaturate)
1146 BA1(absoluteDifference)
1147 BA1(average)
1148 BA1(averageRounded)
1149 B1(mulExtended)
1150 BA1(multiply32x16)
1151 B1(interpolateAtCentroid)
1152 B1(interpolateAtOffset)
1153 B1(interpolateAtSample)
1154
1155 ir_function_signature *_atomic_counter_intrinsic(builtin_available_predicate avail,
1156 enum ir_intrinsic_id id);
1157 ir_function_signature *_atomic_counter_intrinsic1(builtin_available_predicate avail,
1158 enum ir_intrinsic_id id);
1159 ir_function_signature *_atomic_counter_intrinsic2(builtin_available_predicate avail,
1160 enum ir_intrinsic_id id);
1161 ir_function_signature *_atomic_counter_op(const char *intrinsic,
1162 builtin_available_predicate avail);
1163 ir_function_signature *_atomic_counter_op1(const char *intrinsic,
1164 builtin_available_predicate avail);
1165 ir_function_signature *_atomic_counter_op2(const char *intrinsic,
1166 builtin_available_predicate avail);
1167
1168 ir_function_signature *_atomic_intrinsic2(builtin_available_predicate avail,
1169 const glsl_type *type,
1170 enum ir_intrinsic_id id);
1171 ir_function_signature *_atomic_op2(const char *intrinsic,
1172 builtin_available_predicate avail,
1173 const glsl_type *type);
1174 ir_function_signature *_atomic_intrinsic3(builtin_available_predicate avail,
1175 const glsl_type *type,
1176 enum ir_intrinsic_id id);
1177 ir_function_signature *_atomic_op3(const char *intrinsic,
1178 builtin_available_predicate avail,
1179 const glsl_type *type);
1180
1181 B1(min3)
1182 B1(max3)
1183 B1(mid3)
1184
1185 ir_function_signature *_image_prototype(const glsl_type *image_type,
1186 unsigned num_arguments,
1187 unsigned flags);
1188 ir_function_signature *_image_size_prototype(const glsl_type *image_type,
1189 unsigned num_arguments,
1190 unsigned flags);
1191 ir_function_signature *_image_samples_prototype(const glsl_type *image_type,
1192 unsigned num_arguments,
1193 unsigned flags);
1194 ir_function_signature *_image(image_prototype_ctr prototype,
1195 const glsl_type *image_type,
1196 const char *intrinsic_name,
1197 unsigned num_arguments,
1198 unsigned flags,
1199 enum ir_intrinsic_id id);
1200
1201 ir_function_signature *_memory_barrier_intrinsic(
1202 builtin_available_predicate avail,
1203 enum ir_intrinsic_id id);
1204 ir_function_signature *_memory_barrier(const char *intrinsic_name,
1205 builtin_available_predicate avail);
1206
1207 ir_function_signature *_ballot_intrinsic();
1208 ir_function_signature *_ballot();
1209 ir_function_signature *_read_first_invocation_intrinsic(const glsl_type *type);
1210 ir_function_signature *_read_first_invocation(const glsl_type *type);
1211 ir_function_signature *_read_invocation_intrinsic(const glsl_type *type);
1212 ir_function_signature *_read_invocation(const glsl_type *type);
1213
1214
1215 ir_function_signature *_invocation_interlock_intrinsic(
1216 builtin_available_predicate avail,
1217 enum ir_intrinsic_id id);
1218 ir_function_signature *_invocation_interlock(
1219 const char *intrinsic_name,
1220 builtin_available_predicate avail);
1221
1222 ir_function_signature *_shader_clock_intrinsic(builtin_available_predicate avail,
1223 const glsl_type *type);
1224 ir_function_signature *_shader_clock(builtin_available_predicate avail,
1225 const glsl_type *type);
1226
1227 ir_function_signature *_vote_intrinsic(builtin_available_predicate avail,
1228 enum ir_intrinsic_id id);
1229 ir_function_signature *_vote(const char *intrinsic_name,
1230 builtin_available_predicate avail);
1231
1232 ir_function_signature *_helper_invocation_intrinsic();
1233 ir_function_signature *_helper_invocation();
1234
1235 #undef B0
1236 #undef B1
1237 #undef B2
1238 #undef B3
1239 #undef BA1
1240 #undef BA2
1241 /** @} */
1242 };
1243
1244 enum image_function_flags {
1245 IMAGE_FUNCTION_EMIT_STUB = (1 << 0),
1246 IMAGE_FUNCTION_RETURNS_VOID = (1 << 1),
1247 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE = (1 << 2),
1248 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE = (1 << 3),
1249 IMAGE_FUNCTION_READ_ONLY = (1 << 4),
1250 IMAGE_FUNCTION_WRITE_ONLY = (1 << 5),
1251 IMAGE_FUNCTION_AVAIL_ATOMIC = (1 << 6),
1252 IMAGE_FUNCTION_MS_ONLY = (1 << 7),
1253 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE = (1 << 8),
1254 IMAGE_FUNCTION_AVAIL_ATOMIC_ADD = (1 << 9),
1255 IMAGE_FUNCTION_EXT_ONLY = (1 << 10),
1256 };
1257
1258 } /* anonymous namespace */
1259
1260 /**
1261 * Core builtin_builder functionality:
1262 * @{
1263 */
1264 builtin_builder::builtin_builder()
1265 : shader(NULL)
1266 {
1267 mem_ctx = NULL;
1268 }
1269
1270 builtin_builder::~builtin_builder()
1271 {
1272 ralloc_free(mem_ctx);
1273 }
1274
1275 ir_function_signature *
1276 builtin_builder::find(_mesa_glsl_parse_state *state,
1277 const char *name, exec_list *actual_parameters)
1278 {
1279 /* The shader currently being compiled requested a built-in function;
1280 * it needs to link against builtin_builder::shader in order to get them.
1281 *
1282 * Even if we don't find a matching signature, we still need to do this so
1283 * that the "no matching signature" error will list potential candidates
1284 * from the available built-ins.
1285 */
1286 state->uses_builtin_functions = true;
1287
1288 ir_function *f = shader->symbols->get_function(name);
1289 if (f == NULL)
1290 return NULL;
1291
1292 ir_function_signature *sig =
1293 f->matching_signature(state, actual_parameters, true);
1294 if (sig == NULL)
1295 return NULL;
1296
1297 return sig;
1298 }
1299
1300 void
1301 builtin_builder::initialize()
1302 {
1303 /* If already initialized, don't do it again. */
1304 if (mem_ctx != NULL)
1305 return;
1306
1307 glsl_type_singleton_init_or_ref();
1308
1309 mem_ctx = ralloc_context(NULL);
1310 create_shader();
1311 create_intrinsics();
1312 create_builtins();
1313 }
1314
1315 void
1316 builtin_builder::release()
1317 {
1318 ralloc_free(mem_ctx);
1319 mem_ctx = NULL;
1320
1321 ralloc_free(shader);
1322 shader = NULL;
1323
1324 glsl_type_singleton_decref();
1325 }
1326
1327 void
1328 builtin_builder::create_shader()
1329 {
1330 /* The target doesn't actually matter. There's no target for generic
1331 * GLSL utility code that could be linked against any stage, so just
1332 * arbitrarily pick GL_VERTEX_SHADER.
1333 */
1334 shader = _mesa_new_shader(0, MESA_SHADER_VERTEX);
1335 shader->symbols = new(mem_ctx) glsl_symbol_table;
1336 }
1337
1338 /** @} */
1339
1340 /**
1341 * Create ir_function and ir_function_signature objects for each
1342 * intrinsic.
1343 */
1344 void
1345 builtin_builder::create_intrinsics()
1346 {
1347 add_function("__intrinsic_atomic_read",
1348 _atomic_counter_intrinsic(shader_atomic_counters,
1349 ir_intrinsic_atomic_counter_read),
1350 NULL);
1351 add_function("__intrinsic_atomic_increment",
1352 _atomic_counter_intrinsic(shader_atomic_counters,
1353 ir_intrinsic_atomic_counter_increment),
1354 NULL);
1355 add_function("__intrinsic_atomic_predecrement",
1356 _atomic_counter_intrinsic(shader_atomic_counters,
1357 ir_intrinsic_atomic_counter_predecrement),
1358 NULL);
1359
1360 add_function("__intrinsic_atomic_add",
1361 _atomic_intrinsic2(buffer_atomics_supported,
1362 glsl_type::uint_type,
1363 ir_intrinsic_generic_atomic_add),
1364 _atomic_intrinsic2(buffer_atomics_supported,
1365 glsl_type::int_type,
1366 ir_intrinsic_generic_atomic_add),
1367 _atomic_intrinsic2(NV_shader_atomic_float_supported,
1368 glsl_type::float_type,
1369 ir_intrinsic_generic_atomic_add),
1370 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
1371 ir_intrinsic_atomic_counter_add),
1372 NULL);
1373 add_function("__intrinsic_atomic_min",
1374 _atomic_intrinsic2(buffer_atomics_supported,
1375 glsl_type::uint_type,
1376 ir_intrinsic_generic_atomic_min),
1377 _atomic_intrinsic2(buffer_atomics_supported,
1378 glsl_type::int_type,
1379 ir_intrinsic_generic_atomic_min),
1380 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported,
1381 glsl_type::float_type,
1382 ir_intrinsic_generic_atomic_min),
1383 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
1384 ir_intrinsic_atomic_counter_min),
1385 NULL);
1386 add_function("__intrinsic_atomic_max",
1387 _atomic_intrinsic2(buffer_atomics_supported,
1388 glsl_type::uint_type,
1389 ir_intrinsic_generic_atomic_max),
1390 _atomic_intrinsic2(buffer_atomics_supported,
1391 glsl_type::int_type,
1392 ir_intrinsic_generic_atomic_max),
1393 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported,
1394 glsl_type::float_type,
1395 ir_intrinsic_generic_atomic_max),
1396 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
1397 ir_intrinsic_atomic_counter_max),
1398 NULL);
1399 add_function("__intrinsic_atomic_and",
1400 _atomic_intrinsic2(buffer_atomics_supported,
1401 glsl_type::uint_type,
1402 ir_intrinsic_generic_atomic_and),
1403 _atomic_intrinsic2(buffer_atomics_supported,
1404 glsl_type::int_type,
1405 ir_intrinsic_generic_atomic_and),
1406 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
1407 ir_intrinsic_atomic_counter_and),
1408 NULL);
1409 add_function("__intrinsic_atomic_or",
1410 _atomic_intrinsic2(buffer_atomics_supported,
1411 glsl_type::uint_type,
1412 ir_intrinsic_generic_atomic_or),
1413 _atomic_intrinsic2(buffer_atomics_supported,
1414 glsl_type::int_type,
1415 ir_intrinsic_generic_atomic_or),
1416 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
1417 ir_intrinsic_atomic_counter_or),
1418 NULL);
1419 add_function("__intrinsic_atomic_xor",
1420 _atomic_intrinsic2(buffer_atomics_supported,
1421 glsl_type::uint_type,
1422 ir_intrinsic_generic_atomic_xor),
1423 _atomic_intrinsic2(buffer_atomics_supported,
1424 glsl_type::int_type,
1425 ir_intrinsic_generic_atomic_xor),
1426 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
1427 ir_intrinsic_atomic_counter_xor),
1428 NULL);
1429 add_function("__intrinsic_atomic_exchange",
1430 _atomic_intrinsic2(buffer_atomics_supported,
1431 glsl_type::uint_type,
1432 ir_intrinsic_generic_atomic_exchange),
1433 _atomic_intrinsic2(buffer_atomics_supported,
1434 glsl_type::int_type,
1435 ir_intrinsic_generic_atomic_exchange),
1436 _atomic_intrinsic2(NV_shader_atomic_float_supported,
1437 glsl_type::float_type,
1438 ir_intrinsic_generic_atomic_exchange),
1439 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
1440 ir_intrinsic_atomic_counter_exchange),
1441 NULL);
1442 add_function("__intrinsic_atomic_comp_swap",
1443 _atomic_intrinsic3(buffer_atomics_supported,
1444 glsl_type::uint_type,
1445 ir_intrinsic_generic_atomic_comp_swap),
1446 _atomic_intrinsic3(buffer_atomics_supported,
1447 glsl_type::int_type,
1448 ir_intrinsic_generic_atomic_comp_swap),
1449 _atomic_intrinsic3(INTEL_shader_atomic_float_minmax_supported,
1450 glsl_type::float_type,
1451 ir_intrinsic_generic_atomic_comp_swap),
1452 _atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop,
1453 ir_intrinsic_atomic_counter_comp_swap),
1454 NULL);
1455
1456 add_image_functions(false);
1457
1458 add_function("__intrinsic_memory_barrier",
1459 _memory_barrier_intrinsic(shader_image_load_store,
1460 ir_intrinsic_memory_barrier),
1461 NULL);
1462 add_function("__intrinsic_group_memory_barrier",
1463 _memory_barrier_intrinsic(compute_shader,
1464 ir_intrinsic_group_memory_barrier),
1465 NULL);
1466 add_function("__intrinsic_memory_barrier_atomic_counter",
1467 _memory_barrier_intrinsic(compute_shader_supported,
1468 ir_intrinsic_memory_barrier_atomic_counter),
1469 NULL);
1470 add_function("__intrinsic_memory_barrier_buffer",
1471 _memory_barrier_intrinsic(compute_shader_supported,
1472 ir_intrinsic_memory_barrier_buffer),
1473 NULL);
1474 add_function("__intrinsic_memory_barrier_image",
1475 _memory_barrier_intrinsic(compute_shader_supported,
1476 ir_intrinsic_memory_barrier_image),
1477 NULL);
1478 add_function("__intrinsic_memory_barrier_shared",
1479 _memory_barrier_intrinsic(compute_shader,
1480 ir_intrinsic_memory_barrier_shared),
1481 NULL);
1482
1483 add_function("__intrinsic_begin_invocation_interlock",
1484 _invocation_interlock_intrinsic(
1485 supports_arb_fragment_shader_interlock,
1486 ir_intrinsic_begin_invocation_interlock), NULL);
1487
1488 add_function("__intrinsic_end_invocation_interlock",
1489 _invocation_interlock_intrinsic(
1490 supports_arb_fragment_shader_interlock,
1491 ir_intrinsic_end_invocation_interlock), NULL);
1492
1493 add_function("__intrinsic_shader_clock",
1494 _shader_clock_intrinsic(shader_clock,
1495 glsl_type::uvec2_type),
1496 NULL);
1497
1498 add_function("__intrinsic_vote_all",
1499 _vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_all),
1500 NULL);
1501 add_function("__intrinsic_vote_any",
1502 _vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_any),
1503 NULL);
1504 add_function("__intrinsic_vote_eq",
1505 _vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_eq),
1506 NULL);
1507
1508 add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL);
1509
1510 add_function("__intrinsic_read_invocation",
1511 _read_invocation_intrinsic(glsl_type::float_type),
1512 _read_invocation_intrinsic(glsl_type::vec2_type),
1513 _read_invocation_intrinsic(glsl_type::vec3_type),
1514 _read_invocation_intrinsic(glsl_type::vec4_type),
1515
1516 _read_invocation_intrinsic(glsl_type::int_type),
1517 _read_invocation_intrinsic(glsl_type::ivec2_type),
1518 _read_invocation_intrinsic(glsl_type::ivec3_type),
1519 _read_invocation_intrinsic(glsl_type::ivec4_type),
1520
1521 _read_invocation_intrinsic(glsl_type::uint_type),
1522 _read_invocation_intrinsic(glsl_type::uvec2_type),
1523 _read_invocation_intrinsic(glsl_type::uvec3_type),
1524 _read_invocation_intrinsic(glsl_type::uvec4_type),
1525 NULL);
1526
1527 add_function("__intrinsic_read_first_invocation",
1528 _read_first_invocation_intrinsic(glsl_type::float_type),
1529 _read_first_invocation_intrinsic(glsl_type::vec2_type),
1530 _read_first_invocation_intrinsic(glsl_type::vec3_type),
1531 _read_first_invocation_intrinsic(glsl_type::vec4_type),
1532
1533 _read_first_invocation_intrinsic(glsl_type::int_type),
1534 _read_first_invocation_intrinsic(glsl_type::ivec2_type),
1535 _read_first_invocation_intrinsic(glsl_type::ivec3_type),
1536 _read_first_invocation_intrinsic(glsl_type::ivec4_type),
1537
1538 _read_first_invocation_intrinsic(glsl_type::uint_type),
1539 _read_first_invocation_intrinsic(glsl_type::uvec2_type),
1540 _read_first_invocation_intrinsic(glsl_type::uvec3_type),
1541 _read_first_invocation_intrinsic(glsl_type::uvec4_type),
1542 NULL);
1543
1544 add_function("__intrinsic_helper_invocation",
1545 _helper_invocation_intrinsic(), NULL);
1546 }
1547
1548 /**
1549 * Create ir_function and ir_function_signature objects for each built-in.
1550 *
1551 * Contains a list of every available built-in.
1552 */
1553 void
1554 builtin_builder::create_builtins()
1555 {
1556 #define F(NAME) \
1557 add_function(#NAME, \
1558 _##NAME(glsl_type::float_type), \
1559 _##NAME(glsl_type::vec2_type), \
1560 _##NAME(glsl_type::vec3_type), \
1561 _##NAME(glsl_type::vec4_type), \
1562 NULL);
1563
1564 #define FD(NAME) \
1565 add_function(#NAME, \
1566 _##NAME(always_available, glsl_type::float_type), \
1567 _##NAME(always_available, glsl_type::vec2_type), \
1568 _##NAME(always_available, glsl_type::vec3_type), \
1569 _##NAME(always_available, glsl_type::vec4_type), \
1570 _##NAME(fp64, glsl_type::double_type), \
1571 _##NAME(fp64, glsl_type::dvec2_type), \
1572 _##NAME(fp64, glsl_type::dvec3_type), \
1573 _##NAME(fp64, glsl_type::dvec4_type), \
1574 NULL);
1575
1576 #define FD130(NAME) \
1577 add_function(#NAME, \
1578 _##NAME(v130, glsl_type::float_type), \
1579 _##NAME(v130, glsl_type::vec2_type), \
1580 _##NAME(v130, glsl_type::vec3_type), \
1581 _##NAME(v130, glsl_type::vec4_type), \
1582 _##NAME(fp64, glsl_type::double_type), \
1583 _##NAME(fp64, glsl_type::dvec2_type), \
1584 _##NAME(fp64, glsl_type::dvec3_type), \
1585 _##NAME(fp64, glsl_type::dvec4_type), \
1586 NULL);
1587
1588 #define FDGS5(NAME) \
1589 add_function(#NAME, \
1590 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1591 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1592 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1593 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1594 _##NAME(fp64, glsl_type::double_type), \
1595 _##NAME(fp64, glsl_type::dvec2_type), \
1596 _##NAME(fp64, glsl_type::dvec3_type), \
1597 _##NAME(fp64, glsl_type::dvec4_type), \
1598 NULL);
1599
1600 #define FI(NAME) \
1601 add_function(#NAME, \
1602 _##NAME(glsl_type::float_type), \
1603 _##NAME(glsl_type::vec2_type), \
1604 _##NAME(glsl_type::vec3_type), \
1605 _##NAME(glsl_type::vec4_type), \
1606 _##NAME(glsl_type::int_type), \
1607 _##NAME(glsl_type::ivec2_type), \
1608 _##NAME(glsl_type::ivec3_type), \
1609 _##NAME(glsl_type::ivec4_type), \
1610 NULL);
1611
1612 #define FI64(NAME) \
1613 add_function(#NAME, \
1614 _##NAME(always_available, glsl_type::float_type), \
1615 _##NAME(always_available, glsl_type::vec2_type), \
1616 _##NAME(always_available, glsl_type::vec3_type), \
1617 _##NAME(always_available, glsl_type::vec4_type), \
1618 _##NAME(always_available, glsl_type::int_type), \
1619 _##NAME(always_available, glsl_type::ivec2_type), \
1620 _##NAME(always_available, glsl_type::ivec3_type), \
1621 _##NAME(always_available, glsl_type::ivec4_type), \
1622 _##NAME(fp64, glsl_type::double_type), \
1623 _##NAME(fp64, glsl_type::dvec2_type), \
1624 _##NAME(fp64, glsl_type::dvec3_type), \
1625 _##NAME(fp64, glsl_type::dvec4_type), \
1626 _##NAME(int64, glsl_type::int64_t_type), \
1627 _##NAME(int64, glsl_type::i64vec2_type), \
1628 _##NAME(int64, glsl_type::i64vec3_type), \
1629 _##NAME(int64, glsl_type::i64vec4_type), \
1630 NULL);
1631
1632 #define FIUD_VEC(NAME) \
1633 add_function(#NAME, \
1634 _##NAME(always_available, glsl_type::vec2_type), \
1635 _##NAME(always_available, glsl_type::vec3_type), \
1636 _##NAME(always_available, glsl_type::vec4_type), \
1637 \
1638 _##NAME(always_available, glsl_type::ivec2_type), \
1639 _##NAME(always_available, glsl_type::ivec3_type), \
1640 _##NAME(always_available, glsl_type::ivec4_type), \
1641 \
1642 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \
1643 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \
1644 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \
1645 _##NAME(fp64, glsl_type::dvec2_type), \
1646 _##NAME(fp64, glsl_type::dvec3_type), \
1647 _##NAME(fp64, glsl_type::dvec4_type), \
1648 _##NAME(int64, glsl_type::int64_t_type), \
1649 _##NAME(int64, glsl_type::i64vec2_type), \
1650 _##NAME(int64, glsl_type::i64vec3_type), \
1651 _##NAME(int64, glsl_type::i64vec4_type), \
1652 _##NAME(int64, glsl_type::uint64_t_type), \
1653 _##NAME(int64, glsl_type::u64vec2_type), \
1654 _##NAME(int64, glsl_type::u64vec3_type), \
1655 _##NAME(int64, glsl_type::u64vec4_type), \
1656 NULL);
1657
1658 #define IU(NAME) \
1659 add_function(#NAME, \
1660 _##NAME(glsl_type::int_type), \
1661 _##NAME(glsl_type::ivec2_type), \
1662 _##NAME(glsl_type::ivec3_type), \
1663 _##NAME(glsl_type::ivec4_type), \
1664 \
1665 _##NAME(glsl_type::uint_type), \
1666 _##NAME(glsl_type::uvec2_type), \
1667 _##NAME(glsl_type::uvec3_type), \
1668 _##NAME(glsl_type::uvec4_type), \
1669 NULL);
1670
1671 #define FIUBD_VEC(NAME) \
1672 add_function(#NAME, \
1673 _##NAME(always_available, glsl_type::vec2_type), \
1674 _##NAME(always_available, glsl_type::vec3_type), \
1675 _##NAME(always_available, glsl_type::vec4_type), \
1676 \
1677 _##NAME(always_available, glsl_type::ivec2_type), \
1678 _##NAME(always_available, glsl_type::ivec3_type), \
1679 _##NAME(always_available, glsl_type::ivec4_type), \
1680 \
1681 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \
1682 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \
1683 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \
1684 \
1685 _##NAME(always_available, glsl_type::bvec2_type), \
1686 _##NAME(always_available, glsl_type::bvec3_type), \
1687 _##NAME(always_available, glsl_type::bvec4_type), \
1688 \
1689 _##NAME(fp64, glsl_type::dvec2_type), \
1690 _##NAME(fp64, glsl_type::dvec3_type), \
1691 _##NAME(fp64, glsl_type::dvec4_type), \
1692 _##NAME(int64, glsl_type::int64_t_type), \
1693 _##NAME(int64, glsl_type::i64vec2_type), \
1694 _##NAME(int64, glsl_type::i64vec3_type), \
1695 _##NAME(int64, glsl_type::i64vec4_type), \
1696 _##NAME(int64, glsl_type::uint64_t_type), \
1697 _##NAME(int64, glsl_type::u64vec2_type), \
1698 _##NAME(int64, glsl_type::u64vec3_type), \
1699 _##NAME(int64, glsl_type::u64vec4_type), \
1700 NULL);
1701
1702 #define FIUD2_MIXED(NAME) \
1703 add_function(#NAME, \
1704 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1705 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1706 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1707 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1708 \
1709 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1710 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1711 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1712 \
1713 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1714 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1715 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1716 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1717 \
1718 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1719 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1720 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1721 \
1722 _##NAME(v130_or_gpu_shader4, glsl_type::uint_type, glsl_type::uint_type), \
1723 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uint_type), \
1724 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uint_type), \
1725 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uint_type), \
1726 \
1727 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1728 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1729 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1730 \
1731 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1732 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1733 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1734 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1735 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1736 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1737 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1738 \
1739 _##NAME(int64, glsl_type::int64_t_type, glsl_type::int64_t_type), \
1740 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::int64_t_type), \
1741 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::int64_t_type), \
1742 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::int64_t_type), \
1743 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::i64vec2_type), \
1744 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::i64vec3_type), \
1745 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::i64vec4_type), \
1746 _##NAME(int64, glsl_type::uint64_t_type, glsl_type::uint64_t_type), \
1747 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::uint64_t_type), \
1748 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::uint64_t_type), \
1749 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::uint64_t_type), \
1750 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::u64vec2_type), \
1751 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::u64vec3_type), \
1752 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::u64vec4_type), \
1753 NULL);
1754
1755 F(radians)
1756 F(degrees)
1757 F(sin)
1758 F(cos)
1759 F(tan)
1760 F(asin)
1761 F(acos)
1762
1763 add_function("atan",
1764 _atan(glsl_type::float_type),
1765 _atan(glsl_type::vec2_type),
1766 _atan(glsl_type::vec3_type),
1767 _atan(glsl_type::vec4_type),
1768 _atan2(glsl_type::float_type),
1769 _atan2(glsl_type::vec2_type),
1770 _atan2(glsl_type::vec3_type),
1771 _atan2(glsl_type::vec4_type),
1772 _atan_op(glsl_type::float_type),
1773 _atan_op(glsl_type::vec2_type),
1774 _atan_op(glsl_type::vec3_type),
1775 _atan_op(glsl_type::vec4_type),
1776 _atan2_op(glsl_type::float_type),
1777 _atan2_op(glsl_type::vec2_type),
1778 _atan2_op(glsl_type::vec3_type),
1779 _atan2_op(glsl_type::vec4_type),
1780 NULL);
1781
1782 F(sinh)
1783 F(cosh)
1784 F(tanh)
1785 F(asinh)
1786 F(acosh)
1787 F(atanh)
1788 F(pow)
1789 F(exp)
1790 F(log)
1791 F(exp2)
1792 F(log2)
1793 FD(sqrt)
1794 FD(inversesqrt)
1795 FI64(abs)
1796 FI64(sign)
1797 FD(floor)
1798 FD(trunc)
1799 FD(round)
1800 FD(roundEven)
1801 FD(ceil)
1802 FD(fract)
1803
1804 add_function("truncate",
1805 _truncate(gpu_shader4, glsl_type::float_type),
1806 _truncate(gpu_shader4, glsl_type::vec2_type),
1807 _truncate(gpu_shader4, glsl_type::vec3_type),
1808 _truncate(gpu_shader4, glsl_type::vec4_type),
1809 NULL);
1810
1811
1812 add_function("mod",
1813 _mod(always_available, glsl_type::float_type, glsl_type::float_type),
1814 _mod(always_available, glsl_type::vec2_type, glsl_type::float_type),
1815 _mod(always_available, glsl_type::vec3_type, glsl_type::float_type),
1816 _mod(always_available, glsl_type::vec4_type, glsl_type::float_type),
1817
1818 _mod(always_available, glsl_type::vec2_type, glsl_type::vec2_type),
1819 _mod(always_available, glsl_type::vec3_type, glsl_type::vec3_type),
1820 _mod(always_available, glsl_type::vec4_type, glsl_type::vec4_type),
1821
1822 _mod(fp64, glsl_type::double_type, glsl_type::double_type),
1823 _mod(fp64, glsl_type::dvec2_type, glsl_type::double_type),
1824 _mod(fp64, glsl_type::dvec3_type, glsl_type::double_type),
1825 _mod(fp64, glsl_type::dvec4_type, glsl_type::double_type),
1826
1827 _mod(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type),
1828 _mod(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type),
1829 _mod(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type),
1830 NULL);
1831
1832 FD(modf)
1833
1834 FIUD2_MIXED(min)
1835 FIUD2_MIXED(max)
1836 FIUD2_MIXED(clamp)
1837
1838 add_function("mix",
1839 _mix_lrp(always_available, glsl_type::float_type, glsl_type::float_type),
1840 _mix_lrp(always_available, glsl_type::vec2_type, glsl_type::float_type),
1841 _mix_lrp(always_available, glsl_type::vec3_type, glsl_type::float_type),
1842 _mix_lrp(always_available, glsl_type::vec4_type, glsl_type::float_type),
1843
1844 _mix_lrp(always_available, glsl_type::vec2_type, glsl_type::vec2_type),
1845 _mix_lrp(always_available, glsl_type::vec3_type, glsl_type::vec3_type),
1846 _mix_lrp(always_available, glsl_type::vec4_type, glsl_type::vec4_type),
1847
1848 _mix_lrp(fp64, glsl_type::double_type, glsl_type::double_type),
1849 _mix_lrp(fp64, glsl_type::dvec2_type, glsl_type::double_type),
1850 _mix_lrp(fp64, glsl_type::dvec3_type, glsl_type::double_type),
1851 _mix_lrp(fp64, glsl_type::dvec4_type, glsl_type::double_type),
1852
1853 _mix_lrp(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type),
1854 _mix_lrp(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type),
1855 _mix_lrp(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type),
1856
1857 _mix_sel(v130, glsl_type::float_type, glsl_type::bool_type),
1858 _mix_sel(v130, glsl_type::vec2_type, glsl_type::bvec2_type),
1859 _mix_sel(v130, glsl_type::vec3_type, glsl_type::bvec3_type),
1860 _mix_sel(v130, glsl_type::vec4_type, glsl_type::bvec4_type),
1861
1862 _mix_sel(fp64, glsl_type::double_type, glsl_type::bool_type),
1863 _mix_sel(fp64, glsl_type::dvec2_type, glsl_type::bvec2_type),
1864 _mix_sel(fp64, glsl_type::dvec3_type, glsl_type::bvec3_type),
1865 _mix_sel(fp64, glsl_type::dvec4_type, glsl_type::bvec4_type),
1866
1867 _mix_sel(shader_integer_mix, glsl_type::int_type, glsl_type::bool_type),
1868 _mix_sel(shader_integer_mix, glsl_type::ivec2_type, glsl_type::bvec2_type),
1869 _mix_sel(shader_integer_mix, glsl_type::ivec3_type, glsl_type::bvec3_type),
1870 _mix_sel(shader_integer_mix, glsl_type::ivec4_type, glsl_type::bvec4_type),
1871
1872 _mix_sel(shader_integer_mix, glsl_type::uint_type, glsl_type::bool_type),
1873 _mix_sel(shader_integer_mix, glsl_type::uvec2_type, glsl_type::bvec2_type),
1874 _mix_sel(shader_integer_mix, glsl_type::uvec3_type, glsl_type::bvec3_type),
1875 _mix_sel(shader_integer_mix, glsl_type::uvec4_type, glsl_type::bvec4_type),
1876
1877 _mix_sel(shader_integer_mix, glsl_type::bool_type, glsl_type::bool_type),
1878 _mix_sel(shader_integer_mix, glsl_type::bvec2_type, glsl_type::bvec2_type),
1879 _mix_sel(shader_integer_mix, glsl_type::bvec3_type, glsl_type::bvec3_type),
1880 _mix_sel(shader_integer_mix, glsl_type::bvec4_type, glsl_type::bvec4_type),
1881
1882 _mix_sel(int64, glsl_type::int64_t_type, glsl_type::bool_type),
1883 _mix_sel(int64, glsl_type::i64vec2_type, glsl_type::bvec2_type),
1884 _mix_sel(int64, glsl_type::i64vec3_type, glsl_type::bvec3_type),
1885 _mix_sel(int64, glsl_type::i64vec4_type, glsl_type::bvec4_type),
1886
1887 _mix_sel(int64, glsl_type::uint64_t_type, glsl_type::bool_type),
1888 _mix_sel(int64, glsl_type::u64vec2_type, glsl_type::bvec2_type),
1889 _mix_sel(int64, glsl_type::u64vec3_type, glsl_type::bvec3_type),
1890 _mix_sel(int64, glsl_type::u64vec4_type, glsl_type::bvec4_type),
1891 NULL);
1892
1893 add_function("step",
1894 _step(always_available, glsl_type::float_type, glsl_type::float_type),
1895 _step(always_available, glsl_type::float_type, glsl_type::vec2_type),
1896 _step(always_available, glsl_type::float_type, glsl_type::vec3_type),
1897 _step(always_available, glsl_type::float_type, glsl_type::vec4_type),
1898
1899 _step(always_available, glsl_type::vec2_type, glsl_type::vec2_type),
1900 _step(always_available, glsl_type::vec3_type, glsl_type::vec3_type),
1901 _step(always_available, glsl_type::vec4_type, glsl_type::vec4_type),
1902 _step(fp64, glsl_type::double_type, glsl_type::double_type),
1903 _step(fp64, glsl_type::double_type, glsl_type::dvec2_type),
1904 _step(fp64, glsl_type::double_type, glsl_type::dvec3_type),
1905 _step(fp64, glsl_type::double_type, glsl_type::dvec4_type),
1906
1907 _step(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type),
1908 _step(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type),
1909 _step(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type),
1910 NULL);
1911
1912 add_function("smoothstep",
1913 _smoothstep(always_available, glsl_type::float_type, glsl_type::float_type),
1914 _smoothstep(always_available, glsl_type::float_type, glsl_type::vec2_type),
1915 _smoothstep(always_available, glsl_type::float_type, glsl_type::vec3_type),
1916 _smoothstep(always_available, glsl_type::float_type, glsl_type::vec4_type),
1917
1918 _smoothstep(always_available, glsl_type::vec2_type, glsl_type::vec2_type),
1919 _smoothstep(always_available, glsl_type::vec3_type, glsl_type::vec3_type),
1920 _smoothstep(always_available, glsl_type::vec4_type, glsl_type::vec4_type),
1921 _smoothstep(fp64, glsl_type::double_type, glsl_type::double_type),
1922 _smoothstep(fp64, glsl_type::double_type, glsl_type::dvec2_type),
1923 _smoothstep(fp64, glsl_type::double_type, glsl_type::dvec3_type),
1924 _smoothstep(fp64, glsl_type::double_type, glsl_type::dvec4_type),
1925
1926 _smoothstep(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type),
1927 _smoothstep(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type),
1928 _smoothstep(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type),
1929 NULL);
1930
1931 FD130(isnan)
1932 FD130(isinf)
1933
1934 F(floatBitsToInt)
1935 F(floatBitsToUint)
1936 add_function("intBitsToFloat",
1937 _intBitsToFloat(glsl_type::int_type),
1938 _intBitsToFloat(glsl_type::ivec2_type),
1939 _intBitsToFloat(glsl_type::ivec3_type),
1940 _intBitsToFloat(glsl_type::ivec4_type),
1941 NULL);
1942 add_function("uintBitsToFloat",
1943 _uintBitsToFloat(glsl_type::uint_type),
1944 _uintBitsToFloat(glsl_type::uvec2_type),
1945 _uintBitsToFloat(glsl_type::uvec3_type),
1946 _uintBitsToFloat(glsl_type::uvec4_type),
1947 NULL);
1948
1949 add_function("doubleBitsToInt64",
1950 _doubleBitsToInt64(int64_fp64, glsl_type::double_type),
1951 _doubleBitsToInt64(int64_fp64, glsl_type::dvec2_type),
1952 _doubleBitsToInt64(int64_fp64, glsl_type::dvec3_type),
1953 _doubleBitsToInt64(int64_fp64, glsl_type::dvec4_type),
1954 NULL);
1955
1956 add_function("doubleBitsToUint64",
1957 _doubleBitsToUint64(int64_fp64, glsl_type::double_type),
1958 _doubleBitsToUint64(int64_fp64, glsl_type::dvec2_type),
1959 _doubleBitsToUint64(int64_fp64, glsl_type::dvec3_type),
1960 _doubleBitsToUint64(int64_fp64, glsl_type::dvec4_type),
1961 NULL);
1962
1963 add_function("int64BitsToDouble",
1964 _int64BitsToDouble(int64_fp64, glsl_type::int64_t_type),
1965 _int64BitsToDouble(int64_fp64, glsl_type::i64vec2_type),
1966 _int64BitsToDouble(int64_fp64, glsl_type::i64vec3_type),
1967 _int64BitsToDouble(int64_fp64, glsl_type::i64vec4_type),
1968 NULL);
1969
1970 add_function("uint64BitsToDouble",
1971 _uint64BitsToDouble(int64_fp64, glsl_type::uint64_t_type),
1972 _uint64BitsToDouble(int64_fp64, glsl_type::u64vec2_type),
1973 _uint64BitsToDouble(int64_fp64, glsl_type::u64vec3_type),
1974 _uint64BitsToDouble(int64_fp64, glsl_type::u64vec4_type),
1975 NULL);
1976
1977 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5), NULL);
1978 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3), NULL);
1979 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);
1980 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);
1981 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5), NULL);
1982 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3), NULL);
1983 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);
1984 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);
1985 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3), NULL);
1986 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3), NULL);
1987 add_function("packDouble2x32", _packDouble2x32(fp64), NULL);
1988 add_function("unpackDouble2x32", _unpackDouble2x32(fp64), NULL);
1989
1990 add_function("packInt2x32", _packInt2x32(int64), NULL);
1991 add_function("unpackInt2x32", _unpackInt2x32(int64), NULL);
1992 add_function("packUint2x32", _packUint2x32(int64), NULL);
1993 add_function("unpackUint2x32", _unpackUint2x32(int64), NULL);
1994
1995 FD(length)
1996 FD(distance)
1997 FD(dot)
1998
1999 add_function("cross", _cross(always_available, glsl_type::vec3_type),
2000 _cross(fp64, glsl_type::dvec3_type), NULL);
2001
2002 FD(normalize)
2003 add_function("ftransform", _ftransform(), NULL);
2004 FD(faceforward)
2005 FD(reflect)
2006 FD(refract)
2007 // ...
2008 add_function("matrixCompMult",
2009 _matrixCompMult(always_available, glsl_type::mat2_type),
2010 _matrixCompMult(always_available, glsl_type::mat3_type),
2011 _matrixCompMult(always_available, glsl_type::mat4_type),
2012 _matrixCompMult(always_available, glsl_type::mat2x3_type),
2013 _matrixCompMult(always_available, glsl_type::mat2x4_type),
2014 _matrixCompMult(always_available, glsl_type::mat3x2_type),
2015 _matrixCompMult(always_available, glsl_type::mat3x4_type),
2016 _matrixCompMult(always_available, glsl_type::mat4x2_type),
2017 _matrixCompMult(always_available, glsl_type::mat4x3_type),
2018 _matrixCompMult(fp64, glsl_type::dmat2_type),
2019 _matrixCompMult(fp64, glsl_type::dmat3_type),
2020 _matrixCompMult(fp64, glsl_type::dmat4_type),
2021 _matrixCompMult(fp64, glsl_type::dmat2x3_type),
2022 _matrixCompMult(fp64, glsl_type::dmat2x4_type),
2023 _matrixCompMult(fp64, glsl_type::dmat3x2_type),
2024 _matrixCompMult(fp64, glsl_type::dmat3x4_type),
2025 _matrixCompMult(fp64, glsl_type::dmat4x2_type),
2026 _matrixCompMult(fp64, glsl_type::dmat4x3_type),
2027 NULL);
2028 add_function("outerProduct",
2029 _outerProduct(v120, glsl_type::mat2_type),
2030 _outerProduct(v120, glsl_type::mat3_type),
2031 _outerProduct(v120, glsl_type::mat4_type),
2032 _outerProduct(v120, glsl_type::mat2x3_type),
2033 _outerProduct(v120, glsl_type::mat2x4_type),
2034 _outerProduct(v120, glsl_type::mat3x2_type),
2035 _outerProduct(v120, glsl_type::mat3x4_type),
2036 _outerProduct(v120, glsl_type::mat4x2_type),
2037 _outerProduct(v120, glsl_type::mat4x3_type),
2038 _outerProduct(fp64, glsl_type::dmat2_type),
2039 _outerProduct(fp64, glsl_type::dmat3_type),
2040 _outerProduct(fp64, glsl_type::dmat4_type),
2041 _outerProduct(fp64, glsl_type::dmat2x3_type),
2042 _outerProduct(fp64, glsl_type::dmat2x4_type),
2043 _outerProduct(fp64, glsl_type::dmat3x2_type),
2044 _outerProduct(fp64, glsl_type::dmat3x4_type),
2045 _outerProduct(fp64, glsl_type::dmat4x2_type),
2046 _outerProduct(fp64, glsl_type::dmat4x3_type),
2047 NULL);
2048 add_function("determinant",
2049 _determinant_mat2(v120, glsl_type::mat2_type),
2050 _determinant_mat3(v120, glsl_type::mat3_type),
2051 _determinant_mat4(v120, glsl_type::mat4_type),
2052 _determinant_mat2(fp64, glsl_type::dmat2_type),
2053 _determinant_mat3(fp64, glsl_type::dmat3_type),
2054 _determinant_mat4(fp64, glsl_type::dmat4_type),
2055
2056 NULL);
2057 add_function("inverse",
2058 _inverse_mat2(v140_or_es3, glsl_type::mat2_type),
2059 _inverse_mat3(v140_or_es3, glsl_type::mat3_type),
2060 _inverse_mat4(v140_or_es3, glsl_type::mat4_type),
2061 _inverse_mat2(fp64, glsl_type::dmat2_type),
2062 _inverse_mat3(fp64, glsl_type::dmat3_type),
2063 _inverse_mat4(fp64, glsl_type::dmat4_type),
2064 NULL);
2065 add_function("transpose",
2066 _transpose(v120, glsl_type::mat2_type),
2067 _transpose(v120, glsl_type::mat3_type),
2068 _transpose(v120, glsl_type::mat4_type),
2069 _transpose(v120, glsl_type::mat2x3_type),
2070 _transpose(v120, glsl_type::mat2x4_type),
2071 _transpose(v120, glsl_type::mat3x2_type),
2072 _transpose(v120, glsl_type::mat3x4_type),
2073 _transpose(v120, glsl_type::mat4x2_type),
2074 _transpose(v120, glsl_type::mat4x3_type),
2075 _transpose(fp64, glsl_type::dmat2_type),
2076 _transpose(fp64, glsl_type::dmat3_type),
2077 _transpose(fp64, glsl_type::dmat4_type),
2078 _transpose(fp64, glsl_type::dmat2x3_type),
2079 _transpose(fp64, glsl_type::dmat2x4_type),
2080 _transpose(fp64, glsl_type::dmat3x2_type),
2081 _transpose(fp64, glsl_type::dmat3x4_type),
2082 _transpose(fp64, glsl_type::dmat4x2_type),
2083 _transpose(fp64, glsl_type::dmat4x3_type),
2084 NULL);
2085 FIUD_VEC(lessThan)
2086 FIUD_VEC(lessThanEqual)
2087 FIUD_VEC(greaterThan)
2088 FIUD_VEC(greaterThanEqual)
2089 FIUBD_VEC(notEqual)
2090 FIUBD_VEC(equal)
2091
2092 add_function("any",
2093 _any(glsl_type::bvec2_type),
2094 _any(glsl_type::bvec3_type),
2095 _any(glsl_type::bvec4_type),
2096 NULL);
2097
2098 add_function("all",
2099 _all(glsl_type::bvec2_type),
2100 _all(glsl_type::bvec3_type),
2101 _all(glsl_type::bvec4_type),
2102 NULL);
2103
2104 add_function("not",
2105 _not(glsl_type::bvec2_type),
2106 _not(glsl_type::bvec3_type),
2107 _not(glsl_type::bvec4_type),
2108 NULL);
2109
2110 add_function("textureSize",
2111 _textureSize(v130, glsl_type::int_type, glsl_type::sampler1D_type),
2112 _textureSize(v130, glsl_type::int_type, glsl_type::isampler1D_type),
2113 _textureSize(v130, glsl_type::int_type, glsl_type::usampler1D_type),
2114
2115 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2D_type),
2116 _textureSize(v130, glsl_type::ivec2_type, glsl_type::isampler2D_type),
2117 _textureSize(v130, glsl_type::ivec2_type, glsl_type::usampler2D_type),
2118
2119 _textureSize(v130, glsl_type::ivec3_type, glsl_type::sampler3D_type),
2120 _textureSize(v130, glsl_type::ivec3_type, glsl_type::isampler3D_type),
2121 _textureSize(v130, glsl_type::ivec3_type, glsl_type::usampler3D_type),
2122
2123 _textureSize(v130, glsl_type::ivec2_type, glsl_type::samplerCube_type),
2124 _textureSize(v130, glsl_type::ivec2_type, glsl_type::isamplerCube_type),
2125 _textureSize(v130, glsl_type::ivec2_type, glsl_type::usamplerCube_type),
2126
2127 _textureSize(v130, glsl_type::int_type, glsl_type::sampler1DShadow_type),
2128 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2DShadow_type),
2129 _textureSize(v130, glsl_type::ivec2_type, glsl_type::samplerCubeShadow_type),
2130
2131 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler1DArray_type),
2132 _textureSize(v130, glsl_type::ivec2_type, glsl_type::isampler1DArray_type),
2133 _textureSize(v130, glsl_type::ivec2_type, glsl_type::usampler1DArray_type),
2134 _textureSize(v130, glsl_type::ivec3_type, glsl_type::sampler2DArray_type),
2135 _textureSize(v130, glsl_type::ivec3_type, glsl_type::isampler2DArray_type),
2136 _textureSize(v130, glsl_type::ivec3_type, glsl_type::usampler2DArray_type),
2137
2138 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler1DArrayShadow_type),
2139 _textureSize(v130, glsl_type::ivec3_type, glsl_type::sampler2DArrayShadow_type),
2140
2141 _textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::samplerCubeArray_type),
2142 _textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::isamplerCubeArray_type),
2143 _textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::usamplerCubeArray_type),
2144 _textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::samplerCubeArrayShadow_type),
2145
2146 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2DRect_type),
2147 _textureSize(v130, glsl_type::ivec2_type, glsl_type::isampler2DRect_type),
2148 _textureSize(v130, glsl_type::ivec2_type, glsl_type::usampler2DRect_type),
2149 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2DRectShadow_type),
2150
2151 _textureSize(texture_buffer, glsl_type::int_type, glsl_type::samplerBuffer_type),
2152 _textureSize(texture_buffer, glsl_type::int_type, glsl_type::isamplerBuffer_type),
2153 _textureSize(texture_buffer, glsl_type::int_type, glsl_type::usamplerBuffer_type),
2154 _textureSize(texture_multisample, glsl_type::ivec2_type, glsl_type::sampler2DMS_type),
2155 _textureSize(texture_multisample, glsl_type::ivec2_type, glsl_type::isampler2DMS_type),
2156 _textureSize(texture_multisample, glsl_type::ivec2_type, glsl_type::usampler2DMS_type),
2157
2158 _textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::sampler2DMSArray_type),
2159 _textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::isampler2DMSArray_type),
2160 _textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::usampler2DMSArray_type),
2161
2162 _textureSize(texture_external_es3, glsl_type::ivec2_type, glsl_type::samplerExternalOES_type),
2163 NULL);
2164
2165 add_function("textureSize1D",
2166 _textureSize(gpu_shader4, glsl_type::int_type, glsl_type::sampler1D_type),
2167 _textureSize(gpu_shader4_integer, glsl_type::int_type, glsl_type::isampler1D_type),
2168 _textureSize(gpu_shader4_integer, glsl_type::int_type, glsl_type::usampler1D_type),
2169 NULL);
2170
2171 add_function("textureSize2D",
2172 _textureSize(gpu_shader4, glsl_type::ivec2_type, glsl_type::sampler2D_type),
2173 _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::isampler2D_type),
2174 _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::usampler2D_type),
2175 NULL);
2176
2177 add_function("textureSize3D",
2178 _textureSize(gpu_shader4, glsl_type::ivec3_type, glsl_type::sampler3D_type),
2179 _textureSize(gpu_shader4_integer, glsl_type::ivec3_type, glsl_type::isampler3D_type),
2180 _textureSize(gpu_shader4_integer, glsl_type::ivec3_type, glsl_type::usampler3D_type),
2181 NULL);
2182
2183 add_function("textureSizeCube",
2184 _textureSize(gpu_shader4, glsl_type::ivec2_type, glsl_type::samplerCube_type),
2185 _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::isamplerCube_type),
2186 _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::usamplerCube_type),
2187 NULL);
2188
2189 add_function("textureSize1DArray",
2190 _textureSize(gpu_shader4_array, glsl_type::ivec2_type, glsl_type::sampler1DArray_type),
2191 _textureSize(gpu_shader4_array_integer, glsl_type::ivec2_type, glsl_type::isampler1DArray_type),
2192 _textureSize(gpu_shader4_array_integer, glsl_type::ivec2_type, glsl_type::usampler1DArray_type),
2193 NULL);
2194
2195 add_function("textureSize2DArray",
2196 _textureSize(gpu_shader4_array, glsl_type::ivec3_type, glsl_type::sampler2DArray_type),
2197 _textureSize(gpu_shader4_array_integer, glsl_type::ivec3_type, glsl_type::isampler2DArray_type),
2198 _textureSize(gpu_shader4_array_integer, glsl_type::ivec3_type, glsl_type::usampler2DArray_type),
2199 NULL);
2200
2201 add_function("textureSize2DRect",
2202 _textureSize(gpu_shader4_rect, glsl_type::ivec2_type, glsl_type::sampler2DRect_type),
2203 _textureSize(gpu_shader4_rect_integer, glsl_type::ivec2_type, glsl_type::isampler2DRect_type),
2204 _textureSize(gpu_shader4_rect_integer, glsl_type::ivec2_type, glsl_type::usampler2DRect_type),
2205 NULL);
2206
2207 add_function("textureSizeBuffer",
2208 _textureSize(gpu_shader4_tbo, glsl_type::int_type, glsl_type::samplerBuffer_type),
2209 _textureSize(gpu_shader4_tbo_integer, glsl_type::int_type, glsl_type::isamplerBuffer_type),
2210 _textureSize(gpu_shader4_tbo_integer, glsl_type::int_type, glsl_type::usamplerBuffer_type),
2211 NULL);
2212
2213 add_function("textureSamples",
2214 _textureSamples(shader_samples, glsl_type::sampler2DMS_type),
2215 _textureSamples(shader_samples, glsl_type::isampler2DMS_type),
2216 _textureSamples(shader_samples, glsl_type::usampler2DMS_type),
2217
2218 _textureSamples(shader_samples, glsl_type::sampler2DMSArray_type),
2219 _textureSamples(shader_samples, glsl_type::isampler2DMSArray_type),
2220 _textureSamples(shader_samples, glsl_type::usampler2DMSArray_type),
2221 NULL);
2222
2223 add_function("texture",
2224 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),
2225 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
2226 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
2227
2228 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
2229 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
2230 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
2231
2232 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),
2233 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
2234 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
2235
2236 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
2237 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
2238 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
2239
2240 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
2241 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
2242 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
2243
2244 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
2245 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
2246 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
2247
2248 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
2249 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
2250 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
2251
2252 _texture(ir_tex, texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type),
2253 _texture(ir_tex, texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),
2254 _texture(ir_tex, texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),
2255
2256 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
2257 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
2258 /* samplerCubeArrayShadow is special; it has an extra parameter
2259 * for the shadow comparator since there is no vec5 type.
2260 */
2261 _textureCubeArrayShadow(ir_tex, texture_cube_map_array, glsl_type::samplerCubeArrayShadow_type),
2262
2263 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),
2264 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),
2265 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),
2266
2267 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),
2268
2269 _texture(ir_tex, texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec2_type),
2270
2271 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),
2272 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
2273 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
2274
2275 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
2276 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
2277 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
2278
2279 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),
2280 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
2281 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
2282
2283 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
2284 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
2285 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
2286
2287 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
2288 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
2289 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
2290
2291 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
2292 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
2293 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
2294
2295 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
2296 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
2297 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
2298
2299 _texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type),
2300 _texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),
2301 _texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),
2302
2303 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
2304 _texture(ir_tex, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
2305 _texture(ir_txb, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
2306
2307 _textureCubeArrayShadow(ir_tex, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type),
2308 _textureCubeArrayShadow(ir_txb, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type),
2309 NULL);
2310
2311 add_function("textureLod",
2312 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),
2313 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
2314 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
2315
2316 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
2317 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
2318 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
2319
2320 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),
2321 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
2322 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
2323
2324 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
2325 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
2326 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
2327
2328 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
2329 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
2330
2331 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
2332 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
2333 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
2334
2335 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
2336 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
2337 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
2338
2339 _texture(ir_txl, texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type),
2340 _texture(ir_txl, texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),
2341 _texture(ir_txl, texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),
2342
2343 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
2344 _texture(ir_txl, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
2345 _texture(ir_txl, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
2346 _textureCubeArrayShadow(ir_txl, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type),
2347 NULL);
2348
2349 add_function("textureOffset",
2350 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),
2351 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
2352 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
2353
2354 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2355 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2356 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2357
2358 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2359 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2360 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2361
2362 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
2363 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
2364 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
2365
2366 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2367
2368 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2369 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2370
2371 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2372 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2373 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2374
2375 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2376 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2377 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2378
2379 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2380 /* The next one was forgotten in GLSL 1.30 spec. It's from
2381 * EXT_gpu_shader4 originally. It was added in 4.30 with the
2382 * wrong syntax. This was corrected in 4.40. 4.30 indicates
2383 * that it was intended to be included previously, so allow it
2384 * in 1.30.
2385 */
2386 _texture(ir_tex, v130_desktop, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
2387
2388 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),
2389 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
2390 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
2391
2392 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2393 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2394 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2395
2396 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2397 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2398 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2399
2400 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2401 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2402
2403 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2404 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2405 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2406
2407 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2408 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2409 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2410
2411 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2412 _texture(ir_tex, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
2413 _texture(ir_txb, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
2414 NULL);
2415
2416 add_function("texture1DOffset",
2417 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),
2418 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
2419 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
2420 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),
2421 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
2422 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
2423 NULL);
2424
2425 add_function("texture2DOffset",
2426 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2427 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2428 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2429 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2430 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2431 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2432 NULL);
2433
2434 add_function("texture3DOffset",
2435 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2436 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2437 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2438 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2439 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2440 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2441 NULL);
2442
2443 add_function("texture2DRectOffset",
2444 _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
2445 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
2446 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
2447 NULL);
2448
2449 add_function("shadow2DRectOffset",
2450 _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2451 NULL);
2452
2453 add_function("shadow1DOffset",
2454 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2455 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2456 NULL);
2457
2458 add_function("shadow2DOffset",
2459 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2460 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2461 NULL);
2462
2463 add_function("texture1DArrayOffset",
2464 _texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2465 _texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2466 _texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2467 _texture(ir_txb, gpu_shader4_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2468 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2469 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2470 NULL);
2471
2472 add_function("texture2DArrayOffset",
2473 _texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2474 _texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2475 _texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2476 _texture(ir_txb, gpu_shader4_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2477 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2478 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2479 NULL);
2480
2481 add_function("shadow1DArrayOffset",
2482 _texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2483 _texture(ir_txb, gpu_shader4_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2484 NULL);
2485
2486 add_function("shadow2DArrayOffset",
2487 _texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
2488 NULL);
2489
2490 add_function("textureProj",
2491 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
2492 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
2493 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
2494 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
2495 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
2496 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
2497
2498 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
2499 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
2500 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
2501 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
2502 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
2503 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
2504
2505 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
2506 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
2507 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
2508
2509 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
2510 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
2511
2512 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
2513 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
2514 _texture(ir_tex, texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec3_type, TEX_PROJECT),
2515 _texture(ir_tex, texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec4_type, TEX_PROJECT),
2516
2517 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
2518 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
2519 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
2520 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
2521
2522 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),
2523
2524 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
2525 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
2526 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
2527 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
2528 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
2529 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
2530
2531 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
2532 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
2533 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
2534 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
2535 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
2536 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
2537
2538 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
2539 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
2540 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
2541
2542 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
2543 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
2544 NULL);
2545
2546 add_function("texelFetch",
2547 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::int_type),
2548 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type),
2549 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type),
2550
2551 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::ivec2_type),
2552 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type),
2553 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type),
2554
2555 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::ivec3_type),
2556 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type),
2557 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type),
2558
2559 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::ivec2_type),
2560 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type),
2561 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type),
2562
2563 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::ivec2_type),
2564 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type),
2565 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type),
2566
2567 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::ivec3_type),
2568 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type),
2569 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type),
2570
2571 _texelFetch(texture_buffer, glsl_type::vec4_type, glsl_type::samplerBuffer_type, glsl_type::int_type),
2572 _texelFetch(texture_buffer, glsl_type::ivec4_type, glsl_type::isamplerBuffer_type, glsl_type::int_type),
2573 _texelFetch(texture_buffer, glsl_type::uvec4_type, glsl_type::usamplerBuffer_type, glsl_type::int_type),
2574
2575 _texelFetch(texture_multisample, glsl_type::vec4_type, glsl_type::sampler2DMS_type, glsl_type::ivec2_type),
2576 _texelFetch(texture_multisample, glsl_type::ivec4_type, glsl_type::isampler2DMS_type, glsl_type::ivec2_type),
2577 _texelFetch(texture_multisample, glsl_type::uvec4_type, glsl_type::usampler2DMS_type, glsl_type::ivec2_type),
2578
2579 _texelFetch(texture_multisample_array, glsl_type::vec4_type, glsl_type::sampler2DMSArray_type, glsl_type::ivec3_type),
2580 _texelFetch(texture_multisample_array, glsl_type::ivec4_type, glsl_type::isampler2DMSArray_type, glsl_type::ivec3_type),
2581 _texelFetch(texture_multisample_array, glsl_type::uvec4_type, glsl_type::usampler2DMSArray_type, glsl_type::ivec3_type),
2582
2583 _texelFetch(texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::ivec2_type),
2584
2585 NULL);
2586
2587 add_function("texelFetch1D",
2588 _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::int_type),
2589 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type),
2590 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type),
2591 NULL);
2592
2593 add_function("texelFetch2D",
2594 _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::ivec2_type),
2595 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type),
2596 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type),
2597 NULL);
2598
2599 add_function("texelFetch3D",
2600 _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::ivec3_type),
2601 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type),
2602 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type),
2603 NULL);
2604
2605 add_function("texelFetch2DRect",
2606 _texelFetch(gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::ivec2_type),
2607 _texelFetch(gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type),
2608 _texelFetch(gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type),
2609 NULL);
2610
2611 add_function("texelFetch1DArray",
2612 _texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::ivec2_type),
2613 _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type),
2614 _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type),
2615 NULL);
2616
2617 add_function("texelFetch2DArray",
2618 _texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::ivec3_type),
2619 _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type),
2620 _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type),
2621 NULL);
2622
2623 add_function("texelFetchBuffer",
2624 _texelFetch(gpu_shader4_tbo, glsl_type::vec4_type, glsl_type::samplerBuffer_type, glsl_type::int_type),
2625 _texelFetch(gpu_shader4_tbo_integer, glsl_type::ivec4_type, glsl_type::isamplerBuffer_type, glsl_type::int_type),
2626 _texelFetch(gpu_shader4_tbo_integer, glsl_type::uvec4_type, glsl_type::usamplerBuffer_type, glsl_type::int_type),
2627 NULL);
2628
2629 add_function("texelFetchOffset",
2630 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::int_type, glsl_type::int_type),
2631 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type, glsl_type::int_type),
2632 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type, glsl_type::int_type),
2633
2634 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2635 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2636 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2637
2638 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
2639 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
2640 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
2641
2642 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2643 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2644 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2645
2646 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),
2647 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),
2648 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),
2649
2650 _texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),
2651 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),
2652 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),
2653
2654 NULL);
2655
2656 add_function("texelFetch1DOffset",
2657 _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::int_type, glsl_type::int_type),
2658 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type, glsl_type::int_type),
2659 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type, glsl_type::int_type),
2660 NULL);
2661
2662 add_function("texelFetch2DOffset",
2663 _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2664 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2665 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2666 NULL);
2667
2668 add_function("texelFetch3DOffset",
2669 _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
2670 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
2671 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
2672 NULL);
2673
2674 add_function("texelFetch2DRectOffset",
2675 _texelFetch(gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2676 _texelFetch(gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2677 _texelFetch(gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
2678 NULL);
2679
2680 add_function("texelFetch1DArrayOffset",
2681 _texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),
2682 _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),
2683 _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),
2684 NULL);
2685
2686 add_function("texelFetch2DArrayOffset",
2687 _texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),
2688 _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),
2689 _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),
2690 NULL);
2691
2692 add_function("textureProjOffset",
2693 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2694 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2695 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2696 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2697 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2698 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2699
2700 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2701 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2702 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2703 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2704 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2705 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2706
2707 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2708 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2709 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2710
2711 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2712 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2713
2714 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2715 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2716 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2717 _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2718 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2719 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2720
2721 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2722
2723 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2724 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2725 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2726 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2727 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2728 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2729
2730 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2731 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2732 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2733 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2734 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2735 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2736
2737 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2738 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2739 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2740
2741 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2742 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2743 NULL);
2744
2745 add_function("texture1DProjOffset",
2746 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2747 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2748 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2749 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2750 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2751 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2752 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2753 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2754 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2755 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2756 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2757 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2758 NULL);
2759
2760 add_function("texture2DProjOffset",
2761 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2762 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2763 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2764 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2765 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2766 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2767 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2768 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2769 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2770 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2771 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2772 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2773 NULL);
2774
2775 add_function("texture3DProjOffset",
2776 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2777 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2778 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2779 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2780 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2781 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2782 NULL);
2783
2784 add_function("shadow1DProjOffset",
2785 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2786 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2787 NULL);
2788
2789 add_function("shadow2DProjOffset",
2790 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2791 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2792 NULL);
2793
2794 add_function("texture2DRectProjOffset",
2795 _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2796 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2797 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2798 _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2799 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2800 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2801 NULL);
2802
2803 add_function("shadow2DRectProjOffset",
2804 _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2805 NULL);
2806
2807 add_function("textureLodOffset",
2808 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),
2809 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
2810 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
2811
2812 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2813 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2814 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2815
2816 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2817 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2818 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2819
2820 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2821 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2822
2823 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2824 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2825 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2826
2827 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2828 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2829 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2830
2831 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2832 _texture(ir_txl, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
2833 NULL);
2834
2835 add_function("texture1DLodOffset",
2836 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),
2837 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
2838 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
2839 NULL);
2840
2841 add_function("texture2DLodOffset",
2842 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2843 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2844 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
2845 NULL);
2846
2847 add_function("texture3DLodOffset",
2848 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2849 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2850 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
2851 NULL);
2852
2853 add_function("shadow1DLodOffset",
2854 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2855 NULL);
2856
2857 add_function("shadow2DLodOffset",
2858 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2859 NULL);
2860
2861 add_function("texture1DArrayLodOffset",
2862 _texture(ir_txl, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2863 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2864 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
2865 NULL);
2866
2867 add_function("texture2DArrayLodOffset",
2868 _texture(ir_txl, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2869 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2870 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
2871 NULL);
2872
2873 add_function("shadow1DArrayLodOffset",
2874 _texture(ir_txl, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
2875 NULL);
2876
2877 add_function("textureProjLod",
2878 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
2879 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
2880 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
2881 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
2882 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
2883 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
2884
2885 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
2886 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
2887 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
2888 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
2889 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
2890 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
2891
2892 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
2893 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
2894 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
2895
2896 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
2897 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
2898 NULL);
2899
2900 add_function("textureProjLodOffset",
2901 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2902 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2903 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2904 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2905 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2906 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2907
2908 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2909 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2910 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2911 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2912 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2913 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2914
2915 _texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2916 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2917 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2918
2919 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2920 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2921 NULL);
2922
2923 add_function("texture1DProjLodOffset",
2924 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2925 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2926 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
2927 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2928 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2929 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2930 NULL);
2931
2932 add_function("texture2DProjLodOffset",
2933 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2934 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2935 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
2936 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2937 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2938 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2939 NULL);
2940
2941 add_function("texture3DProjLodOffset",
2942 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2943 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2944 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2945 NULL);
2946
2947 add_function("shadow1DProjLodOffset",
2948 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2949 NULL);
2950
2951 add_function("shadow2DProjLodOffset",
2952 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
2953 NULL);
2954
2955 add_function("textureGrad",
2956 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),
2957 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
2958 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
2959
2960 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
2961 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
2962 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
2963
2964 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),
2965 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
2966 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
2967
2968 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
2969 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
2970 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
2971
2972 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),
2973 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),
2974 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),
2975
2976 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),
2977
2978 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
2979 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
2980 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
2981
2982 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
2983 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
2984 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
2985
2986 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
2987 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
2988 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
2989
2990 _texture(ir_txd, texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type),
2991 _texture(ir_txd, texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),
2992 _texture(ir_txd, texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),
2993
2994 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
2995 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
2996 NULL);
2997
2998 add_function("textureGradOffset",
2999 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),
3000 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
3001 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
3002
3003 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
3004 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
3005 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
3006
3007 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
3008 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
3009 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
3010
3011 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
3012 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
3013 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
3014
3015 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),
3016
3017 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
3018 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
3019
3020 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
3021 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
3022 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
3023
3024 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
3025 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
3026 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
3027
3028 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
3029 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
3030 NULL);
3031
3032 add_function("texture1DGradOffset",
3033 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),
3034 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
3035 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
3036 NULL);
3037
3038 add_function("texture2DGradOffset",
3039 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
3040 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
3041 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
3042 NULL);
3043
3044 add_function("texture3DGradOffset",
3045 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
3046 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
3047 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
3048 NULL);
3049
3050 add_function("texture2DRectGradOffset",
3051 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
3052 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
3053 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
3054 NULL);
3055
3056 add_function("shadow2DRectGradOffset",
3057 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),
3058 NULL);
3059
3060 add_function("shadow1DGradOffset",
3061 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
3062 NULL);
3063
3064 add_function("shadow2DGradOffset",
3065 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
3066 NULL);
3067
3068 add_function("texture1DArrayGradOffset",
3069 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
3070 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
3071 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
3072 NULL);
3073
3074 add_function("texture2DArrayGradOffset",
3075 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
3076 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
3077 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
3078 NULL);
3079
3080 add_function("shadow1DArrayGradOffset",
3081 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
3082 NULL);
3083
3084 add_function("shadow2DArrayGradOffset",
3085 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
3086 NULL);
3087
3088 add_function("textureProjGrad",
3089 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3090 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3091 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3092 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3093 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3094 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3095
3096 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3097 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3098 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3099 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3100 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3101 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3102
3103 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3104 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3105 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3106
3107 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
3108 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
3109 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
3110 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
3111 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
3112 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
3113
3114 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3115
3116 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3117 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3118 NULL);
3119
3120 add_function("textureProjGradOffset",
3121 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
3122 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
3123 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
3124 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3125 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3126 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3127
3128 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3129 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3130 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3131 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3132 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3133 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3134
3135 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3136 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3137 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3138
3139 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3140 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3141 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3142 _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3143 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3144 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3145
3146 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3147
3148 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3149 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3150 NULL);
3151
3152 add_function("texture1DProjGradOffset",
3153 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
3154 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
3155 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
3156 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3157 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3158 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3159 NULL);
3160
3161 add_function("texture2DProjGradOffset",
3162 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3163 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3164 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3165 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3166 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3167 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3168 NULL);
3169
3170 add_function("texture3DProjGradOffset",
3171 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3172 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3173 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3174 NULL);
3175
3176 add_function("texture2DRectProjGradOffset",
3177 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3178 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3179 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
3180 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3181 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3182 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3183 NULL);
3184
3185 add_function("shadow2DRectProjGradOffset",
3186 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3187 NULL);
3188
3189 add_function("shadow1DProjGradOffset",
3190 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3191 NULL);
3192
3193 add_function("shadow2DProjGradOffset",
3194 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
3195 NULL);
3196
3197 add_function("EmitVertex", _EmitVertex(), NULL);
3198 add_function("EndPrimitive", _EndPrimitive(), NULL);
3199 add_function("EmitStreamVertex",
3200 _EmitStreamVertex(gs_streams, glsl_type::uint_type),
3201 _EmitStreamVertex(gs_streams, glsl_type::int_type),
3202 NULL);
3203 add_function("EndStreamPrimitive",
3204 _EndStreamPrimitive(gs_streams, glsl_type::uint_type),
3205 _EndStreamPrimitive(gs_streams, glsl_type::int_type),
3206 NULL);
3207 add_function("barrier", _barrier(), NULL);
3208
3209 add_function("textureQueryLOD",
3210 _textureQueryLod(texture_query_lod, glsl_type::sampler1D_type, glsl_type::float_type),
3211 _textureQueryLod(texture_query_lod, glsl_type::isampler1D_type, glsl_type::float_type),
3212 _textureQueryLod(texture_query_lod, glsl_type::usampler1D_type, glsl_type::float_type),
3213
3214 _textureQueryLod(texture_query_lod, glsl_type::sampler2D_type, glsl_type::vec2_type),
3215 _textureQueryLod(texture_query_lod, glsl_type::isampler2D_type, glsl_type::vec2_type),
3216 _textureQueryLod(texture_query_lod, glsl_type::usampler2D_type, glsl_type::vec2_type),
3217
3218 _textureQueryLod(texture_query_lod, glsl_type::sampler3D_type, glsl_type::vec3_type),
3219 _textureQueryLod(texture_query_lod, glsl_type::isampler3D_type, glsl_type::vec3_type),
3220 _textureQueryLod(texture_query_lod, glsl_type::usampler3D_type, glsl_type::vec3_type),
3221
3222 _textureQueryLod(texture_query_lod, glsl_type::samplerCube_type, glsl_type::vec3_type),
3223 _textureQueryLod(texture_query_lod, glsl_type::isamplerCube_type, glsl_type::vec3_type),
3224 _textureQueryLod(texture_query_lod, glsl_type::usamplerCube_type, glsl_type::vec3_type),
3225
3226 _textureQueryLod(texture_query_lod, glsl_type::sampler1DArray_type, glsl_type::float_type),
3227 _textureQueryLod(texture_query_lod, glsl_type::isampler1DArray_type, glsl_type::float_type),
3228 _textureQueryLod(texture_query_lod, glsl_type::usampler1DArray_type, glsl_type::float_type),
3229
3230 _textureQueryLod(texture_query_lod, glsl_type::sampler2DArray_type, glsl_type::vec2_type),
3231 _textureQueryLod(texture_query_lod, glsl_type::isampler2DArray_type, glsl_type::vec2_type),
3232 _textureQueryLod(texture_query_lod, glsl_type::usampler2DArray_type, glsl_type::vec2_type),
3233
3234 _textureQueryLod(texture_query_lod, glsl_type::samplerCubeArray_type, glsl_type::vec3_type),
3235 _textureQueryLod(texture_query_lod, glsl_type::isamplerCubeArray_type, glsl_type::vec3_type),
3236 _textureQueryLod(texture_query_lod, glsl_type::usamplerCubeArray_type, glsl_type::vec3_type),
3237
3238 _textureQueryLod(texture_query_lod, glsl_type::sampler1DShadow_type, glsl_type::float_type),
3239 _textureQueryLod(texture_query_lod, glsl_type::sampler2DShadow_type, glsl_type::vec2_type),
3240 _textureQueryLod(texture_query_lod, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type),
3241 _textureQueryLod(texture_query_lod, glsl_type::sampler1DArrayShadow_type, glsl_type::float_type),
3242 _textureQueryLod(texture_query_lod, glsl_type::sampler2DArrayShadow_type, glsl_type::vec2_type),
3243 _textureQueryLod(texture_query_lod, glsl_type::samplerCubeArrayShadow_type, glsl_type::vec3_type),
3244 NULL);
3245
3246 add_function("textureQueryLod",
3247 _textureQueryLod(v400_derivatives_only, glsl_type::sampler1D_type, glsl_type::float_type),
3248 _textureQueryLod(v400_derivatives_only, glsl_type::isampler1D_type, glsl_type::float_type),
3249 _textureQueryLod(v400_derivatives_only, glsl_type::usampler1D_type, glsl_type::float_type),
3250
3251 _textureQueryLod(v400_derivatives_only, glsl_type::sampler2D_type, glsl_type::vec2_type),
3252 _textureQueryLod(v400_derivatives_only, glsl_type::isampler2D_type, glsl_type::vec2_type),
3253 _textureQueryLod(v400_derivatives_only, glsl_type::usampler2D_type, glsl_type::vec2_type),
3254
3255 _textureQueryLod(v400_derivatives_only, glsl_type::sampler3D_type, glsl_type::vec3_type),
3256 _textureQueryLod(v400_derivatives_only, glsl_type::isampler3D_type, glsl_type::vec3_type),
3257 _textureQueryLod(v400_derivatives_only, glsl_type::usampler3D_type, glsl_type::vec3_type),
3258
3259 _textureQueryLod(v400_derivatives_only, glsl_type::samplerCube_type, glsl_type::vec3_type),
3260 _textureQueryLod(v400_derivatives_only, glsl_type::isamplerCube_type, glsl_type::vec3_type),
3261 _textureQueryLod(v400_derivatives_only, glsl_type::usamplerCube_type, glsl_type::vec3_type),
3262
3263 _textureQueryLod(v400_derivatives_only, glsl_type::sampler1DArray_type, glsl_type::float_type),
3264 _textureQueryLod(v400_derivatives_only, glsl_type::isampler1DArray_type, glsl_type::float_type),
3265 _textureQueryLod(v400_derivatives_only, glsl_type::usampler1DArray_type, glsl_type::float_type),
3266
3267 _textureQueryLod(v400_derivatives_only, glsl_type::sampler2DArray_type, glsl_type::vec2_type),
3268 _textureQueryLod(v400_derivatives_only, glsl_type::isampler2DArray_type, glsl_type::vec2_type),
3269 _textureQueryLod(v400_derivatives_only, glsl_type::usampler2DArray_type, glsl_type::vec2_type),
3270
3271 _textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeArray_type, glsl_type::vec3_type),
3272 _textureQueryLod(v400_derivatives_only, glsl_type::isamplerCubeArray_type, glsl_type::vec3_type),
3273 _textureQueryLod(v400_derivatives_only, glsl_type::usamplerCubeArray_type, glsl_type::vec3_type),
3274
3275 _textureQueryLod(v400_derivatives_only, glsl_type::sampler1DShadow_type, glsl_type::float_type),
3276 _textureQueryLod(v400_derivatives_only, glsl_type::sampler2DShadow_type, glsl_type::vec2_type),
3277 _textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type),
3278 _textureQueryLod(v400_derivatives_only, glsl_type::sampler1DArrayShadow_type, glsl_type::float_type),
3279 _textureQueryLod(v400_derivatives_only, glsl_type::sampler2DArrayShadow_type, glsl_type::vec2_type),
3280 _textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeArrayShadow_type, glsl_type::vec3_type),
3281 NULL);
3282
3283 add_function("textureQueryLevels",
3284 _textureQueryLevels(texture_query_levels, glsl_type::sampler1D_type),
3285 _textureQueryLevels(texture_query_levels, glsl_type::sampler2D_type),
3286 _textureQueryLevels(texture_query_levels, glsl_type::sampler3D_type),
3287 _textureQueryLevels(texture_query_levels, glsl_type::samplerCube_type),
3288 _textureQueryLevels(texture_query_levels, glsl_type::sampler1DArray_type),
3289 _textureQueryLevels(texture_query_levels, glsl_type::sampler2DArray_type),
3290 _textureQueryLevels(texture_query_levels, glsl_type::samplerCubeArray_type),
3291 _textureQueryLevels(texture_query_levels, glsl_type::sampler1DShadow_type),
3292 _textureQueryLevels(texture_query_levels, glsl_type::sampler2DShadow_type),
3293 _textureQueryLevels(texture_query_levels, glsl_type::samplerCubeShadow_type),
3294 _textureQueryLevels(texture_query_levels, glsl_type::sampler1DArrayShadow_type),
3295 _textureQueryLevels(texture_query_levels, glsl_type::sampler2DArrayShadow_type),
3296 _textureQueryLevels(texture_query_levels, glsl_type::samplerCubeArrayShadow_type),
3297
3298 _textureQueryLevels(texture_query_levels, glsl_type::isampler1D_type),
3299 _textureQueryLevels(texture_query_levels, glsl_type::isampler2D_type),
3300 _textureQueryLevels(texture_query_levels, glsl_type::isampler3D_type),
3301 _textureQueryLevels(texture_query_levels, glsl_type::isamplerCube_type),
3302 _textureQueryLevels(texture_query_levels, glsl_type::isampler1DArray_type),
3303 _textureQueryLevels(texture_query_levels, glsl_type::isampler2DArray_type),
3304 _textureQueryLevels(texture_query_levels, glsl_type::isamplerCubeArray_type),
3305
3306 _textureQueryLevels(texture_query_levels, glsl_type::usampler1D_type),
3307 _textureQueryLevels(texture_query_levels, glsl_type::usampler2D_type),
3308 _textureQueryLevels(texture_query_levels, glsl_type::usampler3D_type),
3309 _textureQueryLevels(texture_query_levels, glsl_type::usamplerCube_type),
3310 _textureQueryLevels(texture_query_levels, glsl_type::usampler1DArray_type),
3311 _textureQueryLevels(texture_query_levels, glsl_type::usampler2DArray_type),
3312 _textureQueryLevels(texture_query_levels, glsl_type::usamplerCubeArray_type),
3313
3314 NULL);
3315
3316 add_function("textureSamplesIdenticalEXT",
3317 _textureSamplesIdentical(texture_samples_identical, glsl_type::sampler2DMS_type, glsl_type::ivec2_type),
3318 _textureSamplesIdentical(texture_samples_identical, glsl_type::isampler2DMS_type, glsl_type::ivec2_type),
3319 _textureSamplesIdentical(texture_samples_identical, glsl_type::usampler2DMS_type, glsl_type::ivec2_type),
3320
3321 _textureSamplesIdentical(texture_samples_identical_array, glsl_type::sampler2DMSArray_type, glsl_type::ivec3_type),
3322 _textureSamplesIdentical(texture_samples_identical_array, glsl_type::isampler2DMSArray_type, glsl_type::ivec3_type),
3323 _textureSamplesIdentical(texture_samples_identical_array, glsl_type::usampler2DMSArray_type, glsl_type::ivec3_type),
3324 NULL);
3325
3326 add_function("texture1D",
3327 _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),
3328 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),
3329 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
3330 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
3331 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
3332 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
3333 NULL);
3334
3335 add_function("texture1DArray",
3336 _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
3337 _texture(ir_txb, texture_array_derivs_only,glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
3338 _texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
3339 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
3340 _texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
3341 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
3342 NULL);
3343
3344 add_function("texture1DProj",
3345 _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3346 _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3347 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3348 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3349 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3350 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3351 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3352 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3353 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3354 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3355 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3356 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3357 NULL);
3358
3359 add_function("texture1DLod",
3360 _texture(ir_txl, tex1d_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),
3361 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
3362 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
3363 NULL);
3364
3365 add_function("texture1DArrayLod",
3366 _texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
3367 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
3368 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
3369 NULL);
3370
3371 add_function("texture1DProjLod",
3372 _texture(ir_txl, tex1d_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3373 _texture(ir_txl, tex1d_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3374 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3375 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3376 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3377 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3378 NULL);
3379
3380 add_function("texture2D",
3381 _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
3382 _texture(ir_txb, derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
3383 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
3384 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
3385 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
3386 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
3387 _texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec2_type),
3388 NULL);
3389
3390 add_function("texture2DArray",
3391 _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
3392 _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
3393 _texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
3394 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
3395 _texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
3396 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
3397 NULL);
3398
3399 add_function("texture2DProj",
3400 _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3401 _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3402 _texture(ir_txb, derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3403 _texture(ir_txb, derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3404 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3405 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3406 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3407 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3408 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3409 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3410 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3411 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3412 _texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec3_type, TEX_PROJECT),
3413 _texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec4_type, TEX_PROJECT),
3414 NULL);
3415
3416 add_function("texture2DLod",
3417 _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
3418 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
3419 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
3420 NULL);
3421
3422 add_function("texture2DArrayLod",
3423 _texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
3424 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
3425 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
3426 NULL);
3427
3428 add_function("texture2DProjLod",
3429 _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3430 _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3431 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3432 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3433 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3434 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3435 NULL);
3436
3437 add_function("texture3D",
3438 _texture(ir_tex, tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),
3439 _texture(ir_txb, derivatives_tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),
3440 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
3441 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
3442 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
3443 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
3444 NULL);
3445
3446 add_function("texture3DProj",
3447 _texture(ir_tex, tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3448 _texture(ir_txb, derivatives_tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3449 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3450 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3451 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3452 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3453 NULL);
3454
3455 add_function("texture3DLod",
3456 _texture(ir_txl, tex3d_lod, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),
3457 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
3458 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
3459 NULL);
3460
3461 add_function("texture3DProjLod",
3462 _texture(ir_txl, tex3d_lod, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3463 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3464 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3465 NULL);
3466
3467 add_function("textureCube",
3468 _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
3469 _texture(ir_txb, derivatives_only, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
3470 _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
3471 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
3472 _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
3473 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
3474 NULL);
3475
3476 add_function("textureCubeLod",
3477 _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
3478 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
3479 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
3480 NULL);
3481
3482 add_function("texture2DRect",
3483 _texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),
3484 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),
3485 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),
3486 NULL);
3487
3488 add_function("texture2DRectProj",
3489 _texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
3490 _texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
3491 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
3492 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
3493 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
3494 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
3495 NULL);
3496
3497 add_function("shadow1D",
3498 _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
3499 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
3500 NULL);
3501
3502 add_function("shadow1DArray",
3503 _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
3504 _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
3505 NULL);
3506
3507 add_function("shadow2D",
3508 _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
3509 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
3510 NULL);
3511
3512 add_function("shadow2DArray",
3513 _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
3514 _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
3515 NULL);
3516
3517 add_function("shadow1DProj",
3518 _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3519 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3520 NULL);
3521
3522 add_function("shadow2DArray",
3523 _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
3524 _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
3525 NULL);
3526
3527 add_function("shadowCube",
3528 _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
3529 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
3530 NULL);
3531
3532 add_function("shadow2DProj",
3533 _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3534 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3535 NULL);
3536
3537 add_function("shadow1DLod",
3538 _texture(ir_txl, v110_lod, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
3539 NULL);
3540
3541 add_function("shadow2DLod",
3542 _texture(ir_txl, v110_lod, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
3543 NULL);
3544
3545 add_function("shadow1DArrayLod",
3546 _texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
3547 NULL);
3548
3549 add_function("shadow1DProjLod",
3550 _texture(ir_txl, v110_lod, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3551 NULL);
3552
3553 add_function("shadow2DProjLod",
3554 _texture(ir_txl, v110_lod, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3555 NULL);
3556
3557 add_function("shadow2DRect",
3558 _texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),
3559 NULL);
3560
3561 add_function("shadow2DRectProj",
3562 _texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3563 NULL);
3564
3565 add_function("texture1DGradARB",
3566 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),
3567 NULL);
3568
3569 add_function("texture1DProjGradARB",
3570 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3571 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3572 NULL);
3573
3574 add_function("texture2DGradARB",
3575 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
3576 NULL);
3577
3578 add_function("texture2DProjGradARB",
3579 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3580 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3581 NULL);
3582
3583 add_function("texture3DGradARB",
3584 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),
3585 NULL);
3586
3587 add_function("texture3DProjGradARB",
3588 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3589 NULL);
3590
3591 add_function("textureCubeGradARB",
3592 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
3593 NULL);
3594
3595 add_function("shadow1DGradARB",
3596 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
3597 NULL);
3598
3599 add_function("shadow1DProjGradARB",
3600 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3601 NULL);
3602
3603 add_function("shadow2DGradARB",
3604 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
3605 NULL);
3606
3607 add_function("shadow2DProjGradARB",
3608 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3609 NULL);
3610
3611 add_function("texture2DRectGradARB",
3612 _texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),
3613 NULL);
3614
3615 add_function("texture2DRectProjGradARB",
3616 _texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
3617 _texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
3618 NULL);
3619
3620 add_function("shadow2DRectGradARB",
3621 _texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),
3622 NULL);
3623
3624 add_function("shadow2DRectProjGradARB",
3625 _texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3626 NULL);
3627
3628 add_function("texture4",
3629 _texture(ir_tg4, texture_texture4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
3630 NULL);
3631
3632 add_function("texture1DGrad",
3633 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),
3634 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
3635 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
3636 NULL);
3637
3638 add_function("texture1DProjGrad",
3639 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3640 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3641 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3642 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3643 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
3644 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
3645 NULL);
3646
3647 add_function("texture1DArrayGrad",
3648 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
3649 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
3650 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
3651 NULL);
3652
3653 add_function("texture2DGrad",
3654 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
3655 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
3656 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
3657 NULL);
3658
3659 add_function("texture2DProjGrad",
3660 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3661 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3662 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3663 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3664 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
3665 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
3666 NULL);
3667
3668 add_function("texture2DArrayGrad",
3669 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
3670 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
3671 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
3672 NULL);
3673
3674 add_function("texture3DGrad",
3675 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),
3676 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
3677 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
3678 NULL);
3679
3680 add_function("texture3DProjGrad",
3681 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3682 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3683 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
3684 NULL);
3685
3686 add_function("textureCubeGrad",
3687 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
3688 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
3689 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
3690 NULL);
3691
3692 add_function("shadow1DGrad",
3693 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
3694 NULL);
3695
3696 add_function("shadow1DProjGrad",
3697 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3698 NULL);
3699
3700 add_function("shadow1DArrayGrad",
3701 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
3702 NULL);
3703
3704 add_function("shadow2DGrad",
3705 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
3706 NULL);
3707
3708 add_function("shadow2DProjGrad",
3709 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3710 NULL);
3711
3712 add_function("shadow2DArrayGrad",
3713 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
3714 NULL);
3715
3716 add_function("texture2DRectGrad",
3717 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),
3718 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),
3719 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),
3720 NULL);
3721
3722 add_function("texture2DRectProjGrad",
3723 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
3724 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
3725 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
3726 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
3727 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
3728 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
3729 NULL);
3730
3731 add_function("shadow2DRectGrad",
3732 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),
3733 NULL);
3734
3735 add_function("shadow2DRectProjGrad",
3736 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),
3737 NULL);
3738
3739 add_function("shadowCubeGrad",
3740 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
3741 NULL);
3742
3743 add_function("textureGather",
3744 _texture(ir_tg4, texture_gather_or_es31, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
3745 _texture(ir_tg4, texture_gather_or_es31, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
3746 _texture(ir_tg4, texture_gather_or_es31, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
3747
3748 _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),
3749 _texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),
3750 _texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),
3751
3752 _texture(ir_tg4, texture_gather_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
3753 _texture(ir_tg4, texture_gather_or_es31, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
3754 _texture(ir_tg4, texture_gather_or_es31, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
3755
3756 _texture(ir_tg4, texture_gather_or_es31, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
3757 _texture(ir_tg4, texture_gather_or_es31, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
3758 _texture(ir_tg4, texture_gather_or_es31, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
3759
3760 _texture(ir_tg4, texture_gather_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type),
3761 _texture(ir_tg4, texture_gather_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),
3762 _texture(ir_tg4, texture_gather_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),
3763
3764 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),
3765 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),
3766 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),
3767
3768 _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_COMPONENT),
3769 _texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_COMPONENT),
3770 _texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_COMPONENT),
3771
3772 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),
3773 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),
3774 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),
3775
3776 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),
3777 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),
3778 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),
3779
3780 _texture(ir_tg4, gpu_shader5_or_OES_texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type, TEX_COMPONENT),
3781 _texture(ir_tg4, gpu_shader5_or_OES_texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type, TEX_COMPONENT),
3782 _texture(ir_tg4, gpu_shader5_or_OES_texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type, TEX_COMPONENT),
3783
3784 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type),
3785 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type),
3786 _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type),
3787 _texture(ir_tg4, gpu_shader5_or_OES_texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArrayShadow_type, glsl_type::vec4_type),
3788 _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec2_type),
3789 NULL);
3790
3791 add_function("textureGatherOffset",
3792 _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
3793 _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
3794 _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
3795
3796 _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
3797 _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
3798 _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
3799
3800 _texture(ir_tg4, es31_not_gs5, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET | TEX_COMPONENT),
3801 _texture(ir_tg4, es31_not_gs5, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET | TEX_COMPONENT),
3802 _texture(ir_tg4, es31_not_gs5, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET | TEX_COMPONENT),
3803
3804 _texture(ir_tg4, es31_not_gs5, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET | TEX_COMPONENT),
3805 _texture(ir_tg4, es31_not_gs5, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET | TEX_COMPONENT),
3806 _texture(ir_tg4, es31_not_gs5, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET | TEX_COMPONENT),
3807
3808 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
3809 _texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
3810 _texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
3811
3812 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST),
3813 _texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST),
3814 _texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST),
3815
3816 _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
3817 _texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
3818 _texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
3819
3820 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),
3821 _texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),
3822 _texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),
3823
3824 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),
3825 _texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),
3826 _texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),
3827
3828 _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),
3829 _texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),
3830 _texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),
3831
3832 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
3833 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST),
3834 _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
3835
3836 _texture(ir_tg4, es31_not_gs5, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type, TEX_OFFSET),
3837 _texture(ir_tg4, es31_not_gs5, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
3838 NULL);
3839
3840 add_function("textureGatherOffsets",
3841 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),
3842 _texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),
3843 _texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),
3844
3845 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),
3846 _texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),
3847 _texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),
3848
3849 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY),
3850 _texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY),
3851 _texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY),
3852
3853 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),
3854 _texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),
3855 _texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),
3856
3857 _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),
3858 _texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),
3859 _texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),
3860
3861 _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),
3862 _texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),
3863 _texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),
3864
3865 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),
3866 _texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY),
3867 _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),
3868 NULL);
3869
3870 F(dFdx)
3871 F(dFdy)
3872 F(fwidth)
3873 F(dFdxCoarse)
3874 F(dFdyCoarse)
3875 F(fwidthCoarse)
3876 F(dFdxFine)
3877 F(dFdyFine)
3878 F(fwidthFine)
3879 F(noise1)
3880 F(noise2)
3881 F(noise3)
3882 F(noise4)
3883
3884 IU(bitfieldExtract)
3885 IU(bitfieldInsert)
3886 IU(bitfieldReverse)
3887 IU(bitCount)
3888 IU(findLSB)
3889 IU(findMSB)
3890 FDGS5(fma)
3891
3892 add_function("ldexp",
3893 _ldexp(glsl_type::float_type, glsl_type::int_type),
3894 _ldexp(glsl_type::vec2_type, glsl_type::ivec2_type),
3895 _ldexp(glsl_type::vec3_type, glsl_type::ivec3_type),
3896 _ldexp(glsl_type::vec4_type, glsl_type::ivec4_type),
3897 _ldexp(glsl_type::double_type, glsl_type::int_type),
3898 _ldexp(glsl_type::dvec2_type, glsl_type::ivec2_type),
3899 _ldexp(glsl_type::dvec3_type, glsl_type::ivec3_type),
3900 _ldexp(glsl_type::dvec4_type, glsl_type::ivec4_type),
3901 NULL);
3902
3903 add_function("frexp",
3904 _frexp(glsl_type::float_type, glsl_type::int_type),
3905 _frexp(glsl_type::vec2_type, glsl_type::ivec2_type),
3906 _frexp(glsl_type::vec3_type, glsl_type::ivec3_type),
3907 _frexp(glsl_type::vec4_type, glsl_type::ivec4_type),
3908 _dfrexp(glsl_type::double_type, glsl_type::int_type),
3909 _dfrexp(glsl_type::dvec2_type, glsl_type::ivec2_type),
3910 _dfrexp(glsl_type::dvec3_type, glsl_type::ivec3_type),
3911 _dfrexp(glsl_type::dvec4_type, glsl_type::ivec4_type),
3912 NULL);
3913 add_function("uaddCarry",
3914 _uaddCarry(glsl_type::uint_type),
3915 _uaddCarry(glsl_type::uvec2_type),
3916 _uaddCarry(glsl_type::uvec3_type),
3917 _uaddCarry(glsl_type::uvec4_type),
3918 NULL);
3919 add_function("usubBorrow",
3920 _usubBorrow(glsl_type::uint_type),
3921 _usubBorrow(glsl_type::uvec2_type),
3922 _usubBorrow(glsl_type::uvec3_type),
3923 _usubBorrow(glsl_type::uvec4_type),
3924 NULL);
3925 add_function("imulExtended",
3926 _mulExtended(glsl_type::int_type),
3927 _mulExtended(glsl_type::ivec2_type),
3928 _mulExtended(glsl_type::ivec3_type),
3929 _mulExtended(glsl_type::ivec4_type),
3930 NULL);
3931 add_function("umulExtended",
3932 _mulExtended(glsl_type::uint_type),
3933 _mulExtended(glsl_type::uvec2_type),
3934 _mulExtended(glsl_type::uvec3_type),
3935 _mulExtended(glsl_type::uvec4_type),
3936 NULL);
3937 add_function("interpolateAtCentroid",
3938 _interpolateAtCentroid(glsl_type::float_type),
3939 _interpolateAtCentroid(glsl_type::vec2_type),
3940 _interpolateAtCentroid(glsl_type::vec3_type),
3941 _interpolateAtCentroid(glsl_type::vec4_type),
3942 NULL);
3943 add_function("interpolateAtOffset",
3944 _interpolateAtOffset(glsl_type::float_type),
3945 _interpolateAtOffset(glsl_type::vec2_type),
3946 _interpolateAtOffset(glsl_type::vec3_type),
3947 _interpolateAtOffset(glsl_type::vec4_type),
3948 NULL);
3949 add_function("interpolateAtSample",
3950 _interpolateAtSample(glsl_type::float_type),
3951 _interpolateAtSample(glsl_type::vec2_type),
3952 _interpolateAtSample(glsl_type::vec3_type),
3953 _interpolateAtSample(glsl_type::vec4_type),
3954 NULL);
3955
3956 add_function("atomicCounter",
3957 _atomic_counter_op("__intrinsic_atomic_read",
3958 shader_atomic_counters),
3959 NULL);
3960 add_function("atomicCounterIncrement",
3961 _atomic_counter_op("__intrinsic_atomic_increment",
3962 shader_atomic_counters),
3963 NULL);
3964 add_function("atomicCounterDecrement",
3965 _atomic_counter_op("__intrinsic_atomic_predecrement",
3966 shader_atomic_counters),
3967 NULL);
3968
3969 add_function("atomicCounterAddARB",
3970 _atomic_counter_op1("__intrinsic_atomic_add",
3971 shader_atomic_counter_ops),
3972 NULL);
3973 add_function("atomicCounterSubtractARB",
3974 _atomic_counter_op1("__intrinsic_atomic_sub",
3975 shader_atomic_counter_ops),
3976 NULL);
3977 add_function("atomicCounterMinARB",
3978 _atomic_counter_op1("__intrinsic_atomic_min",
3979 shader_atomic_counter_ops),
3980 NULL);
3981 add_function("atomicCounterMaxARB",
3982 _atomic_counter_op1("__intrinsic_atomic_max",
3983 shader_atomic_counter_ops),
3984 NULL);
3985 add_function("atomicCounterAndARB",
3986 _atomic_counter_op1("__intrinsic_atomic_and",
3987 shader_atomic_counter_ops),
3988 NULL);
3989 add_function("atomicCounterOrARB",
3990 _atomic_counter_op1("__intrinsic_atomic_or",
3991 shader_atomic_counter_ops),
3992 NULL);
3993 add_function("atomicCounterXorARB",
3994 _atomic_counter_op1("__intrinsic_atomic_xor",
3995 shader_atomic_counter_ops),
3996 NULL);
3997 add_function("atomicCounterExchangeARB",
3998 _atomic_counter_op1("__intrinsic_atomic_exchange",
3999 shader_atomic_counter_ops),
4000 NULL);
4001 add_function("atomicCounterCompSwapARB",
4002 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
4003 shader_atomic_counter_ops),
4004 NULL);
4005
4006 add_function("atomicCounterAdd",
4007 _atomic_counter_op1("__intrinsic_atomic_add",
4008 v460_desktop),
4009 NULL);
4010 add_function("atomicCounterSubtract",
4011 _atomic_counter_op1("__intrinsic_atomic_sub",
4012 v460_desktop),
4013 NULL);
4014 add_function("atomicCounterMin",
4015 _atomic_counter_op1("__intrinsic_atomic_min",
4016 v460_desktop),
4017 NULL);
4018 add_function("atomicCounterMax",
4019 _atomic_counter_op1("__intrinsic_atomic_max",
4020 v460_desktop),
4021 NULL);
4022 add_function("atomicCounterAnd",
4023 _atomic_counter_op1("__intrinsic_atomic_and",
4024 v460_desktop),
4025 NULL);
4026 add_function("atomicCounterOr",
4027 _atomic_counter_op1("__intrinsic_atomic_or",
4028 v460_desktop),
4029 NULL);
4030 add_function("atomicCounterXor",
4031 _atomic_counter_op1("__intrinsic_atomic_xor",
4032 v460_desktop),
4033 NULL);
4034 add_function("atomicCounterExchange",
4035 _atomic_counter_op1("__intrinsic_atomic_exchange",
4036 v460_desktop),
4037 NULL);
4038 add_function("atomicCounterCompSwap",
4039 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
4040 v460_desktop),
4041 NULL);
4042
4043 add_function("atomicAdd",
4044 _atomic_op2("__intrinsic_atomic_add",
4045 buffer_atomics_supported,
4046 glsl_type::uint_type),
4047 _atomic_op2("__intrinsic_atomic_add",
4048 buffer_atomics_supported,
4049 glsl_type::int_type),
4050 _atomic_op2("__intrinsic_atomic_add",
4051 shader_atomic_float_add,
4052 glsl_type::float_type),
4053 NULL);
4054 add_function("atomicMin",
4055 _atomic_op2("__intrinsic_atomic_min",
4056 buffer_atomics_supported,
4057 glsl_type::uint_type),
4058 _atomic_op2("__intrinsic_atomic_min",
4059 buffer_atomics_supported,
4060 glsl_type::int_type),
4061 _atomic_op2("__intrinsic_atomic_min",
4062 shader_atomic_float_minmax,
4063 glsl_type::float_type),
4064 NULL);
4065 add_function("atomicMax",
4066 _atomic_op2("__intrinsic_atomic_max",
4067 buffer_atomics_supported,
4068 glsl_type::uint_type),
4069 _atomic_op2("__intrinsic_atomic_max",
4070 buffer_atomics_supported,
4071 glsl_type::int_type),
4072 _atomic_op2("__intrinsic_atomic_max",
4073 shader_atomic_float_minmax,
4074 glsl_type::float_type),
4075 NULL);
4076 add_function("atomicAnd",
4077 _atomic_op2("__intrinsic_atomic_and",
4078 buffer_atomics_supported,
4079 glsl_type::uint_type),
4080 _atomic_op2("__intrinsic_atomic_and",
4081 buffer_atomics_supported,
4082 glsl_type::int_type),
4083 NULL);
4084 add_function("atomicOr",
4085 _atomic_op2("__intrinsic_atomic_or",
4086 buffer_atomics_supported,
4087 glsl_type::uint_type),
4088 _atomic_op2("__intrinsic_atomic_or",
4089 buffer_atomics_supported,
4090 glsl_type::int_type),
4091 NULL);
4092 add_function("atomicXor",
4093 _atomic_op2("__intrinsic_atomic_xor",
4094 buffer_atomics_supported,
4095 glsl_type::uint_type),
4096 _atomic_op2("__intrinsic_atomic_xor",
4097 buffer_atomics_supported,
4098 glsl_type::int_type),
4099 NULL);
4100 add_function("atomicExchange",
4101 _atomic_op2("__intrinsic_atomic_exchange",
4102 buffer_atomics_supported,
4103 glsl_type::uint_type),
4104 _atomic_op2("__intrinsic_atomic_exchange",
4105 buffer_atomics_supported,
4106 glsl_type::int_type),
4107 _atomic_op2("__intrinsic_atomic_exchange",
4108 shader_atomic_float_exchange,
4109 glsl_type::float_type),
4110 NULL);
4111 add_function("atomicCompSwap",
4112 _atomic_op3("__intrinsic_atomic_comp_swap",
4113 buffer_atomics_supported,
4114 glsl_type::uint_type),
4115 _atomic_op3("__intrinsic_atomic_comp_swap",
4116 buffer_atomics_supported,
4117 glsl_type::int_type),
4118 _atomic_op3("__intrinsic_atomic_comp_swap",
4119 shader_atomic_float_minmax,
4120 glsl_type::float_type),
4121 NULL);
4122
4123 add_function("min3",
4124 _min3(glsl_type::float_type),
4125 _min3(glsl_type::vec2_type),
4126 _min3(glsl_type::vec3_type),
4127 _min3(glsl_type::vec4_type),
4128
4129 _min3(glsl_type::int_type),
4130 _min3(glsl_type::ivec2_type),
4131 _min3(glsl_type::ivec3_type),
4132 _min3(glsl_type::ivec4_type),
4133
4134 _min3(glsl_type::uint_type),
4135 _min3(glsl_type::uvec2_type),
4136 _min3(glsl_type::uvec3_type),
4137 _min3(glsl_type::uvec4_type),
4138 NULL);
4139
4140 add_function("max3",
4141 _max3(glsl_type::float_type),
4142 _max3(glsl_type::vec2_type),
4143 _max3(glsl_type::vec3_type),
4144 _max3(glsl_type::vec4_type),
4145
4146 _max3(glsl_type::int_type),
4147 _max3(glsl_type::ivec2_type),
4148 _max3(glsl_type::ivec3_type),
4149 _max3(glsl_type::ivec4_type),
4150
4151 _max3(glsl_type::uint_type),
4152 _max3(glsl_type::uvec2_type),
4153 _max3(glsl_type::uvec3_type),
4154 _max3(glsl_type::uvec4_type),
4155 NULL);
4156
4157 add_function("mid3",
4158 _mid3(glsl_type::float_type),
4159 _mid3(glsl_type::vec2_type),
4160 _mid3(glsl_type::vec3_type),
4161 _mid3(glsl_type::vec4_type),
4162
4163 _mid3(glsl_type::int_type),
4164 _mid3(glsl_type::ivec2_type),
4165 _mid3(glsl_type::ivec3_type),
4166 _mid3(glsl_type::ivec4_type),
4167
4168 _mid3(glsl_type::uint_type),
4169 _mid3(glsl_type::uvec2_type),
4170 _mid3(glsl_type::uvec3_type),
4171 _mid3(glsl_type::uvec4_type),
4172 NULL);
4173
4174 add_image_functions(true);
4175
4176 add_function("memoryBarrier",
4177 _memory_barrier("__intrinsic_memory_barrier",
4178 shader_image_load_store),
4179 NULL);
4180 add_function("groupMemoryBarrier",
4181 _memory_barrier("__intrinsic_group_memory_barrier",
4182 compute_shader),
4183 NULL);
4184 add_function("memoryBarrierAtomicCounter",
4185 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
4186 compute_shader_supported),
4187 NULL);
4188 add_function("memoryBarrierBuffer",
4189 _memory_barrier("__intrinsic_memory_barrier_buffer",
4190 compute_shader_supported),
4191 NULL);
4192 add_function("memoryBarrierImage",
4193 _memory_barrier("__intrinsic_memory_barrier_image",
4194 compute_shader_supported),
4195 NULL);
4196 add_function("memoryBarrierShared",
4197 _memory_barrier("__intrinsic_memory_barrier_shared",
4198 compute_shader),
4199 NULL);
4200
4201 add_function("ballotARB", _ballot(), NULL);
4202
4203 add_function("readInvocationARB",
4204 _read_invocation(glsl_type::float_type),
4205 _read_invocation(glsl_type::vec2_type),
4206 _read_invocation(glsl_type::vec3_type),
4207 _read_invocation(glsl_type::vec4_type),
4208
4209 _read_invocation(glsl_type::int_type),
4210 _read_invocation(glsl_type::ivec2_type),
4211 _read_invocation(glsl_type::ivec3_type),
4212 _read_invocation(glsl_type::ivec4_type),
4213
4214 _read_invocation(glsl_type::uint_type),
4215 _read_invocation(glsl_type::uvec2_type),
4216 _read_invocation(glsl_type::uvec3_type),
4217 _read_invocation(glsl_type::uvec4_type),
4218 NULL);
4219
4220 add_function("readFirstInvocationARB",
4221 _read_first_invocation(glsl_type::float_type),
4222 _read_first_invocation(glsl_type::vec2_type),
4223 _read_first_invocation(glsl_type::vec3_type),
4224 _read_first_invocation(glsl_type::vec4_type),
4225
4226 _read_first_invocation(glsl_type::int_type),
4227 _read_first_invocation(glsl_type::ivec2_type),
4228 _read_first_invocation(glsl_type::ivec3_type),
4229 _read_first_invocation(glsl_type::ivec4_type),
4230
4231 _read_first_invocation(glsl_type::uint_type),
4232 _read_first_invocation(glsl_type::uvec2_type),
4233 _read_first_invocation(glsl_type::uvec3_type),
4234 _read_first_invocation(glsl_type::uvec4_type),
4235 NULL);
4236
4237 add_function("clock2x32ARB",
4238 _shader_clock(shader_clock,
4239 glsl_type::uvec2_type),
4240 NULL);
4241
4242 add_function("clockARB",
4243 _shader_clock(shader_clock_int64,
4244 glsl_type::uint64_t_type),
4245 NULL);
4246
4247 add_function("beginInvocationInterlockARB",
4248 _invocation_interlock(
4249 "__intrinsic_begin_invocation_interlock",
4250 supports_arb_fragment_shader_interlock),
4251 NULL);
4252
4253 add_function("endInvocationInterlockARB",
4254 _invocation_interlock(
4255 "__intrinsic_end_invocation_interlock",
4256 supports_arb_fragment_shader_interlock),
4257 NULL);
4258
4259 add_function("beginInvocationInterlockNV",
4260 _invocation_interlock(
4261 "__intrinsic_begin_invocation_interlock",
4262 supports_nv_fragment_shader_interlock),
4263 NULL);
4264
4265 add_function("endInvocationInterlockNV",
4266 _invocation_interlock(
4267 "__intrinsic_end_invocation_interlock",
4268 supports_nv_fragment_shader_interlock),
4269 NULL);
4270
4271 add_function("anyInvocationARB",
4272 _vote("__intrinsic_vote_any", vote),
4273 NULL);
4274
4275 add_function("allInvocationsARB",
4276 _vote("__intrinsic_vote_all", vote),
4277 NULL);
4278
4279 add_function("allInvocationsEqualARB",
4280 _vote("__intrinsic_vote_eq", vote),
4281 NULL);
4282
4283 add_function("anyInvocationEXT",
4284 _vote("__intrinsic_vote_any", vote_ext),
4285 NULL);
4286
4287 add_function("allInvocationsEXT",
4288 _vote("__intrinsic_vote_all", vote_ext),
4289 NULL);
4290
4291 add_function("allInvocationsEqualEXT",
4292 _vote("__intrinsic_vote_eq", vote_ext),
4293 NULL);
4294
4295 add_function("anyInvocation",
4296 _vote("__intrinsic_vote_any", v460_desktop),
4297 NULL);
4298
4299 add_function("allInvocations",
4300 _vote("__intrinsic_vote_all", v460_desktop),
4301 NULL);
4302
4303 add_function("allInvocationsEqual",
4304 _vote("__intrinsic_vote_eq", v460_desktop),
4305 NULL);
4306
4307 add_function("helperInvocationEXT", _helper_invocation(), NULL);
4308
4309 add_function("__builtin_idiv64",
4310 generate_ir::idiv64(mem_ctx, integer_functions_supported),
4311 NULL);
4312
4313 add_function("__builtin_imod64",
4314 generate_ir::imod64(mem_ctx, integer_functions_supported),
4315 NULL);
4316
4317 add_function("__builtin_sign64",
4318 generate_ir::sign64(mem_ctx, integer_functions_supported),
4319 NULL);
4320
4321 add_function("__builtin_udiv64",
4322 generate_ir::udiv64(mem_ctx, integer_functions_supported),
4323 NULL);
4324
4325 add_function("__builtin_umod64",
4326 generate_ir::umod64(mem_ctx, integer_functions_supported),
4327 NULL);
4328
4329 add_function("__builtin_umul64",
4330 generate_ir::umul64(mem_ctx, integer_functions_supported),
4331 NULL);
4332
4333 add_function("countLeadingZeros",
4334 _countLeadingZeros(shader_integer_functions2,
4335 glsl_type::uint_type),
4336 _countLeadingZeros(shader_integer_functions2,
4337 glsl_type::uvec2_type),
4338 _countLeadingZeros(shader_integer_functions2,
4339 glsl_type::uvec3_type),
4340 _countLeadingZeros(shader_integer_functions2,
4341 glsl_type::uvec4_type),
4342 NULL);
4343
4344 add_function("countTrailingZeros",
4345 _countTrailingZeros(shader_integer_functions2,
4346 glsl_type::uint_type),
4347 _countTrailingZeros(shader_integer_functions2,
4348 glsl_type::uvec2_type),
4349 _countTrailingZeros(shader_integer_functions2,
4350 glsl_type::uvec3_type),
4351 _countTrailingZeros(shader_integer_functions2,
4352 glsl_type::uvec4_type),
4353 NULL);
4354
4355 add_function("absoluteDifference",
4356 _absoluteDifference(shader_integer_functions2,
4357 glsl_type::int_type),
4358 _absoluteDifference(shader_integer_functions2,
4359 glsl_type::ivec2_type),
4360 _absoluteDifference(shader_integer_functions2,
4361 glsl_type::ivec3_type),
4362 _absoluteDifference(shader_integer_functions2,
4363 glsl_type::ivec4_type),
4364 _absoluteDifference(shader_integer_functions2,
4365 glsl_type::uint_type),
4366 _absoluteDifference(shader_integer_functions2,
4367 glsl_type::uvec2_type),
4368 _absoluteDifference(shader_integer_functions2,
4369 glsl_type::uvec3_type),
4370 _absoluteDifference(shader_integer_functions2,
4371 glsl_type::uvec4_type),
4372
4373 _absoluteDifference(shader_integer_functions2_int64,
4374 glsl_type::int64_t_type),
4375 _absoluteDifference(shader_integer_functions2_int64,
4376 glsl_type::i64vec2_type),
4377 _absoluteDifference(shader_integer_functions2_int64,
4378 glsl_type::i64vec3_type),
4379 _absoluteDifference(shader_integer_functions2_int64,
4380 glsl_type::i64vec4_type),
4381 _absoluteDifference(shader_integer_functions2_int64,
4382 glsl_type::uint64_t_type),
4383 _absoluteDifference(shader_integer_functions2_int64,
4384 glsl_type::u64vec2_type),
4385 _absoluteDifference(shader_integer_functions2_int64,
4386 glsl_type::u64vec3_type),
4387 _absoluteDifference(shader_integer_functions2_int64,
4388 glsl_type::u64vec4_type),
4389 NULL);
4390
4391 add_function("addSaturate",
4392 _addSaturate(shader_integer_functions2,
4393 glsl_type::int_type),
4394 _addSaturate(shader_integer_functions2,
4395 glsl_type::ivec2_type),
4396 _addSaturate(shader_integer_functions2,
4397 glsl_type::ivec3_type),
4398 _addSaturate(shader_integer_functions2,
4399 glsl_type::ivec4_type),
4400 _addSaturate(shader_integer_functions2,
4401 glsl_type::uint_type),
4402 _addSaturate(shader_integer_functions2,
4403 glsl_type::uvec2_type),
4404 _addSaturate(shader_integer_functions2,
4405 glsl_type::uvec3_type),
4406 _addSaturate(shader_integer_functions2,
4407 glsl_type::uvec4_type),
4408
4409 _addSaturate(shader_integer_functions2_int64,
4410 glsl_type::int64_t_type),
4411 _addSaturate(shader_integer_functions2_int64,
4412 glsl_type::i64vec2_type),
4413 _addSaturate(shader_integer_functions2_int64,
4414 glsl_type::i64vec3_type),
4415 _addSaturate(shader_integer_functions2_int64,
4416 glsl_type::i64vec4_type),
4417 _addSaturate(shader_integer_functions2_int64,
4418 glsl_type::uint64_t_type),
4419 _addSaturate(shader_integer_functions2_int64,
4420 glsl_type::u64vec2_type),
4421 _addSaturate(shader_integer_functions2_int64,
4422 glsl_type::u64vec3_type),
4423 _addSaturate(shader_integer_functions2_int64,
4424 glsl_type::u64vec4_type),
4425 NULL);
4426
4427 add_function("average",
4428 _average(shader_integer_functions2,
4429 glsl_type::int_type),
4430 _average(shader_integer_functions2,
4431 glsl_type::ivec2_type),
4432 _average(shader_integer_functions2,
4433 glsl_type::ivec3_type),
4434 _average(shader_integer_functions2,
4435 glsl_type::ivec4_type),
4436 _average(shader_integer_functions2,
4437 glsl_type::uint_type),
4438 _average(shader_integer_functions2,
4439 glsl_type::uvec2_type),
4440 _average(shader_integer_functions2,
4441 glsl_type::uvec3_type),
4442 _average(shader_integer_functions2,
4443 glsl_type::uvec4_type),
4444
4445 _average(shader_integer_functions2_int64,
4446 glsl_type::int64_t_type),
4447 _average(shader_integer_functions2_int64,
4448 glsl_type::i64vec2_type),
4449 _average(shader_integer_functions2_int64,
4450 glsl_type::i64vec3_type),
4451 _average(shader_integer_functions2_int64,
4452 glsl_type::i64vec4_type),
4453 _average(shader_integer_functions2_int64,
4454 glsl_type::uint64_t_type),
4455 _average(shader_integer_functions2_int64,
4456 glsl_type::u64vec2_type),
4457 _average(shader_integer_functions2_int64,
4458 glsl_type::u64vec3_type),
4459 _average(shader_integer_functions2_int64,
4460 glsl_type::u64vec4_type),
4461 NULL);
4462
4463 add_function("averageRounded",
4464 _averageRounded(shader_integer_functions2,
4465 glsl_type::int_type),
4466 _averageRounded(shader_integer_functions2,
4467 glsl_type::ivec2_type),
4468 _averageRounded(shader_integer_functions2,
4469 glsl_type::ivec3_type),
4470 _averageRounded(shader_integer_functions2,
4471 glsl_type::ivec4_type),
4472 _averageRounded(shader_integer_functions2,
4473 glsl_type::uint_type),
4474 _averageRounded(shader_integer_functions2,
4475 glsl_type::uvec2_type),
4476 _averageRounded(shader_integer_functions2,
4477 glsl_type::uvec3_type),
4478 _averageRounded(shader_integer_functions2,
4479 glsl_type::uvec4_type),
4480
4481 _averageRounded(shader_integer_functions2_int64,
4482 glsl_type::int64_t_type),
4483 _averageRounded(shader_integer_functions2_int64,
4484 glsl_type::i64vec2_type),
4485 _averageRounded(shader_integer_functions2_int64,
4486 glsl_type::i64vec3_type),
4487 _averageRounded(shader_integer_functions2_int64,
4488 glsl_type::i64vec4_type),
4489 _averageRounded(shader_integer_functions2_int64,
4490 glsl_type::uint64_t_type),
4491 _averageRounded(shader_integer_functions2_int64,
4492 glsl_type::u64vec2_type),
4493 _averageRounded(shader_integer_functions2_int64,
4494 glsl_type::u64vec3_type),
4495 _averageRounded(shader_integer_functions2_int64,
4496 glsl_type::u64vec4_type),
4497 NULL);
4498
4499 add_function("subtractSaturate",
4500 _subtractSaturate(shader_integer_functions2,
4501 glsl_type::int_type),
4502 _subtractSaturate(shader_integer_functions2,
4503 glsl_type::ivec2_type),
4504 _subtractSaturate(shader_integer_functions2,
4505 glsl_type::ivec3_type),
4506 _subtractSaturate(shader_integer_functions2,
4507 glsl_type::ivec4_type),
4508 _subtractSaturate(shader_integer_functions2,
4509 glsl_type::uint_type),
4510 _subtractSaturate(shader_integer_functions2,
4511 glsl_type::uvec2_type),
4512 _subtractSaturate(shader_integer_functions2,
4513 glsl_type::uvec3_type),
4514 _subtractSaturate(shader_integer_functions2,
4515 glsl_type::uvec4_type),
4516
4517 _subtractSaturate(shader_integer_functions2_int64,
4518 glsl_type::int64_t_type),
4519 _subtractSaturate(shader_integer_functions2_int64,
4520 glsl_type::i64vec2_type),
4521 _subtractSaturate(shader_integer_functions2_int64,
4522 glsl_type::i64vec3_type),
4523 _subtractSaturate(shader_integer_functions2_int64,
4524 glsl_type::i64vec4_type),
4525 _subtractSaturate(shader_integer_functions2_int64,
4526 glsl_type::uint64_t_type),
4527 _subtractSaturate(shader_integer_functions2_int64,
4528 glsl_type::u64vec2_type),
4529 _subtractSaturate(shader_integer_functions2_int64,
4530 glsl_type::u64vec3_type),
4531 _subtractSaturate(shader_integer_functions2_int64,
4532 glsl_type::u64vec4_type),
4533 NULL);
4534
4535 add_function("multiply32x16",
4536 _multiply32x16(shader_integer_functions2,
4537 glsl_type::int_type),
4538 _multiply32x16(shader_integer_functions2,
4539 glsl_type::ivec2_type),
4540 _multiply32x16(shader_integer_functions2,
4541 glsl_type::ivec3_type),
4542 _multiply32x16(shader_integer_functions2,
4543 glsl_type::ivec4_type),
4544 _multiply32x16(shader_integer_functions2,
4545 glsl_type::uint_type),
4546 _multiply32x16(shader_integer_functions2,
4547 glsl_type::uvec2_type),
4548 _multiply32x16(shader_integer_functions2,
4549 glsl_type::uvec3_type),
4550 _multiply32x16(shader_integer_functions2,
4551 glsl_type::uvec4_type),
4552 NULL);
4553
4554 #undef F
4555 #undef FI
4556 #undef FIUD_VEC
4557 #undef FIUBD_VEC
4558 #undef FIU2_MIXED
4559 }
4560
4561 void
4562 builtin_builder::add_function(const char *name, ...)
4563 {
4564 va_list ap;
4565
4566 ir_function *f = new(mem_ctx) ir_function(name);
4567
4568 va_start(ap, name);
4569 while (true) {
4570 ir_function_signature *sig = va_arg(ap, ir_function_signature *);
4571 if (sig == NULL)
4572 break;
4573
4574 if (false) {
4575 exec_list stuff;
4576 stuff.push_tail(sig);
4577 validate_ir_tree(&stuff);
4578 }
4579
4580 f->add_signature(sig);
4581 }
4582 va_end(ap);
4583
4584 shader->symbols->add_function(f);
4585 }
4586
4587 void
4588 builtin_builder::add_image_function(const char *name,
4589 const char *intrinsic_name,
4590 image_prototype_ctr prototype,
4591 unsigned num_arguments,
4592 unsigned flags,
4593 enum ir_intrinsic_id intrinsic_id)
4594 {
4595 static const glsl_type *const types[] = {
4596 glsl_type::image1D_type,
4597 glsl_type::image2D_type,
4598 glsl_type::image3D_type,
4599 glsl_type::image2DRect_type,
4600 glsl_type::imageCube_type,
4601 glsl_type::imageBuffer_type,
4602 glsl_type::image1DArray_type,
4603 glsl_type::image2DArray_type,
4604 glsl_type::imageCubeArray_type,
4605 glsl_type::image2DMS_type,
4606 glsl_type::image2DMSArray_type,
4607 glsl_type::iimage1D_type,
4608 glsl_type::iimage2D_type,
4609 glsl_type::iimage3D_type,
4610 glsl_type::iimage2DRect_type,
4611 glsl_type::iimageCube_type,
4612 glsl_type::iimageBuffer_type,
4613 glsl_type::iimage1DArray_type,
4614 glsl_type::iimage2DArray_type,
4615 glsl_type::iimageCubeArray_type,
4616 glsl_type::iimage2DMS_type,
4617 glsl_type::iimage2DMSArray_type,
4618 glsl_type::uimage1D_type,
4619 glsl_type::uimage2D_type,
4620 glsl_type::uimage3D_type,
4621 glsl_type::uimage2DRect_type,
4622 glsl_type::uimageCube_type,
4623 glsl_type::uimageBuffer_type,
4624 glsl_type::uimage1DArray_type,
4625 glsl_type::uimage2DArray_type,
4626 glsl_type::uimageCubeArray_type,
4627 glsl_type::uimage2DMS_type,
4628 glsl_type::uimage2DMSArray_type
4629 };
4630
4631 ir_function *f = new(mem_ctx) ir_function(name);
4632
4633 for (unsigned i = 0; i < ARRAY_SIZE(types); ++i) {
4634 if ((types[i]->sampled_type != GLSL_TYPE_FLOAT ||
4635 (flags & IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE)) &&
4636 (types[i]->sampler_dimensionality == GLSL_SAMPLER_DIM_MS ||
4637 !(flags & IMAGE_FUNCTION_MS_ONLY)))
4638 f->add_signature(_image(prototype, types[i], intrinsic_name,
4639 num_arguments, flags, intrinsic_id));
4640 }
4641
4642 shader->symbols->add_function(f);
4643 }
4644
4645 void
4646 builtin_builder::add_image_functions(bool glsl)
4647 {
4648 const unsigned flags = (glsl ? IMAGE_FUNCTION_EMIT_STUB : 0);
4649
4650 add_image_function(glsl ? "imageLoad" : "__intrinsic_image_load",
4651 "__intrinsic_image_load",
4652 &builtin_builder::_image_prototype, 0,
4653 (flags | IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE |
4654 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |
4655 IMAGE_FUNCTION_READ_ONLY),
4656 ir_intrinsic_image_load);
4657
4658 add_image_function(glsl ? "imageStore" : "__intrinsic_image_store",
4659 "__intrinsic_image_store",
4660 &builtin_builder::_image_prototype, 1,
4661 (flags | IMAGE_FUNCTION_RETURNS_VOID |
4662 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE |
4663 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |
4664 IMAGE_FUNCTION_WRITE_ONLY),
4665 ir_intrinsic_image_store);
4666
4667 const unsigned atom_flags = flags | IMAGE_FUNCTION_AVAIL_ATOMIC;
4668
4669 add_image_function(glsl ? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
4670 "__intrinsic_image_atomic_add",
4671 &builtin_builder::_image_prototype, 1,
4672 (flags | IMAGE_FUNCTION_AVAIL_ATOMIC_ADD |
4673 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE),
4674 ir_intrinsic_image_atomic_add);
4675
4676 add_image_function(glsl ? "imageAtomicMin" : "__intrinsic_image_atomic_min",
4677 "__intrinsic_image_atomic_min",
4678 &builtin_builder::_image_prototype, 1, atom_flags,
4679 ir_intrinsic_image_atomic_min);
4680
4681 add_image_function(glsl ? "imageAtomicMax" : "__intrinsic_image_atomic_max",
4682 "__intrinsic_image_atomic_max",
4683 &builtin_builder::_image_prototype, 1, atom_flags,
4684 ir_intrinsic_image_atomic_max);
4685
4686 add_image_function(glsl ? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
4687 "__intrinsic_image_atomic_and",
4688 &builtin_builder::_image_prototype, 1, atom_flags,
4689 ir_intrinsic_image_atomic_and);
4690
4691 add_image_function(glsl ? "imageAtomicOr" : "__intrinsic_image_atomic_or",
4692 "__intrinsic_image_atomic_or",
4693 &builtin_builder::_image_prototype, 1, atom_flags,
4694 ir_intrinsic_image_atomic_or);
4695
4696 add_image_function(glsl ? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
4697 "__intrinsic_image_atomic_xor",
4698 &builtin_builder::_image_prototype, 1, atom_flags,
4699 ir_intrinsic_image_atomic_xor);
4700
4701 add_image_function((glsl ? "imageAtomicExchange" :
4702 "__intrinsic_image_atomic_exchange"),
4703 "__intrinsic_image_atomic_exchange",
4704 &builtin_builder::_image_prototype, 1,
4705 (flags | IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE |
4706 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE),
4707 ir_intrinsic_image_atomic_exchange);
4708
4709 add_image_function((glsl ? "imageAtomicCompSwap" :
4710 "__intrinsic_image_atomic_comp_swap"),
4711 "__intrinsic_image_atomic_comp_swap",
4712 &builtin_builder::_image_prototype, 2, atom_flags,
4713 ir_intrinsic_image_atomic_comp_swap);
4714
4715 add_image_function(glsl ? "imageSize" : "__intrinsic_image_size",
4716 "__intrinsic_image_size",
4717 &builtin_builder::_image_size_prototype, 1,
4718 flags | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE,
4719 ir_intrinsic_image_size);
4720
4721 add_image_function(glsl ? "imageSamples" : "__intrinsic_image_samples",
4722 "__intrinsic_image_samples",
4723 &builtin_builder::_image_samples_prototype, 1,
4724 flags | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |
4725 IMAGE_FUNCTION_MS_ONLY,
4726 ir_intrinsic_image_samples);
4727
4728 /* EXT_shader_image_load_store */
4729 add_image_function(glsl ? "imageAtomicIncWrap" : "__intrinsic_image_atomic_inc_wrap",
4730 "__intrinsic_image_atomic_inc_wrap",
4731 &builtin_builder::_image_prototype, 1,
4732 (atom_flags | IMAGE_FUNCTION_EXT_ONLY),
4733 ir_intrinsic_image_atomic_inc_wrap);
4734 add_image_function(glsl ? "imageAtomicDecWrap" : "__intrinsic_image_atomic_dec_wrap",
4735 "__intrinsic_image_atomic_dec_wrap",
4736 &builtin_builder::_image_prototype, 1,
4737 (atom_flags | IMAGE_FUNCTION_EXT_ONLY),
4738 ir_intrinsic_image_atomic_dec_wrap);
4739 }
4740
4741 ir_variable *
4742 builtin_builder::in_var(const glsl_type *type, const char *name)
4743 {
4744 return new(mem_ctx) ir_variable(type, name, ir_var_function_in);
4745 }
4746
4747 ir_variable *
4748 builtin_builder::out_var(const glsl_type *type, const char *name)
4749 {
4750 return new(mem_ctx) ir_variable(type, name, ir_var_function_out);
4751 }
4752
4753 ir_constant *
4754 builtin_builder::imm(bool b, unsigned vector_elements)
4755 {
4756 return new(mem_ctx) ir_constant(b, vector_elements);
4757 }
4758
4759 ir_constant *
4760 builtin_builder::imm(float f, unsigned vector_elements)
4761 {
4762 return new(mem_ctx) ir_constant(f, vector_elements);
4763 }
4764
4765 ir_constant *
4766 builtin_builder::imm(int i, unsigned vector_elements)
4767 {
4768 return new(mem_ctx) ir_constant(i, vector_elements);
4769 }
4770
4771 ir_constant *
4772 builtin_builder::imm(unsigned u, unsigned vector_elements)
4773 {
4774 return new(mem_ctx) ir_constant(u, vector_elements);
4775 }
4776
4777 ir_constant *
4778 builtin_builder::imm(double d, unsigned vector_elements)
4779 {
4780 return new(mem_ctx) ir_constant(d, vector_elements);
4781 }
4782
4783 ir_constant *
4784 builtin_builder::imm(const glsl_type *type, const ir_constant_data &data)
4785 {
4786 return new(mem_ctx) ir_constant(type, &data);
4787 }
4788
4789 #define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)
4790
4791 ir_dereference_variable *
4792 builtin_builder::var_ref(ir_variable *var)
4793 {
4794 return new(mem_ctx) ir_dereference_variable(var);
4795 }
4796
4797 ir_dereference_array *
4798 builtin_builder::array_ref(ir_variable *var, int idx)
4799 {
4800 return new(mem_ctx) ir_dereference_array(var, imm(idx));
4801 }
4802
4803 /** Return an element of a matrix */
4804 ir_swizzle *
4805 builtin_builder::matrix_elt(ir_variable *var, int column, int row)
4806 {
4807 return swizzle(array_ref(var, column), row, 1);
4808 }
4809
4810 /**
4811 * Implementations of built-in functions:
4812 * @{
4813 */
4814 ir_function_signature *
4815 builtin_builder::new_sig(const glsl_type *return_type,
4816 builtin_available_predicate avail,
4817 int num_params,
4818 ...)
4819 {
4820 va_list ap;
4821
4822 ir_function_signature *sig =
4823 new(mem_ctx) ir_function_signature(return_type, avail);
4824
4825 exec_list plist;
4826 va_start(ap, num_params);
4827 for (int i = 0; i < num_params; i++) {
4828 plist.push_tail(va_arg(ap, ir_variable *));
4829 }
4830 va_end(ap);
4831
4832 sig->replace_parameters(&plist);
4833 return sig;
4834 }
4835
4836 #define MAKE_SIG(return_type, avail, ...) \
4837 ir_function_signature *sig = \
4838 new_sig(return_type, avail, __VA_ARGS__); \
4839 ir_factory body(&sig->body, mem_ctx); \
4840 sig->is_defined = true;
4841
4842 #define MAKE_INTRINSIC(return_type, id, avail, ...) \
4843 ir_function_signature *sig = \
4844 new_sig(return_type, avail, __VA_ARGS__); \
4845 sig->intrinsic_id = id;
4846
4847 ir_function_signature *
4848 builtin_builder::unop(builtin_available_predicate avail,
4849 ir_expression_operation opcode,
4850 const glsl_type *return_type,
4851 const glsl_type *param_type)
4852 {
4853 ir_variable *x = in_var(param_type, "x");
4854 MAKE_SIG(return_type, avail, 1, x);
4855 body.emit(ret(expr(opcode, x)));
4856 return sig;
4857 }
4858
4859 #define UNOP(NAME, OPCODE, AVAIL) \
4860 ir_function_signature * \
4861 builtin_builder::_##NAME(const glsl_type *type) \
4862 { \
4863 return unop(&AVAIL, OPCODE, type, type); \
4864 }
4865
4866 #define UNOPA(NAME, OPCODE) \
4867 ir_function_signature * \
4868 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
4869 { \
4870 return unop(avail, OPCODE, type, type); \
4871 }
4872
4873 ir_function_signature *
4874 builtin_builder::binop(builtin_available_predicate avail,
4875 ir_expression_operation opcode,
4876 const glsl_type *return_type,
4877 const glsl_type *param0_type,
4878 const glsl_type *param1_type,
4879 bool swap_operands)
4880 {
4881 ir_variable *x = in_var(param0_type, "x");
4882 ir_variable *y = in_var(param1_type, "y");
4883 MAKE_SIG(return_type, avail, 2, x, y);
4884
4885 if (swap_operands)
4886 body.emit(ret(expr(opcode, y, x)));
4887 else
4888 body.emit(ret(expr(opcode, x, y)));
4889
4890 return sig;
4891 }
4892
4893 #define BINOP(NAME, OPCODE, AVAIL) \
4894 ir_function_signature * \
4895 builtin_builder::_##NAME(const glsl_type *return_type, \
4896 const glsl_type *param0_type, \
4897 const glsl_type *param1_type) \
4898 { \
4899 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
4900 }
4901
4902 /**
4903 * Angle and Trigonometry Functions @{
4904 */
4905
4906 ir_function_signature *
4907 builtin_builder::_radians(const glsl_type *type)
4908 {
4909 ir_variable *degrees = in_var(type, "degrees");
4910 MAKE_SIG(type, always_available, 1, degrees);
4911 body.emit(ret(mul(degrees, imm(0.0174532925f))));
4912 return sig;
4913 }
4914
4915 ir_function_signature *
4916 builtin_builder::_degrees(const glsl_type *type)
4917 {
4918 ir_variable *radians = in_var(type, "radians");
4919 MAKE_SIG(type, always_available, 1, radians);
4920 body.emit(ret(mul(radians, imm(57.29578f))));
4921 return sig;
4922 }
4923
4924 UNOP(sin, ir_unop_sin, always_available)
4925 UNOP(cos, ir_unop_cos, always_available)
4926
4927 ir_function_signature *
4928 builtin_builder::_tan(const glsl_type *type)
4929 {
4930 ir_variable *theta = in_var(type, "theta");
4931 MAKE_SIG(type, always_available, 1, theta);
4932 body.emit(ret(div(sin(theta), cos(theta))));
4933 return sig;
4934 }
4935
4936 ir_expression *
4937 builtin_builder::asin_expr(ir_variable *x, float p0, float p1)
4938 {
4939 return mul(sign(x),
4940 sub(imm(M_PI_2f),
4941 mul(sqrt(sub(imm(1.0f), abs(x))),
4942 add(imm(M_PI_2f),
4943 mul(abs(x),
4944 add(imm(M_PI_4f - 1.0f),
4945 mul(abs(x),
4946 add(imm(p0),
4947 mul(abs(x), imm(p1))))))))));
4948 }
4949
4950 /**
4951 * Generate a ir_call to a function with a set of parameters
4952 *
4953 * The input \c params can either be a list of \c ir_variable or a list of
4954 * \c ir_dereference_variable. In the latter case, all nodes will be removed
4955 * from \c params and used directly as the parameters to the generated
4956 * \c ir_call.
4957 */
4958 ir_call *
4959 builtin_builder::call(ir_function *f, ir_variable *ret, exec_list params)
4960 {
4961 exec_list actual_params;
4962
4963 foreach_in_list_safe(ir_instruction, ir, &params) {
4964 ir_dereference_variable *d = ir->as_dereference_variable();
4965 if (d != NULL) {
4966 d->remove();
4967 actual_params.push_tail(d);
4968 } else {
4969 ir_variable *var = ir->as_variable();
4970 assert(var != NULL);
4971 actual_params.push_tail(var_ref(var));
4972 }
4973 }
4974
4975 ir_function_signature *sig =
4976 f->exact_matching_signature(NULL, &actual_params);
4977 if (!sig)
4978 return NULL;
4979
4980 ir_dereference_variable *deref =
4981 (sig->return_type->is_void() ? NULL : var_ref(ret));
4982
4983 return new(mem_ctx) ir_call(sig, deref, &actual_params);
4984 }
4985
4986 ir_function_signature *
4987 builtin_builder::_asin(const glsl_type *type)
4988 {
4989 ir_variable *x = in_var(type, "x");
4990 MAKE_SIG(type, always_available, 1, x);
4991
4992 body.emit(ret(asin_expr(x, 0.086566724f, -0.03102955f)));
4993
4994 return sig;
4995 }
4996
4997 ir_function_signature *
4998 builtin_builder::_acos(const glsl_type *type)
4999 {
5000 ir_variable *x = in_var(type, "x");
5001 MAKE_SIG(type, always_available, 1, x);
5002
5003 body.emit(ret(sub(imm(M_PI_2f), asin_expr(x, 0.08132463f, -0.02363318f))));
5004
5005 return sig;
5006 }
5007
5008 ir_function_signature *
5009 builtin_builder::_atan2(const glsl_type *type)
5010 {
5011 const unsigned n = type->vector_elements;
5012 ir_variable *y = in_var(type, "y");
5013 ir_variable *x = in_var(type, "x");
5014 MAKE_SIG(type, is_not_nir, 2, y, x);
5015
5016 /* If we're on the left half-plane rotate the coordinates π/2 clock-wise
5017 * for the y=0 discontinuity to end up aligned with the vertical
5018 * discontinuity of atan(s/t) along t=0. This also makes sure that we
5019 * don't attempt to divide by zero along the vertical line, which may give
5020 * unspecified results on non-GLSL 4.1-capable hardware.
5021 */
5022 ir_variable *flip = body.make_temp(glsl_type::bvec(n), "flip");
5023 body.emit(assign(flip, gequal(imm(0.0f, n), x)));
5024 ir_variable *s = body.make_temp(type, "s");
5025 body.emit(assign(s, csel(flip, abs(x), y)));
5026 ir_variable *t = body.make_temp(type, "t");
5027 body.emit(assign(t, csel(flip, y, abs(x))));
5028
5029 /* If the magnitude of the denominator exceeds some huge value, scale down
5030 * the arguments in order to prevent the reciprocal operation from flushing
5031 * its result to zero, which would cause precision problems, and for s
5032 * infinite would cause us to return a NaN instead of the correct finite
5033 * value.
5034 *
5035 * If fmin and fmax are respectively the smallest and largest positive
5036 * normalized floating point values representable by the implementation,
5037 * the constants below should be in agreement with:
5038 *
5039 * huge <= 1 / fmin
5040 * scale <= 1 / fmin / fmax (for |t| >= huge)
5041 *
5042 * In addition scale should be a negative power of two in order to avoid
5043 * loss of precision. The values chosen below should work for most usual
5044 * floating point representations with at least the dynamic range of ATI's
5045 * 24-bit representation.
5046 */
5047 ir_constant *huge = imm(1e18f, n);
5048 ir_variable *scale = body.make_temp(type, "scale");
5049 body.emit(assign(scale, csel(gequal(abs(t), huge),
5050 imm(0.25f, n), imm(1.0f, n))));
5051 ir_variable *rcp_scaled_t = body.make_temp(type, "rcp_scaled_t");
5052 body.emit(assign(rcp_scaled_t, rcp(mul(t, scale))));
5053 ir_expression *s_over_t = mul(mul(s, scale), rcp_scaled_t);
5054
5055 /* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily
5056 * that ∞/∞ = 1) in order to comply with the rather artificial rules
5057 * inherited from IEEE 754-2008, namely:
5058 *
5059 * "atan2(±∞, −∞) is ±3π/4
5060 * atan2(±∞, +∞) is ±π/4"
5061 *
5062 * Note that this is inconsistent with the rules for the neighborhood of
5063 * zero that are based on iterated limits:
5064 *
5065 * "atan2(±0, −0) is ±π
5066 * atan2(±0, +0) is ±0"
5067 *
5068 * but GLSL specifically allows implementations to deviate from IEEE rules
5069 * at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as
5070 * well).
5071 */
5072 ir_expression *tan = csel(equal(abs(x), abs(y)),
5073 imm(1.0f, n), abs(s_over_t));
5074
5075 /* Calculate the arctangent and fix up the result if we had flipped the
5076 * coordinate system.
5077 */
5078 ir_variable *arc = body.make_temp(type, "arc");
5079 do_atan(body, type, arc, tan);
5080 body.emit(assign(arc, add(arc, mul(b2f(flip), imm(M_PI_2f)))));
5081
5082 /* Rather convoluted calculation of the sign of the result. When x < 0 we
5083 * cannot use fsign because we need to be able to distinguish between
5084 * negative and positive zero. Unfortunately we cannot use bitwise
5085 * arithmetic tricks either because of back-ends without integer support.
5086 * When x >= 0 rcp_scaled_t will always be non-negative so this won't be
5087 * able to distinguish between negative and positive zero, but we don't
5088 * care because atan2 is continuous along the whole positive y = 0
5089 * half-line, so it won't affect the result significantly.
5090 */
5091 body.emit(ret(csel(less(min2(y, rcp_scaled_t), imm(0.0f, n)),
5092 neg(arc), arc)));
5093
5094 return sig;
5095 }
5096
5097 void
5098 builtin_builder::do_atan(ir_factory &body, const glsl_type *type, ir_variable *res, operand y_over_x)
5099 {
5100 /*
5101 * range-reduction, first step:
5102 *
5103 * / y_over_x if |y_over_x| <= 1.0;
5104 * x = <
5105 * \ 1.0 / y_over_x otherwise
5106 */
5107 ir_variable *x = body.make_temp(type, "atan_x");
5108 body.emit(assign(x, div(min2(abs(y_over_x),
5109 imm(1.0f)),
5110 max2(abs(y_over_x),
5111 imm(1.0f)))));
5112
5113 /*
5114 * approximate atan by evaluating polynomial:
5115 *
5116 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
5117 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
5118 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
5119 */
5120 ir_variable *tmp = body.make_temp(type, "atan_tmp");
5121 body.emit(assign(tmp, mul(x, x)));
5122 body.emit(assign(tmp, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f),
5123 tmp),
5124 imm(0.0536813784310406f)),
5125 tmp),
5126 imm(0.1173503194786851f)),
5127 tmp),
5128 imm(0.1938924977115610f)),
5129 tmp),
5130 imm(0.3326756418091246f)),
5131 tmp),
5132 imm(0.9999793128310355f)),
5133 x)));
5134
5135 /* range-reduction fixup */
5136 body.emit(assign(tmp, add(tmp,
5137 mul(b2f(greater(abs(y_over_x),
5138 imm(1.0f, type->components()))),
5139 add(mul(tmp,
5140 imm(-2.0f)),
5141 imm(M_PI_2f))))));
5142
5143 /* sign fixup */
5144 body.emit(assign(res, mul(tmp, sign(y_over_x))));
5145 }
5146
5147 ir_function_signature *
5148 builtin_builder::_atan(const glsl_type *type)
5149 {
5150 ir_variable *y_over_x = in_var(type, "y_over_x");
5151 MAKE_SIG(type, is_not_nir, 1, y_over_x);
5152
5153 ir_variable *tmp = body.make_temp(type, "tmp");
5154 do_atan(body, type, tmp, y_over_x);
5155 body.emit(ret(tmp));
5156
5157 return sig;
5158 }
5159
5160 ir_function_signature *
5161 builtin_builder::_sinh(const glsl_type *type)
5162 {
5163 ir_variable *x = in_var(type, "x");
5164 MAKE_SIG(type, v130, 1, x);
5165
5166 /* 0.5 * (e^x - e^(-x)) */
5167 body.emit(ret(mul(imm(0.5f), sub(exp(x), exp(neg(x))))));
5168
5169 return sig;
5170 }
5171
5172 ir_function_signature *
5173 builtin_builder::_cosh(const glsl_type *type)
5174 {
5175 ir_variable *x = in_var(type, "x");
5176 MAKE_SIG(type, v130, 1, x);
5177
5178 /* 0.5 * (e^x + e^(-x)) */
5179 body.emit(ret(mul(imm(0.5f), add(exp(x), exp(neg(x))))));
5180
5181 return sig;
5182 }
5183
5184 ir_function_signature *
5185 builtin_builder::_tanh(const glsl_type *type)
5186 {
5187 ir_variable *x = in_var(type, "x");
5188 MAKE_SIG(type, v130, 1, x);
5189
5190 /* Clamp x to [-10, +10] to avoid precision problems.
5191 * When x > 10, e^(-x) is so small relative to e^x that it gets flushed to
5192 * zero in the computation e^x + e^(-x). The same happens in the other
5193 * direction when x < -10.
5194 */
5195 ir_variable *t = body.make_temp(type, "tmp");
5196 body.emit(assign(t, min2(max2(x, imm(-10.0f)), imm(10.0f))));
5197
5198 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
5199 body.emit(ret(div(sub(exp(t), exp(neg(t))),
5200 add(exp(t), exp(neg(t))))));
5201
5202 return sig;
5203 }
5204
5205 ir_function_signature *
5206 builtin_builder::_asinh(const glsl_type *type)
5207 {
5208 ir_variable *x = in_var(type, "x");
5209 MAKE_SIG(type, v130, 1, x);
5210
5211 body.emit(ret(mul(sign(x), log(add(abs(x), sqrt(add(mul(x, x),
5212 imm(1.0f))))))));
5213 return sig;
5214 }
5215
5216 ir_function_signature *
5217 builtin_builder::_acosh(const glsl_type *type)
5218 {
5219 ir_variable *x = in_var(type, "x");
5220 MAKE_SIG(type, v130, 1, x);
5221
5222 body.emit(ret(log(add(x, sqrt(sub(mul(x, x), imm(1.0f)))))));
5223 return sig;
5224 }
5225
5226 ir_function_signature *
5227 builtin_builder::_atanh(const glsl_type *type)
5228 {
5229 ir_variable *x = in_var(type, "x");
5230 MAKE_SIG(type, v130, 1, x);
5231
5232 body.emit(ret(mul(imm(0.5f), log(div(add(imm(1.0f), x),
5233 sub(imm(1.0f), x))))));
5234 return sig;
5235 }
5236 /** @} */
5237
5238 /**
5239 * Exponential Functions @{
5240 */
5241
5242 ir_function_signature *
5243 builtin_builder::_pow(const glsl_type *type)
5244 {
5245 return binop(always_available, ir_binop_pow, type, type, type);
5246 }
5247
5248 UNOP(exp, ir_unop_exp, always_available)
5249 UNOP(log, ir_unop_log, always_available)
5250 UNOP(exp2, ir_unop_exp2, always_available)
5251 UNOP(log2, ir_unop_log2, always_available)
5252 UNOP(atan_op, ir_unop_atan, is_nir)
5253 UNOPA(sqrt, ir_unop_sqrt)
5254 UNOPA(inversesqrt, ir_unop_rsq)
5255
5256 /** @} */
5257
5258 UNOPA(abs, ir_unop_abs)
5259 UNOPA(sign, ir_unop_sign)
5260 UNOPA(floor, ir_unop_floor)
5261 UNOPA(truncate, ir_unop_trunc)
5262 UNOPA(trunc, ir_unop_trunc)
5263 UNOPA(round, ir_unop_round_even)
5264 UNOPA(roundEven, ir_unop_round_even)
5265 UNOPA(ceil, ir_unop_ceil)
5266 UNOPA(fract, ir_unop_fract)
5267
5268 ir_function_signature *
5269 builtin_builder::_mod(builtin_available_predicate avail,
5270 const glsl_type *x_type, const glsl_type *y_type)
5271 {
5272 return binop(avail, ir_binop_mod, x_type, x_type, y_type);
5273 }
5274
5275 ir_function_signature *
5276 builtin_builder::_modf(builtin_available_predicate avail, const glsl_type *type)
5277 {
5278 ir_variable *x = in_var(type, "x");
5279 ir_variable *i = out_var(type, "i");
5280 MAKE_SIG(type, avail, 2, x, i);
5281
5282 ir_variable *t = body.make_temp(type, "t");
5283 body.emit(assign(t, expr(ir_unop_trunc, x)));
5284 body.emit(assign(i, t));
5285 body.emit(ret(sub(x, t)));
5286
5287 return sig;
5288 }
5289
5290 ir_function_signature *
5291 builtin_builder::_min(builtin_available_predicate avail,
5292 const glsl_type *x_type, const glsl_type *y_type)
5293 {
5294 return binop(avail, ir_binop_min, x_type, x_type, y_type);
5295 }
5296
5297 ir_function_signature *
5298 builtin_builder::_max(builtin_available_predicate avail,
5299 const glsl_type *x_type, const glsl_type *y_type)
5300 {
5301 return binop(avail, ir_binop_max, x_type, x_type, y_type);
5302 }
5303
5304 ir_function_signature *
5305 builtin_builder::_clamp(builtin_available_predicate avail,
5306 const glsl_type *val_type, const glsl_type *bound_type)
5307 {
5308 ir_variable *x = in_var(val_type, "x");
5309 ir_variable *minVal = in_var(bound_type, "minVal");
5310 ir_variable *maxVal = in_var(bound_type, "maxVal");
5311 MAKE_SIG(val_type, avail, 3, x, minVal, maxVal);
5312
5313 body.emit(ret(clamp(x, minVal, maxVal)));
5314
5315 return sig;
5316 }
5317
5318 ir_function_signature *
5319 builtin_builder::_mix_lrp(builtin_available_predicate avail, const glsl_type *val_type, const glsl_type *blend_type)
5320 {
5321 ir_variable *x = in_var(val_type, "x");
5322 ir_variable *y = in_var(val_type, "y");
5323 ir_variable *a = in_var(blend_type, "a");
5324 MAKE_SIG(val_type, avail, 3, x, y, a);
5325
5326 body.emit(ret(lrp(x, y, a)));
5327
5328 return sig;
5329 }
5330
5331 ir_function_signature *
5332 builtin_builder::_mix_sel(builtin_available_predicate avail,
5333 const glsl_type *val_type,
5334 const glsl_type *blend_type)
5335 {
5336 ir_variable *x = in_var(val_type, "x");
5337 ir_variable *y = in_var(val_type, "y");
5338 ir_variable *a = in_var(blend_type, "a");
5339 MAKE_SIG(val_type, avail, 3, x, y, a);
5340
5341 /* csel matches the ternary operator in that a selector of true choses the
5342 * first argument. This differs from mix(x, y, false) which choses the
5343 * second argument (to remain consistent with the interpolating version of
5344 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
5345 *
5346 * To handle the behavior mismatch, reverse the x and y arguments.
5347 */
5348 body.emit(ret(csel(a, y, x)));
5349
5350 return sig;
5351 }
5352
5353 ir_function_signature *
5354 builtin_builder::_step(builtin_available_predicate avail, const glsl_type *edge_type, const glsl_type *x_type)
5355 {
5356 ir_variable *edge = in_var(edge_type, "edge");
5357 ir_variable *x = in_var(x_type, "x");
5358 MAKE_SIG(x_type, avail, 2, edge, x);
5359
5360 ir_variable *t = body.make_temp(x_type, "t");
5361 if (x_type->vector_elements == 1) {
5362 /* Both are floats */
5363 if (edge_type->is_double())
5364 body.emit(assign(t, f2d(b2f(gequal(x, edge)))));
5365 else
5366 body.emit(assign(t, b2f(gequal(x, edge))));
5367 } else if (edge_type->vector_elements == 1) {
5368 /* x is a vector but edge is a float */
5369 for (int i = 0; i < x_type->vector_elements; i++) {
5370 if (edge_type->is_double())
5371 body.emit(assign(t, f2d(b2f(gequal(swizzle(x, i, 1), edge))), 1 << i));
5372 else
5373 body.emit(assign(t, b2f(gequal(swizzle(x, i, 1), edge)), 1 << i));
5374 }
5375 } else {
5376 /* Both are vectors */
5377 for (int i = 0; i < x_type->vector_elements; i++) {
5378 if (edge_type->is_double())
5379 body.emit(assign(t, f2d(b2f(gequal(swizzle(x, i, 1), swizzle(edge, i, 1)))),
5380 1 << i));
5381 else
5382 body.emit(assign(t, b2f(gequal(swizzle(x, i, 1), swizzle(edge, i, 1))),
5383 1 << i));
5384
5385 }
5386 }
5387 body.emit(ret(t));
5388
5389 return sig;
5390 }
5391
5392 ir_function_signature *
5393 builtin_builder::_smoothstep(builtin_available_predicate avail, const glsl_type *edge_type, const glsl_type *x_type)
5394 {
5395 ir_variable *edge0 = in_var(edge_type, "edge0");
5396 ir_variable *edge1 = in_var(edge_type, "edge1");
5397 ir_variable *x = in_var(x_type, "x");
5398 MAKE_SIG(x_type, avail, 3, edge0, edge1, x);
5399
5400 /* From the GLSL 1.10 specification:
5401 *
5402 * genType t;
5403 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
5404 * return t * t * (3 - 2 * t);
5405 */
5406
5407 ir_variable *t = body.make_temp(x_type, "t");
5408 body.emit(assign(t, clamp(div(sub(x, edge0), sub(edge1, edge0)),
5409 IMM_FP(x_type, 0.0), IMM_FP(x_type, 1.0))));
5410
5411 body.emit(ret(mul(t, mul(t, sub(IMM_FP(x_type, 3.0), mul(IMM_FP(x_type, 2.0), t))))));
5412
5413 return sig;
5414 }
5415
5416 ir_function_signature *
5417 builtin_builder::_isnan(builtin_available_predicate avail, const glsl_type *type)
5418 {
5419 ir_variable *x = in_var(type, "x");
5420 MAKE_SIG(glsl_type::bvec(type->vector_elements), avail, 1, x);
5421
5422 body.emit(ret(nequal(x, x)));
5423
5424 return sig;
5425 }
5426
5427 ir_function_signature *
5428 builtin_builder::_isinf(builtin_available_predicate avail, const glsl_type *type)
5429 {
5430 ir_variable *x = in_var(type, "x");
5431 MAKE_SIG(glsl_type::bvec(type->vector_elements), avail, 1, x);
5432
5433 ir_constant_data infinities;
5434 for (int i = 0; i < type->vector_elements; i++) {
5435 switch (type->base_type) {
5436 case GLSL_TYPE_FLOAT:
5437 infinities.f[i] = INFINITY;
5438 break;
5439 case GLSL_TYPE_DOUBLE:
5440 infinities.d[i] = INFINITY;
5441 break;
5442 default:
5443 unreachable("unknown type");
5444 }
5445 }
5446
5447 body.emit(ret(equal(abs(x), imm(type, infinities))));
5448
5449 return sig;
5450 }
5451
5452 ir_function_signature *
5453 builtin_builder::_atan2_op(const glsl_type *x_type)
5454 {
5455 return binop(is_nir, ir_binop_atan2, x_type, x_type, x_type);
5456 }
5457
5458 ir_function_signature *
5459 builtin_builder::_floatBitsToInt(const glsl_type *type)
5460 {
5461 ir_variable *x = in_var(type, "x");
5462 MAKE_SIG(glsl_type::ivec(type->vector_elements), shader_bit_encoding, 1, x);
5463 body.emit(ret(bitcast_f2i(x)));
5464 return sig;
5465 }
5466
5467 ir_function_signature *
5468 builtin_builder::_floatBitsToUint(const glsl_type *type)
5469 {
5470 ir_variable *x = in_var(type, "x");
5471 MAKE_SIG(glsl_type::uvec(type->vector_elements), shader_bit_encoding, 1, x);
5472 body.emit(ret(bitcast_f2u(x)));
5473 return sig;
5474 }
5475
5476 ir_function_signature *
5477 builtin_builder::_intBitsToFloat(const glsl_type *type)
5478 {
5479 ir_variable *x = in_var(type, "x");
5480 MAKE_SIG(glsl_type::vec(type->vector_elements), shader_bit_encoding, 1, x);
5481 body.emit(ret(bitcast_i2f(x)));
5482 return sig;
5483 }
5484
5485 ir_function_signature *
5486 builtin_builder::_uintBitsToFloat(const glsl_type *type)
5487 {
5488 ir_variable *x = in_var(type, "x");
5489 MAKE_SIG(glsl_type::vec(type->vector_elements), shader_bit_encoding, 1, x);
5490 body.emit(ret(bitcast_u2f(x)));
5491 return sig;
5492 }
5493
5494 ir_function_signature *
5495 builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail, const glsl_type *type)
5496 {
5497 ir_variable *x = in_var(type, "x");
5498 MAKE_SIG(glsl_type::i64vec(type->vector_elements), avail, 1, x);
5499 body.emit(ret(bitcast_d2i64(x)));
5500 return sig;
5501 }
5502
5503 ir_function_signature *
5504 builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail, const glsl_type *type)
5505 {
5506 ir_variable *x = in_var(type, "x");
5507 MAKE_SIG(glsl_type::u64vec(type->vector_elements), avail, 1, x);
5508 body.emit(ret(bitcast_d2u64(x)));
5509 return sig;
5510 }
5511
5512 ir_function_signature *
5513 builtin_builder::_int64BitsToDouble(builtin_available_predicate avail, const glsl_type *type)
5514 {
5515 ir_variable *x = in_var(type, "x");
5516 MAKE_SIG(glsl_type::dvec(type->vector_elements), avail, 1, x);
5517 body.emit(ret(bitcast_i642d(x)));
5518 return sig;
5519 }
5520
5521 ir_function_signature *
5522 builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail, const glsl_type *type)
5523 {
5524 ir_variable *x = in_var(type, "x");
5525 MAKE_SIG(glsl_type::dvec(type->vector_elements), avail, 1, x);
5526 body.emit(ret(bitcast_u642d(x)));
5527 return sig;
5528 }
5529
5530 ir_function_signature *
5531 builtin_builder::_packUnorm2x16(builtin_available_predicate avail)
5532 {
5533 ir_variable *v = in_var(glsl_type::vec2_type, "v");
5534 MAKE_SIG(glsl_type::uint_type, avail, 1, v);
5535 body.emit(ret(expr(ir_unop_pack_unorm_2x16, v)));
5536 return sig;
5537 }
5538
5539 ir_function_signature *
5540 builtin_builder::_packSnorm2x16(builtin_available_predicate avail)
5541 {
5542 ir_variable *v = in_var(glsl_type::vec2_type, "v");
5543 MAKE_SIG(glsl_type::uint_type, avail, 1, v);
5544 body.emit(ret(expr(ir_unop_pack_snorm_2x16, v)));
5545 return sig;
5546 }
5547
5548 ir_function_signature *
5549 builtin_builder::_packUnorm4x8(builtin_available_predicate avail)
5550 {
5551 ir_variable *v = in_var(glsl_type::vec4_type, "v");
5552 MAKE_SIG(glsl_type::uint_type, avail, 1, v);
5553 body.emit(ret(expr(ir_unop_pack_unorm_4x8, v)));
5554 return sig;
5555 }
5556
5557 ir_function_signature *
5558 builtin_builder::_packSnorm4x8(builtin_available_predicate avail)
5559 {
5560 ir_variable *v = in_var(glsl_type::vec4_type, "v");
5561 MAKE_SIG(glsl_type::uint_type, avail, 1, v);
5562 body.emit(ret(expr(ir_unop_pack_snorm_4x8, v)));
5563 return sig;
5564 }
5565
5566 ir_function_signature *
5567 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail)
5568 {
5569 ir_variable *p = in_var(glsl_type::uint_type, "p");
5570 MAKE_SIG(glsl_type::vec2_type, avail, 1, p);
5571 body.emit(ret(expr(ir_unop_unpack_unorm_2x16, p)));
5572 return sig;
5573 }
5574
5575 ir_function_signature *
5576 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail)
5577 {
5578 ir_variable *p = in_var(glsl_type::uint_type, "p");
5579 MAKE_SIG(glsl_type::vec2_type, avail, 1, p);
5580 body.emit(ret(expr(ir_unop_unpack_snorm_2x16, p)));
5581 return sig;
5582 }
5583
5584
5585 ir_function_signature *
5586 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail)
5587 {
5588 ir_variable *p = in_var(glsl_type::uint_type, "p");
5589 MAKE_SIG(glsl_type::vec4_type, avail, 1, p);
5590 body.emit(ret(expr(ir_unop_unpack_unorm_4x8, p)));
5591 return sig;
5592 }
5593
5594 ir_function_signature *
5595 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail)
5596 {
5597 ir_variable *p = in_var(glsl_type::uint_type, "p");
5598 MAKE_SIG(glsl_type::vec4_type, avail, 1, p);
5599 body.emit(ret(expr(ir_unop_unpack_snorm_4x8, p)));
5600 return sig;
5601 }
5602
5603 ir_function_signature *
5604 builtin_builder::_packHalf2x16(builtin_available_predicate avail)
5605 {
5606 ir_variable *v = in_var(glsl_type::vec2_type, "v");
5607 MAKE_SIG(glsl_type::uint_type, avail, 1, v);
5608 body.emit(ret(expr(ir_unop_pack_half_2x16, v)));
5609 return sig;
5610 }
5611
5612 ir_function_signature *
5613 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail)
5614 {
5615 ir_variable *p = in_var(glsl_type::uint_type, "p");
5616 MAKE_SIG(glsl_type::vec2_type, avail, 1, p);
5617 body.emit(ret(expr(ir_unop_unpack_half_2x16, p)));
5618 return sig;
5619 }
5620
5621 ir_function_signature *
5622 builtin_builder::_packDouble2x32(builtin_available_predicate avail)
5623 {
5624 ir_variable *v = in_var(glsl_type::uvec2_type, "v");
5625 MAKE_SIG(glsl_type::double_type, avail, 1, v);
5626 body.emit(ret(expr(ir_unop_pack_double_2x32, v)));
5627 return sig;
5628 }
5629
5630 ir_function_signature *
5631 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail)
5632 {
5633 ir_variable *p = in_var(glsl_type::double_type, "p");
5634 MAKE_SIG(glsl_type::uvec2_type, avail, 1, p);
5635 body.emit(ret(expr(ir_unop_unpack_double_2x32, p)));
5636 return sig;
5637 }
5638
5639 ir_function_signature *
5640 builtin_builder::_packInt2x32(builtin_available_predicate avail)
5641 {
5642 ir_variable *v = in_var(glsl_type::ivec2_type, "v");
5643 MAKE_SIG(glsl_type::int64_t_type, avail, 1, v);
5644 body.emit(ret(expr(ir_unop_pack_int_2x32, v)));
5645 return sig;
5646 }
5647
5648 ir_function_signature *
5649 builtin_builder::_unpackInt2x32(builtin_available_predicate avail)
5650 {
5651 ir_variable *p = in_var(glsl_type::int64_t_type, "p");
5652 MAKE_SIG(glsl_type::ivec2_type, avail, 1, p);
5653 body.emit(ret(expr(ir_unop_unpack_int_2x32, p)));
5654 return sig;
5655 }
5656
5657 ir_function_signature *
5658 builtin_builder::_packUint2x32(builtin_available_predicate avail)
5659 {
5660 ir_variable *v = in_var(glsl_type::uvec2_type, "v");
5661 MAKE_SIG(glsl_type::uint64_t_type, avail, 1, v);
5662 body.emit(ret(expr(ir_unop_pack_uint_2x32, v)));
5663 return sig;
5664 }
5665
5666 ir_function_signature *
5667 builtin_builder::_unpackUint2x32(builtin_available_predicate avail)
5668 {
5669 ir_variable *p = in_var(glsl_type::uint64_t_type, "p");
5670 MAKE_SIG(glsl_type::uvec2_type, avail, 1, p);
5671 body.emit(ret(expr(ir_unop_unpack_uint_2x32, p)));
5672 return sig;
5673 }
5674
5675 ir_function_signature *
5676 builtin_builder::_length(builtin_available_predicate avail, const glsl_type *type)
5677 {
5678 ir_variable *x = in_var(type, "x");
5679 MAKE_SIG(type->get_base_type(), avail, 1, x);
5680
5681 body.emit(ret(sqrt(dot(x, x))));
5682
5683 return sig;
5684 }
5685
5686 ir_function_signature *
5687 builtin_builder::_distance(builtin_available_predicate avail, const glsl_type *type)
5688 {
5689 ir_variable *p0 = in_var(type, "p0");
5690 ir_variable *p1 = in_var(type, "p1");
5691 MAKE_SIG(type->get_base_type(), avail, 2, p0, p1);
5692
5693 if (type->vector_elements == 1) {
5694 body.emit(ret(abs(sub(p0, p1))));
5695 } else {
5696 ir_variable *p = body.make_temp(type, "p");
5697 body.emit(assign(p, sub(p0, p1)));
5698 body.emit(ret(sqrt(dot(p, p))));
5699 }
5700
5701 return sig;
5702 }
5703
5704 ir_function_signature *
5705 builtin_builder::_dot(builtin_available_predicate avail, const glsl_type *type)
5706 {
5707 if (type->vector_elements == 1)
5708 return binop(avail, ir_binop_mul, type, type, type);
5709
5710 return binop(avail, ir_binop_dot,
5711 type->get_base_type(), type, type);
5712 }
5713
5714 ir_function_signature *
5715 builtin_builder::_cross(builtin_available_predicate avail, const glsl_type *type)
5716 {
5717 ir_variable *a = in_var(type, "a");
5718 ir_variable *b = in_var(type, "b");
5719 MAKE_SIG(type, avail, 2, a, b);
5720
5721 int yzx = MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X, 0);
5722 int zxy = MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_X, SWIZZLE_Y, 0);
5723
5724 body.emit(ret(sub(mul(swizzle(a, yzx, 3), swizzle(b, zxy, 3)),
5725 mul(swizzle(a, zxy, 3), swizzle(b, yzx, 3)))));
5726
5727 return sig;
5728 }
5729
5730 ir_function_signature *
5731 builtin_builder::_normalize(builtin_available_predicate avail, const glsl_type *type)
5732 {
5733 ir_variable *x = in_var(type, "x");
5734 MAKE_SIG(type, avail, 1, x);
5735
5736 if (type->vector_elements == 1) {
5737 body.emit(ret(sign(x)));
5738 } else {
5739 body.emit(ret(mul(x, rsq(dot(x, x)))));
5740 }
5741
5742 return sig;
5743 }
5744
5745 ir_function_signature *
5746 builtin_builder::_ftransform()
5747 {
5748 MAKE_SIG(glsl_type::vec4_type, compatibility_vs_only, 0);
5749
5750 /* ftransform() refers to global variables, and is always emitted
5751 * directly by ast_function.cpp. Just emit a prototype here so we
5752 * can recognize calls to it.
5753 */
5754 return sig;
5755 }
5756
5757 ir_function_signature *
5758 builtin_builder::_faceforward(builtin_available_predicate avail, const glsl_type *type)
5759 {
5760 ir_variable *N = in_var(type, "N");
5761 ir_variable *I = in_var(type, "I");
5762 ir_variable *Nref = in_var(type, "Nref");
5763 MAKE_SIG(type, avail, 3, N, I, Nref);
5764
5765 body.emit(if_tree(less(dot(Nref, I), IMM_FP(type, 0.0)),
5766 ret(N), ret(neg(N))));
5767
5768 return sig;
5769 }
5770
5771 ir_function_signature *
5772 builtin_builder::_reflect(builtin_available_predicate avail, const glsl_type *type)
5773 {
5774 ir_variable *I = in_var(type, "I");
5775 ir_variable *N = in_var(type, "N");
5776 MAKE_SIG(type, avail, 2, I, N);
5777
5778 /* I - 2 * dot(N, I) * N */
5779 body.emit(ret(sub(I, mul(IMM_FP(type, 2.0), mul(dot(N, I), N)))));
5780
5781 return sig;
5782 }
5783
5784 ir_function_signature *
5785 builtin_builder::_refract(builtin_available_predicate avail, const glsl_type *type)
5786 {
5787 ir_variable *I = in_var(type, "I");
5788 ir_variable *N = in_var(type, "N");
5789 ir_variable *eta = in_var(type->get_base_type(), "eta");
5790 MAKE_SIG(type, avail, 3, I, N, eta);
5791
5792 ir_variable *n_dot_i = body.make_temp(type->get_base_type(), "n_dot_i");
5793 body.emit(assign(n_dot_i, dot(N, I)));
5794
5795 /* From the GLSL 1.10 specification:
5796 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
5797 * if (k < 0.0)
5798 * return genType(0.0)
5799 * else
5800 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
5801 */
5802 ir_variable *k = body.make_temp(type->get_base_type(), "k");
5803 body.emit(assign(k, sub(IMM_FP(type, 1.0),
5804 mul(eta, mul(eta, sub(IMM_FP(type, 1.0),
5805 mul(n_dot_i, n_dot_i)))))));
5806 body.emit(if_tree(less(k, IMM_FP(type, 0.0)),
5807 ret(ir_constant::zero(mem_ctx, type)),
5808 ret(sub(mul(eta, I),
5809 mul(add(mul(eta, n_dot_i), sqrt(k)), N)))));
5810
5811 return sig;
5812 }
5813
5814 ir_function_signature *
5815 builtin_builder::_matrixCompMult(builtin_available_predicate avail, const glsl_type *type)
5816 {
5817 ir_variable *x = in_var(type, "x");
5818 ir_variable *y = in_var(type, "y");
5819 MAKE_SIG(type, avail, 2, x, y);
5820
5821 ir_variable *z = body.make_temp(type, "z");
5822 for (int i = 0; i < type->matrix_columns; i++) {
5823 body.emit(assign(array_ref(z, i), mul(array_ref(x, i), array_ref(y, i))));
5824 }
5825 body.emit(ret(z));
5826
5827 return sig;
5828 }
5829
5830 ir_function_signature *
5831 builtin_builder::_outerProduct(builtin_available_predicate avail, const glsl_type *type)
5832 {
5833 ir_variable *c;
5834 ir_variable *r;
5835
5836 if (type->is_double()) {
5837 r = in_var(glsl_type::dvec(type->matrix_columns), "r");
5838 c = in_var(glsl_type::dvec(type->vector_elements), "c");
5839 } else {
5840 r = in_var(glsl_type::vec(type->matrix_columns), "r");
5841 c = in_var(glsl_type::vec(type->vector_elements), "c");
5842 }
5843 MAKE_SIG(type, avail, 2, c, r);
5844
5845 ir_variable *m = body.make_temp(type, "m");
5846 for (int i = 0; i < type->matrix_columns; i++) {
5847 body.emit(assign(array_ref(m, i), mul(c, swizzle(r, i, 1))));
5848 }
5849 body.emit(ret(m));
5850
5851 return sig;
5852 }
5853
5854 ir_function_signature *
5855 builtin_builder::_transpose(builtin_available_predicate avail, const glsl_type *orig_type)
5856 {
5857 const glsl_type *transpose_type =
5858 glsl_type::get_instance(orig_type->base_type,
5859 orig_type->matrix_columns,
5860 orig_type->vector_elements);
5861
5862 ir_variable *m = in_var(orig_type, "m");
5863 MAKE_SIG(transpose_type, avail, 1, m);
5864
5865 ir_variable *t = body.make_temp(transpose_type, "t");
5866 for (int i = 0; i < orig_type->matrix_columns; i++) {
5867 for (int j = 0; j < orig_type->vector_elements; j++) {
5868 body.emit(assign(array_ref(t, j),
5869 matrix_elt(m, i, j),
5870 1 << i));
5871 }
5872 }
5873 body.emit(ret(t));
5874
5875 return sig;
5876 }
5877
5878 ir_function_signature *
5879 builtin_builder::_determinant_mat2(builtin_available_predicate avail, const glsl_type *type)
5880 {
5881 ir_variable *m = in_var(type, "m");
5882 MAKE_SIG(type->get_base_type(), avail, 1, m);
5883
5884 body.emit(ret(sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 1, 1)),
5885 mul(matrix_elt(m, 1, 0), matrix_elt(m, 0, 1)))));
5886
5887 return sig;
5888 }
5889
5890 ir_function_signature *
5891 builtin_builder::_determinant_mat3(builtin_available_predicate avail, const glsl_type *type)
5892 {
5893 ir_variable *m = in_var(type, "m");
5894 MAKE_SIG(type->get_base_type(), avail, 1, m);
5895
5896 ir_expression *f1 =
5897 sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 2)),
5898 mul(matrix_elt(m, 1, 2), matrix_elt(m, 2, 1)));
5899
5900 ir_expression *f2 =
5901 sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 2)),
5902 mul(matrix_elt(m, 1, 2), matrix_elt(m, 2, 0)));
5903
5904 ir_expression *f3 =
5905 sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 1)),
5906 mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 0)));
5907
5908 body.emit(ret(add(sub(mul(matrix_elt(m, 0, 0), f1),
5909 mul(matrix_elt(m, 0, 1), f2)),
5910 mul(matrix_elt(m, 0, 2), f3))));
5911
5912 return sig;
5913 }
5914
5915 ir_function_signature *
5916 builtin_builder::_determinant_mat4(builtin_available_predicate avail, const glsl_type *type)
5917 {
5918 ir_variable *m = in_var(type, "m");
5919 const glsl_type *btype = type->get_base_type();
5920 MAKE_SIG(btype, avail, 1, m);
5921
5922 ir_variable *SubFactor00 = body.make_temp(btype, "SubFactor00");
5923 ir_variable *SubFactor01 = body.make_temp(btype, "SubFactor01");
5924 ir_variable *SubFactor02 = body.make_temp(btype, "SubFactor02");
5925 ir_variable *SubFactor03 = body.make_temp(btype, "SubFactor03");
5926 ir_variable *SubFactor04 = body.make_temp(btype, "SubFactor04");
5927 ir_variable *SubFactor05 = body.make_temp(btype, "SubFactor05");
5928 ir_variable *SubFactor06 = body.make_temp(btype, "SubFactor06");
5929 ir_variable *SubFactor07 = body.make_temp(btype, "SubFactor07");
5930 ir_variable *SubFactor08 = body.make_temp(btype, "SubFactor08");
5931 ir_variable *SubFactor09 = body.make_temp(btype, "SubFactor09");
5932 ir_variable *SubFactor10 = body.make_temp(btype, "SubFactor10");
5933 ir_variable *SubFactor11 = body.make_temp(btype, "SubFactor11");
5934 ir_variable *SubFactor12 = body.make_temp(btype, "SubFactor12");
5935 ir_variable *SubFactor13 = body.make_temp(btype, "SubFactor13");
5936 ir_variable *SubFactor14 = body.make_temp(btype, "SubFactor14");
5937 ir_variable *SubFactor15 = body.make_temp(btype, "SubFactor15");
5938 ir_variable *SubFactor16 = body.make_temp(btype, "SubFactor16");
5939 ir_variable *SubFactor17 = body.make_temp(btype, "SubFactor17");
5940 ir_variable *SubFactor18 = body.make_temp(btype, "SubFactor18");
5941
5942 body.emit(assign(SubFactor00, sub(mul(matrix_elt(m, 2, 2), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 2), matrix_elt(m, 2, 3)))));
5943 body.emit(assign(SubFactor01, sub(mul(matrix_elt(m, 2, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 2, 3)))));
5944 body.emit(assign(SubFactor02, sub(mul(matrix_elt(m, 2, 1), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 2, 2)))));
5945 body.emit(assign(SubFactor03, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 3)))));
5946 body.emit(assign(SubFactor04, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 2)))));
5947 body.emit(assign(SubFactor05, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 1)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 1)))));
5948 body.emit(assign(SubFactor06, sub(mul(matrix_elt(m, 1, 2), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 2), matrix_elt(m, 1, 3)))));
5949 body.emit(assign(SubFactor07, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 3)))));
5950 body.emit(assign(SubFactor08, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 2)))));
5951 body.emit(assign(SubFactor09, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 3)))));
5952 body.emit(assign(SubFactor10, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 2)))));
5953 body.emit(assign(SubFactor11, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 3)))));
5954 body.emit(assign(SubFactor12, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 1)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 1)))));
5955 body.emit(assign(SubFactor13, sub(mul(matrix_elt(m, 1, 2), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 2), matrix_elt(m, 1, 3)))));
5956 body.emit(assign(SubFactor14, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 1), matrix_elt(m, 1, 3)))));
5957 body.emit(assign(SubFactor15, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 2)), mul(matrix_elt(m, 2, 1), matrix_elt(m, 1, 2)))));
5958 body.emit(assign(SubFactor16, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 3)))));
5959 body.emit(assign(SubFactor17, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 2)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 2)))));
5960 body.emit(assign(SubFactor18, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 1)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 1)))));
5961
5962 ir_variable *adj_0 = body.make_temp(btype == glsl_type::float_type ? glsl_type::vec4_type : glsl_type::dvec4_type, "adj_0");
5963
5964 body.emit(assign(adj_0,
5965 add(sub(mul(matrix_elt(m, 1, 1), SubFactor00),
5966 mul(matrix_elt(m, 1, 2), SubFactor01)),
5967 mul(matrix_elt(m, 1, 3), SubFactor02)),
5968 WRITEMASK_X));
5969 body.emit(assign(adj_0, neg(
5970 add(sub(mul(matrix_elt(m, 1, 0), SubFactor00),
5971 mul(matrix_elt(m, 1, 2), SubFactor03)),
5972 mul(matrix_elt(m, 1, 3), SubFactor04))),
5973 WRITEMASK_Y));
5974 body.emit(assign(adj_0,
5975 add(sub(mul(matrix_elt(m, 1, 0), SubFactor01),
5976 mul(matrix_elt(m, 1, 1), SubFactor03)),
5977 mul(matrix_elt(m, 1, 3), SubFactor05)),
5978 WRITEMASK_Z));
5979 body.emit(assign(adj_0, neg(
5980 add(sub(mul(matrix_elt(m, 1, 0), SubFactor02),
5981 mul(matrix_elt(m, 1, 1), SubFactor04)),
5982 mul(matrix_elt(m, 1, 2), SubFactor05))),
5983 WRITEMASK_W));
5984
5985 body.emit(ret(dot(array_ref(m, 0), adj_0)));
5986
5987 return sig;
5988 }
5989
5990 ir_function_signature *
5991 builtin_builder::_inverse_mat2(builtin_available_predicate avail, const glsl_type *type)
5992 {
5993 ir_variable *m = in_var(type, "m");
5994 MAKE_SIG(type, avail, 1, m);
5995
5996 ir_variable *adj = body.make_temp(type, "adj");
5997 body.emit(assign(array_ref(adj, 0), matrix_elt(m, 1, 1), 1 << 0));
5998 body.emit(assign(array_ref(adj, 0), neg(matrix_elt(m, 0, 1)), 1 << 1));
5999 body.emit(assign(array_ref(adj, 1), neg(matrix_elt(m, 1, 0)), 1 << 0));
6000 body.emit(assign(array_ref(adj, 1), matrix_elt(m, 0, 0), 1 << 1));
6001
6002 ir_expression *det =
6003 sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 1, 1)),
6004 mul(matrix_elt(m, 1, 0), matrix_elt(m, 0, 1)));
6005
6006 body.emit(ret(div(adj, det)));
6007 return sig;
6008 }
6009
6010 ir_function_signature *
6011 builtin_builder::_inverse_mat3(builtin_available_predicate avail, const glsl_type *type)
6012 {
6013 ir_variable *m = in_var(type, "m");
6014 const glsl_type *btype = type->get_base_type();
6015 MAKE_SIG(type, avail, 1, m);
6016
6017 ir_variable *f11_22_21_12 = body.make_temp(btype, "f11_22_21_12");
6018 ir_variable *f10_22_20_12 = body.make_temp(btype, "f10_22_20_12");
6019 ir_variable *f10_21_20_11 = body.make_temp(btype, "f10_21_20_11");
6020
6021 body.emit(assign(f11_22_21_12,
6022 sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 2)),
6023 mul(matrix_elt(m, 2, 1), matrix_elt(m, 1, 2)))));
6024 body.emit(assign(f10_22_20_12,
6025 sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 2)),
6026 mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 2)))));
6027 body.emit(assign(f10_21_20_11,
6028 sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 1)),
6029 mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 1)))));
6030
6031 ir_variable *adj = body.make_temp(type, "adj");
6032 body.emit(assign(array_ref(adj, 0), f11_22_21_12, WRITEMASK_X));
6033 body.emit(assign(array_ref(adj, 1), neg(f10_22_20_12), WRITEMASK_X));
6034 body.emit(assign(array_ref(adj, 2), f10_21_20_11, WRITEMASK_X));
6035
6036 body.emit(assign(array_ref(adj, 0), neg(
6037 sub(mul(matrix_elt(m, 0, 1), matrix_elt(m, 2, 2)),
6038 mul(matrix_elt(m, 2, 1), matrix_elt(m, 0, 2)))),
6039 WRITEMASK_Y));
6040 body.emit(assign(array_ref(adj, 1),
6041 sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 2, 2)),
6042 mul(matrix_elt(m, 2, 0), matrix_elt(m, 0, 2))),
6043 WRITEMASK_Y));
6044 body.emit(assign(array_ref(adj, 2), neg(
6045 sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 2, 1)),
6046 mul(matrix_elt(m, 2, 0), matrix_elt(m, 0, 1)))),
6047 WRITEMASK_Y));
6048
6049 body.emit(assign(array_ref(adj, 0),
6050 sub(mul(matrix_elt(m, 0, 1), matrix_elt(m, 1, 2)),
6051 mul(matrix_elt(m, 1, 1), matrix_elt(m, 0, 2))),
6052 WRITEMASK_Z));
6053 body.emit(assign(array_ref(adj, 1), neg(
6054 sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 1, 2)),
6055 mul(matrix_elt(m, 1, 0), matrix_elt(m, 0, 2)))),
6056 WRITEMASK_Z));
6057 body.emit(assign(array_ref(adj, 2),
6058 sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 1, 1)),
6059 mul(matrix_elt(m, 1, 0), matrix_elt(m, 0, 1))),
6060 WRITEMASK_Z));
6061
6062 ir_expression *det =
6063 add(sub(mul(matrix_elt(m, 0, 0), f11_22_21_12),
6064 mul(matrix_elt(m, 0, 1), f10_22_20_12)),
6065 mul(matrix_elt(m, 0, 2), f10_21_20_11));
6066
6067 body.emit(ret(div(adj, det)));
6068
6069 return sig;
6070 }
6071
6072 ir_function_signature *
6073 builtin_builder::_inverse_mat4(builtin_available_predicate avail, const glsl_type *type)
6074 {
6075 ir_variable *m = in_var(type, "m");
6076 const glsl_type *btype = type->get_base_type();
6077 MAKE_SIG(type, avail, 1, m);
6078
6079 ir_variable *SubFactor00 = body.make_temp(btype, "SubFactor00");
6080 ir_variable *SubFactor01 = body.make_temp(btype, "SubFactor01");
6081 ir_variable *SubFactor02 = body.make_temp(btype, "SubFactor02");
6082 ir_variable *SubFactor03 = body.make_temp(btype, "SubFactor03");
6083 ir_variable *SubFactor04 = body.make_temp(btype, "SubFactor04");
6084 ir_variable *SubFactor05 = body.make_temp(btype, "SubFactor05");
6085 ir_variable *SubFactor06 = body.make_temp(btype, "SubFactor06");
6086 ir_variable *SubFactor07 = body.make_temp(btype, "SubFactor07");
6087 ir_variable *SubFactor08 = body.make_temp(btype, "SubFactor08");
6088 ir_variable *SubFactor09 = body.make_temp(btype, "SubFactor09");
6089 ir_variable *SubFactor10 = body.make_temp(btype, "SubFactor10");
6090 ir_variable *SubFactor11 = body.make_temp(btype, "SubFactor11");
6091 ir_variable *SubFactor12 = body.make_temp(btype, "SubFactor12");
6092 ir_variable *SubFactor13 = body.make_temp(btype, "SubFactor13");
6093 ir_variable *SubFactor14 = body.make_temp(btype, "SubFactor14");
6094 ir_variable *SubFactor15 = body.make_temp(btype, "SubFactor15");
6095 ir_variable *SubFactor16 = body.make_temp(btype, "SubFactor16");
6096 ir_variable *SubFactor17 = body.make_temp(btype, "SubFactor17");
6097 ir_variable *SubFactor18 = body.make_temp(btype, "SubFactor18");
6098
6099 body.emit(assign(SubFactor00, sub(mul(matrix_elt(m, 2, 2), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 2), matrix_elt(m, 2, 3)))));
6100 body.emit(assign(SubFactor01, sub(mul(matrix_elt(m, 2, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 2, 3)))));
6101 body.emit(assign(SubFactor02, sub(mul(matrix_elt(m, 2, 1), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 2, 2)))));
6102 body.emit(assign(SubFactor03, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 3)))));
6103 body.emit(assign(SubFactor04, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 2)))));
6104 body.emit(assign(SubFactor05, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 1)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 1)))));
6105 body.emit(assign(SubFactor06, sub(mul(matrix_elt(m, 1, 2), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 2), matrix_elt(m, 1, 3)))));
6106 body.emit(assign(SubFactor07, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 3)))));
6107 body.emit(assign(SubFactor08, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 2)))));
6108 body.emit(assign(SubFactor09, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 3)))));
6109 body.emit(assign(SubFactor10, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 2)))));
6110 body.emit(assign(SubFactor11, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 3)))));
6111 body.emit(assign(SubFactor12, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 1)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 1)))));
6112 body.emit(assign(SubFactor13, sub(mul(matrix_elt(m, 1, 2), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 2), matrix_elt(m, 1, 3)))));
6113 body.emit(assign(SubFactor14, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 1), matrix_elt(m, 1, 3)))));
6114 body.emit(assign(SubFactor15, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 2)), mul(matrix_elt(m, 2, 1), matrix_elt(m, 1, 2)))));
6115 body.emit(assign(SubFactor16, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 3)))));
6116 body.emit(assign(SubFactor17, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 2)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 2)))));
6117 body.emit(assign(SubFactor18, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 1)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 1)))));
6118
6119 ir_variable *adj = body.make_temp(btype == glsl_type::float_type ? glsl_type::mat4_type : glsl_type::dmat4_type, "adj");
6120 body.emit(assign(array_ref(adj, 0),
6121 add(sub(mul(matrix_elt(m, 1, 1), SubFactor00),
6122 mul(matrix_elt(m, 1, 2), SubFactor01)),
6123 mul(matrix_elt(m, 1, 3), SubFactor02)),
6124 WRITEMASK_X));
6125 body.emit(assign(array_ref(adj, 1), neg(
6126 add(sub(mul(matrix_elt(m, 1, 0), SubFactor00),
6127 mul(matrix_elt(m, 1, 2), SubFactor03)),
6128 mul(matrix_elt(m, 1, 3), SubFactor04))),
6129 WRITEMASK_X));
6130 body.emit(assign(array_ref(adj, 2),
6131 add(sub(mul(matrix_elt(m, 1, 0), SubFactor01),
6132 mul(matrix_elt(m, 1, 1), SubFactor03)),
6133 mul(matrix_elt(m, 1, 3), SubFactor05)),
6134 WRITEMASK_X));
6135 body.emit(assign(array_ref(adj, 3), neg(
6136 add(sub(mul(matrix_elt(m, 1, 0), SubFactor02),
6137 mul(matrix_elt(m, 1, 1), SubFactor04)),
6138 mul(matrix_elt(m, 1, 2), SubFactor05))),
6139 WRITEMASK_X));
6140
6141 body.emit(assign(array_ref(adj, 0), neg(
6142 add(sub(mul(matrix_elt(m, 0, 1), SubFactor00),
6143 mul(matrix_elt(m, 0, 2), SubFactor01)),
6144 mul(matrix_elt(m, 0, 3), SubFactor02))),
6145 WRITEMASK_Y));
6146 body.emit(assign(array_ref(adj, 1),
6147 add(sub(mul(matrix_elt(m, 0, 0), SubFactor00),
6148 mul(matrix_elt(m, 0, 2), SubFactor03)),
6149 mul(matrix_elt(m, 0, 3), SubFactor04)),
6150 WRITEMASK_Y));
6151 body.emit(assign(array_ref(adj, 2), neg(
6152 add(sub(mul(matrix_elt(m, 0, 0), SubFactor01),
6153 mul(matrix_elt(m, 0, 1), SubFactor03)),
6154 mul(matrix_elt(m, 0, 3), SubFactor05))),
6155 WRITEMASK_Y));
6156 body.emit(assign(array_ref(adj, 3),
6157 add(sub(mul(matrix_elt(m, 0, 0), SubFactor02),
6158 mul(matrix_elt(m, 0, 1), SubFactor04)),
6159 mul(matrix_elt(m, 0, 2), SubFactor05)),
6160 WRITEMASK_Y));
6161
6162 body.emit(assign(array_ref(adj, 0),
6163 add(sub(mul(matrix_elt(m, 0, 1), SubFactor06),
6164 mul(matrix_elt(m, 0, 2), SubFactor07)),
6165 mul(matrix_elt(m, 0, 3), SubFactor08)),
6166 WRITEMASK_Z));
6167 body.emit(assign(array_ref(adj, 1), neg(
6168 add(sub(mul(matrix_elt(m, 0, 0), SubFactor06),
6169 mul(matrix_elt(m, 0, 2), SubFactor09)),
6170 mul(matrix_elt(m, 0, 3), SubFactor10))),
6171 WRITEMASK_Z));
6172 body.emit(assign(array_ref(adj, 2),
6173 add(sub(mul(matrix_elt(m, 0, 0), SubFactor11),
6174 mul(matrix_elt(m, 0, 1), SubFactor09)),
6175 mul(matrix_elt(m, 0, 3), SubFactor12)),
6176 WRITEMASK_Z));
6177 body.emit(assign(array_ref(adj, 3), neg(
6178 add(sub(mul(matrix_elt(m, 0, 0), SubFactor08),
6179 mul(matrix_elt(m, 0, 1), SubFactor10)),
6180 mul(matrix_elt(m, 0, 2), SubFactor12))),
6181 WRITEMASK_Z));
6182
6183 body.emit(assign(array_ref(adj, 0), neg(
6184 add(sub(mul(matrix_elt(m, 0, 1), SubFactor13),
6185 mul(matrix_elt(m, 0, 2), SubFactor14)),
6186 mul(matrix_elt(m, 0, 3), SubFactor15))),
6187 WRITEMASK_W));
6188 body.emit(assign(array_ref(adj, 1),
6189 add(sub(mul(matrix_elt(m, 0, 0), SubFactor13),
6190 mul(matrix_elt(m, 0, 2), SubFactor16)),
6191 mul(matrix_elt(m, 0, 3), SubFactor17)),
6192 WRITEMASK_W));
6193 body.emit(assign(array_ref(adj, 2), neg(
6194 add(sub(mul(matrix_elt(m, 0, 0), SubFactor14),
6195 mul(matrix_elt(m, 0, 1), SubFactor16)),
6196 mul(matrix_elt(m, 0, 3), SubFactor18))),
6197 WRITEMASK_W));
6198 body.emit(assign(array_ref(adj, 3),
6199 add(sub(mul(matrix_elt(m, 0, 0), SubFactor15),
6200 mul(matrix_elt(m, 0, 1), SubFactor17)),
6201 mul(matrix_elt(m, 0, 2), SubFactor18)),
6202 WRITEMASK_W));
6203
6204 ir_expression *det =
6205 add(mul(matrix_elt(m, 0, 0), matrix_elt(adj, 0, 0)),
6206 add(mul(matrix_elt(m, 0, 1), matrix_elt(adj, 1, 0)),
6207 add(mul(matrix_elt(m, 0, 2), matrix_elt(adj, 2, 0)),
6208 mul(matrix_elt(m, 0, 3), matrix_elt(adj, 3, 0)))));
6209
6210 body.emit(ret(div(adj, det)));
6211
6212 return sig;
6213 }
6214
6215
6216 ir_function_signature *
6217 builtin_builder::_lessThan(builtin_available_predicate avail,
6218 const glsl_type *type)
6219 {
6220 return binop(avail, ir_binop_less,
6221 glsl_type::bvec(type->vector_elements), type, type);
6222 }
6223
6224 ir_function_signature *
6225 builtin_builder::_lessThanEqual(builtin_available_predicate avail,
6226 const glsl_type *type)
6227 {
6228 return binop(avail, ir_binop_gequal,
6229 glsl_type::bvec(type->vector_elements), type, type,
6230 true);
6231 }
6232
6233 ir_function_signature *
6234 builtin_builder::_greaterThan(builtin_available_predicate avail,
6235 const glsl_type *type)
6236 {
6237 return binop(avail, ir_binop_less,
6238 glsl_type::bvec(type->vector_elements), type, type,
6239 true);
6240 }
6241
6242 ir_function_signature *
6243 builtin_builder::_greaterThanEqual(builtin_available_predicate avail,
6244 const glsl_type *type)
6245 {
6246 return binop(avail, ir_binop_gequal,
6247 glsl_type::bvec(type->vector_elements), type, type);
6248 }
6249
6250 ir_function_signature *
6251 builtin_builder::_equal(builtin_available_predicate avail,
6252 const glsl_type *type)
6253 {
6254 return binop(avail, ir_binop_equal,
6255 glsl_type::bvec(type->vector_elements), type, type);
6256 }
6257
6258 ir_function_signature *
6259 builtin_builder::_notEqual(builtin_available_predicate avail,
6260 const glsl_type *type)
6261 {
6262 return binop(avail, ir_binop_nequal,
6263 glsl_type::bvec(type->vector_elements), type, type);
6264 }
6265
6266 ir_function_signature *
6267 builtin_builder::_any(const glsl_type *type)
6268 {
6269 ir_variable *v = in_var(type, "v");
6270 MAKE_SIG(glsl_type::bool_type, always_available, 1, v);
6271
6272 const unsigned vec_elem = v->type->vector_elements;
6273 body.emit(ret(expr(ir_binop_any_nequal, v, imm(false, vec_elem))));
6274
6275 return sig;
6276 }
6277
6278 ir_function_signature *
6279 builtin_builder::_all(const glsl_type *type)
6280 {
6281 ir_variable *v = in_var(type, "v");
6282 MAKE_SIG(glsl_type::bool_type, always_available, 1, v);
6283
6284 const unsigned vec_elem = v->type->vector_elements;
6285 body.emit(ret(expr(ir_binop_all_equal, v, imm(true, vec_elem))));
6286
6287 return sig;
6288 }
6289
6290 UNOP(not, ir_unop_logic_not, always_available)
6291
6292 static bool
6293 has_lod(const glsl_type *sampler_type)
6294 {
6295 assert(sampler_type->is_sampler());
6296
6297 switch (sampler_type->sampler_dimensionality) {
6298 case GLSL_SAMPLER_DIM_RECT:
6299 case GLSL_SAMPLER_DIM_BUF:
6300 case GLSL_SAMPLER_DIM_MS:
6301 return false;
6302 default:
6303 return true;
6304 }
6305 }
6306
6307 ir_function_signature *
6308 builtin_builder::_textureSize(builtin_available_predicate avail,
6309 const glsl_type *return_type,
6310 const glsl_type *sampler_type)
6311 {
6312 ir_variable *s = in_var(sampler_type, "sampler");
6313 /* The sampler always exists; add optional lod later. */
6314 MAKE_SIG(return_type, avail, 1, s);
6315
6316 ir_texture *tex = new(mem_ctx) ir_texture(ir_txs);
6317 tex->set_sampler(new(mem_ctx) ir_dereference_variable(s), return_type);
6318
6319 if (has_lod(sampler_type)) {
6320 ir_variable *lod = in_var(glsl_type::int_type, "lod");
6321 sig->parameters.push_tail(lod);
6322 tex->lod_info.lod = var_ref(lod);
6323 } else {
6324 tex->lod_info.lod = imm(0u);
6325 }
6326
6327 body.emit(ret(tex));
6328
6329 return sig;
6330 }
6331
6332 ir_function_signature *
6333 builtin_builder::_textureSamples(builtin_available_predicate avail,
6334 const glsl_type *sampler_type)
6335 {
6336 ir_variable *s = in_var(sampler_type, "sampler");
6337 MAKE_SIG(glsl_type::int_type, avail, 1, s);
6338
6339 ir_texture *tex = new(mem_ctx) ir_texture(ir_texture_samples);
6340 tex->set_sampler(new(mem_ctx) ir_dereference_variable(s), glsl_type::int_type);
6341 body.emit(ret(tex));
6342
6343 return sig;
6344 }
6345
6346 ir_function_signature *
6347 builtin_builder::_texture(ir_texture_opcode opcode,
6348 builtin_available_predicate avail,
6349 const glsl_type *return_type,
6350 const glsl_type *sampler_type,
6351 const glsl_type *coord_type,
6352 int flags)
6353 {
6354 ir_variable *s = in_var(sampler_type, "sampler");
6355 ir_variable *P = in_var(coord_type, "P");
6356 /* The sampler and coordinate always exist; add optional parameters later. */
6357 MAKE_SIG(return_type, avail, 2, s, P);
6358
6359 ir_texture *tex = new(mem_ctx) ir_texture(opcode);
6360 tex->set_sampler(var_ref(s), return_type);
6361
6362 const int coord_size = sampler_type->coordinate_components();
6363
6364 if (coord_size == coord_type->vector_elements) {
6365 tex->coordinate = var_ref(P);
6366 } else {
6367 /* The incoming coordinate also has the projector or shadow comparator,
6368 * so we need to swizzle those away.
6369 */
6370 tex->coordinate = swizzle_for_size(P, coord_size);
6371 }
6372
6373 /* The projector is always in the last component. */
6374 if (flags & TEX_PROJECT)
6375 tex->projector = swizzle(P, coord_type->vector_elements - 1, 1);
6376
6377 if (sampler_type->sampler_shadow) {
6378 if (opcode == ir_tg4) {
6379 /* gather has refz as a separate parameter, immediately after the
6380 * coordinate
6381 */
6382 ir_variable *refz = in_var(glsl_type::float_type, "refz");
6383 sig->parameters.push_tail(refz);
6384 tex->shadow_comparator = var_ref(refz);
6385 } else {
6386 /* The shadow comparator is normally in the Z component, but a few types
6387 * have sufficiently large coordinates that it's in W.
6388 */
6389 tex->shadow_comparator = swizzle(P, MAX2(coord_size, SWIZZLE_Z), 1);
6390 }
6391 }
6392
6393 if (opcode == ir_txl) {
6394 ir_variable *lod = in_var(glsl_type::float_type, "lod");
6395 sig->parameters.push_tail(lod);
6396 tex->lod_info.lod = var_ref(lod);
6397 } else if (opcode == ir_txd) {
6398 int grad_size = coord_size - (sampler_type->sampler_array ? 1 : 0);
6399 ir_variable *dPdx = in_var(glsl_type::vec(grad_size), "dPdx");
6400 ir_variable *dPdy = in_var(glsl_type::vec(grad_size), "dPdy");
6401 sig->parameters.push_tail(dPdx);
6402 sig->parameters.push_tail(dPdy);
6403 tex->lod_info.grad.dPdx = var_ref(dPdx);
6404 tex->lod_info.grad.dPdy = var_ref(dPdy);
6405 }
6406
6407 if (flags & (TEX_OFFSET | TEX_OFFSET_NONCONST)) {
6408 int offset_size = coord_size - (sampler_type->sampler_array ? 1 : 0);
6409 ir_variable *offset =
6410 new(mem_ctx) ir_variable(glsl_type::ivec(offset_size), "offset",
6411 (flags & TEX_OFFSET) ? ir_var_const_in : ir_var_function_in);
6412 sig->parameters.push_tail(offset);
6413 tex->offset = var_ref(offset);
6414 }
6415
6416 if (flags & TEX_OFFSET_ARRAY) {
6417 ir_variable *offsets =
6418 new(mem_ctx) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type, 4),
6419 "offsets", ir_var_const_in);
6420 sig->parameters.push_tail(offsets);
6421 tex->offset = var_ref(offsets);
6422 }
6423
6424 if (opcode == ir_tg4) {
6425 if (flags & TEX_COMPONENT) {
6426 ir_variable *component =
6427 new(mem_ctx) ir_variable(glsl_type::int_type, "comp", ir_var_const_in);
6428 sig->parameters.push_tail(component);
6429 tex->lod_info.component = var_ref(component);
6430 }
6431 else {
6432 tex->lod_info.component = imm(0);
6433 }
6434 }
6435
6436 /* The "bias" parameter comes /after/ the "offset" parameter, which is
6437 * inconsistent with both textureLodOffset and textureGradOffset.
6438 */
6439 if (opcode == ir_txb) {
6440 ir_variable *bias = in_var(glsl_type::float_type, "bias");
6441 sig->parameters.push_tail(bias);
6442 tex->lod_info.bias = var_ref(bias);
6443 }
6444
6445 body.emit(ret(tex));
6446
6447 return sig;
6448 }
6449
6450 ir_function_signature *
6451 builtin_builder::_textureCubeArrayShadow(ir_texture_opcode opcode,
6452 builtin_available_predicate avail,
6453 const glsl_type *sampler_type)
6454 {
6455 ir_variable *s = in_var(sampler_type, "sampler");
6456 ir_variable *P = in_var(glsl_type::vec4_type, "P");
6457 ir_variable *compare = in_var(glsl_type::float_type, "compare");
6458 MAKE_SIG(glsl_type::float_type, avail, 3, s, P, compare);
6459
6460 ir_texture *tex = new(mem_ctx) ir_texture(opcode);
6461 tex->set_sampler(var_ref(s), glsl_type::float_type);
6462
6463 tex->coordinate = var_ref(P);
6464 tex->shadow_comparator = var_ref(compare);
6465
6466 if (opcode == ir_txb) {
6467 ir_variable *bias = in_var(glsl_type::float_type, "bias");
6468 sig->parameters.push_tail(bias);
6469 tex->lod_info.bias = var_ref(bias);
6470 }
6471
6472 if (opcode == ir_txl) {
6473 ir_variable *lod = in_var(glsl_type::float_type, "lod");
6474 sig->parameters.push_tail(lod);
6475 tex->lod_info.lod = var_ref(lod);
6476 }
6477
6478 body.emit(ret(tex));
6479
6480 return sig;
6481 }
6482
6483 ir_function_signature *
6484 builtin_builder::_texelFetch(builtin_available_predicate avail,
6485 const glsl_type *return_type,
6486 const glsl_type *sampler_type,
6487 const glsl_type *coord_type,
6488 const glsl_type *offset_type)
6489 {
6490 ir_variable *s = in_var(sampler_type, "sampler");
6491 ir_variable *P = in_var(coord_type, "P");
6492 /* The sampler and coordinate always exist; add optional parameters later. */
6493 MAKE_SIG(return_type, avail, 2, s, P);
6494
6495 ir_texture *tex = new(mem_ctx) ir_texture(ir_txf);
6496 tex->coordinate = var_ref(P);
6497 tex->set_sampler(var_ref(s), return_type);
6498
6499 if (sampler_type->sampler_dimensionality == GLSL_SAMPLER_DIM_MS) {
6500 ir_variable *sample = in_var(glsl_type::int_type, "sample");
6501 sig->parameters.push_tail(sample);
6502 tex->lod_info.sample_index = var_ref(sample);
6503 tex->op = ir_txf_ms;
6504 } else if (has_lod(sampler_type)) {
6505 ir_variable *lod = in_var(glsl_type::int_type, "lod");
6506 sig->parameters.push_tail(lod);
6507 tex->lod_info.lod = var_ref(lod);
6508 } else {
6509 tex->lod_info.lod = imm(0u);
6510 }
6511
6512 if (offset_type != NULL) {
6513 ir_variable *offset =
6514 new(mem_ctx) ir_variable(offset_type, "offset", ir_var_const_in);
6515 sig->parameters.push_tail(offset);
6516 tex->offset = var_ref(offset);
6517 }
6518
6519 body.emit(ret(tex));
6520
6521 return sig;
6522 }
6523
6524 ir_function_signature *
6525 builtin_builder::_EmitVertex()
6526 {
6527 MAKE_SIG(glsl_type::void_type, gs_only, 0);
6528
6529 ir_rvalue *stream = new(mem_ctx) ir_constant(0, 1);
6530 body.emit(new(mem_ctx) ir_emit_vertex(stream));
6531
6532 return sig;
6533 }
6534
6535 ir_function_signature *
6536 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail,
6537 const glsl_type *stream_type)
6538 {
6539 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
6540 *
6541 * "Emit the current values of output variables to the current output
6542 * primitive on stream stream. The argument to stream must be a constant
6543 * integral expression."
6544 */
6545 ir_variable *stream =
6546 new(mem_ctx) ir_variable(stream_type, "stream", ir_var_const_in);
6547
6548 MAKE_SIG(glsl_type::void_type, avail, 1, stream);
6549
6550 body.emit(new(mem_ctx) ir_emit_vertex(var_ref(stream)));
6551
6552 return sig;
6553 }
6554
6555 ir_function_signature *
6556 builtin_builder::_EndPrimitive()
6557 {
6558 MAKE_SIG(glsl_type::void_type, gs_only, 0);
6559
6560 ir_rvalue *stream = new(mem_ctx) ir_constant(0, 1);
6561 body.emit(new(mem_ctx) ir_end_primitive(stream));
6562
6563 return sig;
6564 }
6565
6566 ir_function_signature *
6567 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail,
6568 const glsl_type *stream_type)
6569 {
6570 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
6571 *
6572 * "Completes the current output primitive on stream stream and starts
6573 * a new one. The argument to stream must be a constant integral
6574 * expression."
6575 */
6576 ir_variable *stream =
6577 new(mem_ctx) ir_variable(stream_type, "stream", ir_var_const_in);
6578
6579 MAKE_SIG(glsl_type::void_type, avail, 1, stream);
6580
6581 body.emit(new(mem_ctx) ir_end_primitive(var_ref(stream)));
6582
6583 return sig;
6584 }
6585
6586 ir_function_signature *
6587 builtin_builder::_barrier()
6588 {
6589 MAKE_SIG(glsl_type::void_type, barrier_supported, 0);
6590
6591 body.emit(new(mem_ctx) ir_barrier());
6592 return sig;
6593 }
6594
6595 ir_function_signature *
6596 builtin_builder::_textureQueryLod(builtin_available_predicate avail,
6597 const glsl_type *sampler_type,
6598 const glsl_type *coord_type)
6599 {
6600 ir_variable *s = in_var(sampler_type, "sampler");
6601 ir_variable *coord = in_var(coord_type, "coord");
6602 /* The sampler and coordinate always exist; add optional parameters later. */
6603 MAKE_SIG(glsl_type::vec2_type, avail, 2, s, coord);
6604
6605 ir_texture *tex = new(mem_ctx) ir_texture(ir_lod);
6606 tex->coordinate = var_ref(coord);
6607 tex->set_sampler(var_ref(s), glsl_type::vec2_type);
6608
6609 body.emit(ret(tex));
6610
6611 return sig;
6612 }
6613
6614 ir_function_signature *
6615 builtin_builder::_textureQueryLevels(builtin_available_predicate avail,
6616 const glsl_type *sampler_type)
6617 {
6618 ir_variable *s = in_var(sampler_type, "sampler");
6619 const glsl_type *return_type = glsl_type::int_type;
6620 MAKE_SIG(return_type, avail, 1, s);
6621
6622 ir_texture *tex = new(mem_ctx) ir_texture(ir_query_levels);
6623 tex->set_sampler(var_ref(s), return_type);
6624
6625 body.emit(ret(tex));
6626
6627 return sig;
6628 }
6629
6630 ir_function_signature *
6631 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail,
6632 const glsl_type *sampler_type,
6633 const glsl_type *coord_type)
6634 {
6635 ir_variable *s = in_var(sampler_type, "sampler");
6636 ir_variable *P = in_var(coord_type, "P");
6637 const glsl_type *return_type = glsl_type::bool_type;
6638 MAKE_SIG(return_type, avail, 2, s, P);
6639
6640 ir_texture *tex = new(mem_ctx) ir_texture(ir_samples_identical);
6641 tex->coordinate = var_ref(P);
6642 tex->set_sampler(var_ref(s), return_type);
6643
6644 body.emit(ret(tex));
6645
6646 return sig;
6647 }
6648
6649 UNOP(dFdx, ir_unop_dFdx, derivatives)
6650 UNOP(dFdxCoarse, ir_unop_dFdx_coarse, derivative_control)
6651 UNOP(dFdxFine, ir_unop_dFdx_fine, derivative_control)
6652 UNOP(dFdy, ir_unop_dFdy, derivatives)
6653 UNOP(dFdyCoarse, ir_unop_dFdy_coarse, derivative_control)
6654 UNOP(dFdyFine, ir_unop_dFdy_fine, derivative_control)
6655
6656 ir_function_signature *
6657 builtin_builder::_fwidth(const glsl_type *type)
6658 {
6659 ir_variable *p = in_var(type, "p");
6660 MAKE_SIG(type, derivatives, 1, p);
6661
6662 body.emit(ret(add(abs(expr(ir_unop_dFdx, p)), abs(expr(ir_unop_dFdy, p)))));
6663
6664 return sig;
6665 }
6666
6667 ir_function_signature *
6668 builtin_builder::_fwidthCoarse(const glsl_type *type)
6669 {
6670 ir_variable *p = in_var(type, "p");
6671 MAKE_SIG(type, derivative_control, 1, p);
6672
6673 body.emit(ret(add(abs(expr(ir_unop_dFdx_coarse, p)),
6674 abs(expr(ir_unop_dFdy_coarse, p)))));
6675
6676 return sig;
6677 }
6678
6679 ir_function_signature *
6680 builtin_builder::_fwidthFine(const glsl_type *type)
6681 {
6682 ir_variable *p = in_var(type, "p");
6683 MAKE_SIG(type, derivative_control, 1, p);
6684
6685 body.emit(ret(add(abs(expr(ir_unop_dFdx_fine, p)),
6686 abs(expr(ir_unop_dFdy_fine, p)))));
6687
6688 return sig;
6689 }
6690
6691 ir_function_signature *
6692 builtin_builder::_noise1(const glsl_type *type)
6693 {
6694 /* From the GLSL 4.60 specification:
6695 *
6696 * "The noise functions noise1, noise2, noise3, and noise4 have been
6697 * deprecated starting with version 4.4 of GLSL. When not generating
6698 * SPIR-V they are defined to return the value 0.0 or a vector whose
6699 * components are all 0.0. When generating SPIR-V the noise functions
6700 * are not declared and may not be used."
6701 *
6702 * In earlier versions of the GLSL specification attempt to define some
6703 * sort of statistical noise function. However, the function's
6704 * characteristics have always been such that always returning 0 is
6705 * valid and Mesa has always returned 0 for noise on most drivers.
6706 */
6707 ir_variable *p = in_var(type, "p");
6708 MAKE_SIG(glsl_type::float_type, v110, 1, p);
6709 body.emit(ret(imm(glsl_type::float_type, ir_constant_data())));
6710 return sig;
6711 }
6712
6713 ir_function_signature *
6714 builtin_builder::_noise2(const glsl_type *type)
6715 {
6716 /* See builtin_builder::_noise1 */
6717 ir_variable *p = in_var(type, "p");
6718 MAKE_SIG(glsl_type::vec2_type, v110, 1, p);
6719 body.emit(ret(imm(glsl_type::vec2_type, ir_constant_data())));
6720 return sig;
6721 }
6722
6723 ir_function_signature *
6724 builtin_builder::_noise3(const glsl_type *type)
6725 {
6726 /* See builtin_builder::_noise1 */
6727 ir_variable *p = in_var(type, "p");
6728 MAKE_SIG(glsl_type::vec3_type, v110, 1, p);
6729 body.emit(ret(imm(glsl_type::vec3_type, ir_constant_data())));
6730 return sig;
6731 }
6732
6733 ir_function_signature *
6734 builtin_builder::_noise4(const glsl_type *type)
6735 {
6736 /* See builtin_builder::_noise1 */
6737 ir_variable *p = in_var(type, "p");
6738 MAKE_SIG(glsl_type::vec4_type, v110, 1, p);
6739 body.emit(ret(imm(glsl_type::vec4_type, ir_constant_data())));
6740 return sig;
6741 }
6742
6743 ir_function_signature *
6744 builtin_builder::_bitfieldExtract(const glsl_type *type)
6745 {
6746 bool is_uint = type->base_type == GLSL_TYPE_UINT;
6747 ir_variable *value = in_var(type, "value");
6748 ir_variable *offset = in_var(glsl_type::int_type, "offset");
6749 ir_variable *bits = in_var(glsl_type::int_type, "bits");
6750 MAKE_SIG(type, gpu_shader5_or_es31_or_integer_functions, 3, value, offset,
6751 bits);
6752
6753 operand cast_offset = is_uint ? i2u(offset) : operand(offset);
6754 operand cast_bits = is_uint ? i2u(bits) : operand(bits);
6755
6756 body.emit(ret(expr(ir_triop_bitfield_extract, value,
6757 swizzle(cast_offset, SWIZZLE_XXXX, type->vector_elements),
6758 swizzle(cast_bits, SWIZZLE_XXXX, type->vector_elements))));
6759
6760 return sig;
6761 }
6762
6763 ir_function_signature *
6764 builtin_builder::_bitfieldInsert(const glsl_type *type)
6765 {
6766 bool is_uint = type->base_type == GLSL_TYPE_UINT;
6767 ir_variable *base = in_var(type, "base");
6768 ir_variable *insert = in_var(type, "insert");
6769 ir_variable *offset = in_var(glsl_type::int_type, "offset");
6770 ir_variable *bits = in_var(glsl_type::int_type, "bits");
6771 MAKE_SIG(type, gpu_shader5_or_es31_or_integer_functions, 4, base, insert,
6772 offset, bits);
6773
6774 operand cast_offset = is_uint ? i2u(offset) : operand(offset);
6775 operand cast_bits = is_uint ? i2u(bits) : operand(bits);
6776
6777 body.emit(ret(bitfield_insert(base, insert,
6778 swizzle(cast_offset, SWIZZLE_XXXX, type->vector_elements),
6779 swizzle(cast_bits, SWIZZLE_XXXX, type->vector_elements))));
6780
6781 return sig;
6782 }
6783
6784 UNOP(bitfieldReverse, ir_unop_bitfield_reverse, gpu_shader5_or_es31_or_integer_functions)
6785
6786 ir_function_signature *
6787 builtin_builder::_bitCount(const glsl_type *type)
6788 {
6789 return unop(gpu_shader5_or_es31_or_integer_functions, ir_unop_bit_count,
6790 glsl_type::ivec(type->vector_elements), type);
6791 }
6792
6793 ir_function_signature *
6794 builtin_builder::_findLSB(const glsl_type *type)
6795 {
6796 return unop(gpu_shader5_or_es31_or_integer_functions, ir_unop_find_lsb,
6797 glsl_type::ivec(type->vector_elements), type);
6798 }
6799
6800 ir_function_signature *
6801 builtin_builder::_findMSB(const glsl_type *type)
6802 {
6803 return unop(gpu_shader5_or_es31_or_integer_functions, ir_unop_find_msb,
6804 glsl_type::ivec(type->vector_elements), type);
6805 }
6806
6807 ir_function_signature *
6808 builtin_builder::_countLeadingZeros(builtin_available_predicate avail,
6809 const glsl_type *type)
6810 {
6811 return unop(avail, ir_unop_clz,
6812 glsl_type::uvec(type->vector_elements), type);
6813 }
6814
6815 ir_function_signature *
6816 builtin_builder::_countTrailingZeros(builtin_available_predicate avail,
6817 const glsl_type *type)
6818 {
6819 ir_variable *a = in_var(type, "a");
6820 MAKE_SIG(glsl_type::uvec(type->vector_elements), avail, 1, a);
6821
6822 body.emit(ret(ir_builder::min2(
6823 ir_builder::i2u(ir_builder::expr(ir_unop_find_lsb, a)),
6824 imm(32u))));
6825
6826 return sig;
6827 }
6828
6829 ir_function_signature *
6830 builtin_builder::_fma(builtin_available_predicate avail, const glsl_type *type)
6831 {
6832 ir_variable *a = in_var(type, "a");
6833 ir_variable *b = in_var(type, "b");
6834 ir_variable *c = in_var(type, "c");
6835 MAKE_SIG(type, avail, 3, a, b, c);
6836
6837 body.emit(ret(ir_builder::fma(a, b, c)));
6838
6839 return sig;
6840 }
6841
6842 ir_function_signature *
6843 builtin_builder::_ldexp(const glsl_type *x_type, const glsl_type *exp_type)
6844 {
6845 return binop(x_type->is_double() ? fp64 : gpu_shader5_or_es31_or_integer_functions,
6846 ir_binop_ldexp, x_type, x_type, exp_type);
6847 }
6848
6849 ir_function_signature *
6850 builtin_builder::_dfrexp(const glsl_type *x_type, const glsl_type *exp_type)
6851 {
6852 ir_variable *x = in_var(x_type, "x");
6853 ir_variable *exponent = out_var(exp_type, "exp");
6854 MAKE_SIG(x_type, fp64, 2, x, exponent);
6855
6856 body.emit(assign(exponent, expr(ir_unop_frexp_exp, x)));
6857
6858 body.emit(ret(expr(ir_unop_frexp_sig, x)));
6859 return sig;
6860 }
6861
6862 ir_function_signature *
6863 builtin_builder::_frexp(const glsl_type *x_type, const glsl_type *exp_type)
6864 {
6865 ir_variable *x = in_var(x_type, "x");
6866 ir_variable *exponent = out_var(exp_type, "exp");
6867 MAKE_SIG(x_type, gpu_shader5_or_es31_or_integer_functions, 2, x, exponent);
6868
6869 const unsigned vec_elem = x_type->vector_elements;
6870 const glsl_type *bvec = glsl_type::get_instance(GLSL_TYPE_BOOL, vec_elem, 1);
6871 const glsl_type *uvec = glsl_type::get_instance(GLSL_TYPE_UINT, vec_elem, 1);
6872
6873 /* Single-precision floating-point values are stored as
6874 * 1 sign bit;
6875 * 8 exponent bits;
6876 * 23 mantissa bits.
6877 *
6878 * An exponent shift of 23 will shift the mantissa out, leaving only the
6879 * exponent and sign bit (which itself may be zero, if the absolute value
6880 * was taken before the bitcast and shift.
6881 */
6882 ir_constant *exponent_shift = imm(23);
6883 ir_constant *exponent_bias = imm(-126, vec_elem);
6884
6885 ir_constant *sign_mantissa_mask = imm(0x807fffffu, vec_elem);
6886
6887 /* Exponent of floating-point values in the range [0.5, 1.0). */
6888 ir_constant *exponent_value = imm(0x3f000000u, vec_elem);
6889
6890 ir_variable *is_not_zero = body.make_temp(bvec, "is_not_zero");
6891 body.emit(assign(is_not_zero, nequal(abs(x), imm(0.0f, vec_elem))));
6892
6893 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
6894 * to unsigned integers to ensure that 1 bits aren't shifted in.
6895 */
6896 body.emit(assign(exponent, rshift(bitcast_f2i(abs(x)), exponent_shift)));
6897 body.emit(assign(exponent, add(exponent, csel(is_not_zero, exponent_bias,
6898 imm(0, vec_elem)))));
6899
6900 ir_variable *bits = body.make_temp(uvec, "bits");
6901 body.emit(assign(bits, bitcast_f2u(x)));
6902 body.emit(assign(bits, bit_and(bits, sign_mantissa_mask)));
6903 body.emit(assign(bits, bit_or(bits, csel(is_not_zero, exponent_value,
6904 imm(0u, vec_elem)))));
6905 body.emit(ret(bitcast_u2f(bits)));
6906
6907 return sig;
6908 }
6909
6910 ir_function_signature *
6911 builtin_builder::_uaddCarry(const glsl_type *type)
6912 {
6913 ir_variable *x = in_var(type, "x");
6914 ir_variable *y = in_var(type, "y");
6915 ir_variable *carry = out_var(type, "carry");
6916 MAKE_SIG(type, gpu_shader5_or_es31_or_integer_functions, 3, x, y, carry);
6917
6918 body.emit(assign(carry, ir_builder::carry(x, y)));
6919 body.emit(ret(add(x, y)));
6920
6921 return sig;
6922 }
6923
6924 ir_function_signature *
6925 builtin_builder::_addSaturate(builtin_available_predicate avail,
6926 const glsl_type *type)
6927 {
6928 return binop(avail, ir_binop_add_sat, type, type, type);
6929 }
6930
6931 ir_function_signature *
6932 builtin_builder::_usubBorrow(const glsl_type *type)
6933 {
6934 ir_variable *x = in_var(type, "x");
6935 ir_variable *y = in_var(type, "y");
6936 ir_variable *borrow = out_var(type, "borrow");
6937 MAKE_SIG(type, gpu_shader5_or_es31_or_integer_functions, 3, x, y, borrow);
6938
6939 body.emit(assign(borrow, ir_builder::borrow(x, y)));
6940 body.emit(ret(sub(x, y)));
6941
6942 return sig;
6943 }
6944
6945 ir_function_signature *
6946 builtin_builder::_subtractSaturate(builtin_available_predicate avail,
6947 const glsl_type *type)
6948 {
6949 return binop(avail, ir_binop_sub_sat, type, type, type);
6950 }
6951
6952 ir_function_signature *
6953 builtin_builder::_absoluteDifference(builtin_available_predicate avail,
6954 const glsl_type *type)
6955 {
6956 /* absoluteDifference returns an unsigned type that has the same number of
6957 * bits and number of vector elements as the type of the operands.
6958 */
6959 return binop(avail, ir_binop_abs_sub,
6960 glsl_type::get_instance(glsl_unsigned_base_type_of(type->base_type),
6961 type->vector_elements, 1),
6962 type, type);
6963 }
6964
6965 ir_function_signature *
6966 builtin_builder::_average(builtin_available_predicate avail,
6967 const glsl_type *type)
6968 {
6969 return binop(avail, ir_binop_avg, type, type, type);
6970 }
6971
6972 ir_function_signature *
6973 builtin_builder::_averageRounded(builtin_available_predicate avail,
6974 const glsl_type *type)
6975 {
6976 return binop(avail, ir_binop_avg_round, type, type, type);
6977 }
6978
6979 /**
6980 * For both imulExtended() and umulExtended() built-ins.
6981 */
6982 ir_function_signature *
6983 builtin_builder::_mulExtended(const glsl_type *type)
6984 {
6985 const glsl_type *mul_type, *unpack_type;
6986 ir_expression_operation unpack_op;
6987
6988 if (type->base_type == GLSL_TYPE_INT) {
6989 unpack_op = ir_unop_unpack_int_2x32;
6990 mul_type = glsl_type::get_instance(GLSL_TYPE_INT64, type->vector_elements, 1);
6991 unpack_type = glsl_type::ivec2_type;
6992 } else {
6993 unpack_op = ir_unop_unpack_uint_2x32;
6994 mul_type = glsl_type::get_instance(GLSL_TYPE_UINT64, type->vector_elements, 1);
6995 unpack_type = glsl_type::uvec2_type;
6996 }
6997
6998 ir_variable *x = in_var(type, "x");
6999 ir_variable *y = in_var(type, "y");
7000 ir_variable *msb = out_var(type, "msb");
7001 ir_variable *lsb = out_var(type, "lsb");
7002 MAKE_SIG(glsl_type::void_type, gpu_shader5_or_es31_or_integer_functions, 4, x, y, msb, lsb);
7003
7004 ir_variable *unpack_val = body.make_temp(unpack_type, "_unpack_val");
7005
7006 ir_expression *mul_res = new(mem_ctx) ir_expression(ir_binop_mul, mul_type,
7007 new(mem_ctx)ir_dereference_variable(x),
7008 new(mem_ctx)ir_dereference_variable(y));
7009
7010 if (type->vector_elements == 1) {
7011 body.emit(assign(unpack_val, expr(unpack_op, mul_res)));
7012 body.emit(assign(msb, swizzle_y(unpack_val)));
7013 body.emit(assign(lsb, swizzle_x(unpack_val)));
7014 } else {
7015 for (int i = 0; i < type->vector_elements; i++) {
7016 body.emit(assign(unpack_val, expr(unpack_op, swizzle(mul_res, i, 1))));
7017 body.emit(assign(array_ref(msb, i), swizzle_y(unpack_val)));
7018 body.emit(assign(array_ref(lsb, i), swizzle_x(unpack_val)));
7019 }
7020 }
7021
7022 return sig;
7023 }
7024
7025 ir_function_signature *
7026 builtin_builder::_multiply32x16(builtin_available_predicate avail,
7027 const glsl_type *type)
7028 {
7029 return binop(avail, ir_binop_mul_32x16, type, type, type);
7030 }
7031
7032 ir_function_signature *
7033 builtin_builder::_interpolateAtCentroid(const glsl_type *type)
7034 {
7035 ir_variable *interpolant = in_var(type, "interpolant");
7036 interpolant->data.must_be_shader_input = 1;
7037 MAKE_SIG(type, fs_interpolate_at, 1, interpolant);
7038
7039 body.emit(ret(interpolate_at_centroid(interpolant)));
7040
7041 return sig;
7042 }
7043
7044 ir_function_signature *
7045 builtin_builder::_interpolateAtOffset(const glsl_type *type)
7046 {
7047 ir_variable *interpolant = in_var(type, "interpolant");
7048 interpolant->data.must_be_shader_input = 1;
7049 ir_variable *offset = in_var(glsl_type::vec2_type, "offset");
7050 MAKE_SIG(type, fs_interpolate_at, 2, interpolant, offset);
7051
7052 body.emit(ret(interpolate_at_offset(interpolant, offset)));
7053
7054 return sig;
7055 }
7056
7057 ir_function_signature *
7058 builtin_builder::_interpolateAtSample(const glsl_type *type)
7059 {
7060 ir_variable *interpolant = in_var(type, "interpolant");
7061 interpolant->data.must_be_shader_input = 1;
7062 ir_variable *sample_num = in_var(glsl_type::int_type, "sample_num");
7063 MAKE_SIG(type, fs_interpolate_at, 2, interpolant, sample_num);
7064
7065 body.emit(ret(interpolate_at_sample(interpolant, sample_num)));
7066
7067 return sig;
7068 }
7069
7070 ir_function_signature *
7071 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail,
7072 enum ir_intrinsic_id id)
7073 {
7074 ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");
7075 MAKE_INTRINSIC(glsl_type::uint_type, id, avail, 1, counter);
7076 return sig;
7077 }
7078
7079 ir_function_signature *
7080 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail,
7081 enum ir_intrinsic_id id)
7082 {
7083 ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");
7084 ir_variable *data = in_var(glsl_type::uint_type, "data");
7085 MAKE_INTRINSIC(glsl_type::uint_type, id, avail, 2, counter, data);
7086 return sig;
7087 }
7088
7089 ir_function_signature *
7090 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail,
7091 enum ir_intrinsic_id id)
7092 {
7093 ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");
7094 ir_variable *compare = in_var(glsl_type::uint_type, "compare");
7095 ir_variable *data = in_var(glsl_type::uint_type, "data");
7096 MAKE_INTRINSIC(glsl_type::uint_type, id, avail, 3, counter, compare, data);
7097 return sig;
7098 }
7099
7100 ir_function_signature *
7101 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail,
7102 const glsl_type *type,
7103 enum ir_intrinsic_id id)
7104 {
7105 ir_variable *atomic = in_var(type, "atomic");
7106 ir_variable *data = in_var(type, "data");
7107 MAKE_INTRINSIC(type, id, avail, 2, atomic, data);
7108 return sig;
7109 }
7110
7111 ir_function_signature *
7112 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail,
7113 const glsl_type *type,
7114 enum ir_intrinsic_id id)
7115 {
7116 ir_variable *atomic = in_var(type, "atomic");
7117 ir_variable *data1 = in_var(type, "data1");
7118 ir_variable *data2 = in_var(type, "data2");
7119 MAKE_INTRINSIC(type, id, avail, 3, atomic, data1, data2);
7120 return sig;
7121 }
7122
7123 ir_function_signature *
7124 builtin_builder::_atomic_counter_op(const char *intrinsic,
7125 builtin_available_predicate avail)
7126 {
7127 ir_variable *counter = in_var(glsl_type::atomic_uint_type, "atomic_counter");
7128 MAKE_SIG(glsl_type::uint_type, avail, 1, counter);
7129
7130 ir_variable *retval = body.make_temp(glsl_type::uint_type, "atomic_retval");
7131 body.emit(call(shader->symbols->get_function(intrinsic), retval,
7132 sig->parameters));
7133 body.emit(ret(retval));
7134 return sig;
7135 }
7136
7137 ir_function_signature *
7138 builtin_builder::_atomic_counter_op1(const char *intrinsic,
7139 builtin_available_predicate avail)
7140 {
7141 ir_variable *counter = in_var(glsl_type::atomic_uint_type, "atomic_counter");
7142 ir_variable *data = in_var(glsl_type::uint_type, "data");
7143 MAKE_SIG(glsl_type::uint_type, avail, 2, counter, data);
7144
7145 ir_variable *retval = body.make_temp(glsl_type::uint_type, "atomic_retval");
7146
7147 /* Instead of generating an __intrinsic_atomic_sub, generate an
7148 * __intrinsic_atomic_add with the data parameter negated.
7149 */
7150 if (strcmp("__intrinsic_atomic_sub", intrinsic) == 0) {
7151 ir_variable *const neg_data =
7152 body.make_temp(glsl_type::uint_type, "neg_data");
7153
7154 body.emit(assign(neg_data, neg(data)));
7155
7156 exec_list parameters;
7157
7158 parameters.push_tail(new(mem_ctx) ir_dereference_variable(counter));
7159 parameters.push_tail(new(mem_ctx) ir_dereference_variable(neg_data));
7160
7161 ir_function *const func =
7162 shader->symbols->get_function("__intrinsic_atomic_add");
7163 ir_instruction *const c = call(func, retval, parameters);
7164
7165 assert(c != NULL);
7166 assert(parameters.is_empty());
7167
7168 body.emit(c);
7169 } else {
7170 body.emit(call(shader->symbols->get_function(intrinsic), retval,
7171 sig->parameters));
7172 }
7173
7174 body.emit(ret(retval));
7175 return sig;
7176 }
7177
7178 ir_function_signature *
7179 builtin_builder::_atomic_counter_op2(const char *intrinsic,
7180 builtin_available_predicate avail)
7181 {
7182 ir_variable *counter = in_var(glsl_type::atomic_uint_type, "atomic_counter");
7183 ir_variable *compare = in_var(glsl_type::uint_type, "compare");
7184 ir_variable *data = in_var(glsl_type::uint_type, "data");
7185 MAKE_SIG(glsl_type::uint_type, avail, 3, counter, compare, data);
7186
7187 ir_variable *retval = body.make_temp(glsl_type::uint_type, "atomic_retval");
7188 body.emit(call(shader->symbols->get_function(intrinsic), retval,
7189 sig->parameters));
7190 body.emit(ret(retval));
7191 return sig;
7192 }
7193
7194 ir_function_signature *
7195 builtin_builder::_atomic_op2(const char *intrinsic,
7196 builtin_available_predicate avail,
7197 const glsl_type *type)
7198 {
7199 ir_variable *atomic = in_var(type, "atomic_var");
7200 ir_variable *data = in_var(type, "atomic_data");
7201 MAKE_SIG(type, avail, 2, atomic, data);
7202
7203 ir_variable *retval = body.make_temp(type, "atomic_retval");
7204 body.emit(call(shader->symbols->get_function(intrinsic), retval,
7205 sig->parameters));
7206 body.emit(ret(retval));
7207 return sig;
7208 }
7209
7210 ir_function_signature *
7211 builtin_builder::_atomic_op3(const char *intrinsic,
7212 builtin_available_predicate avail,
7213 const glsl_type *type)
7214 {
7215 ir_variable *atomic = in_var(type, "atomic_var");
7216 ir_variable *data1 = in_var(type, "atomic_data1");
7217 ir_variable *data2 = in_var(type, "atomic_data2");
7218 MAKE_SIG(type, avail, 3, atomic, data1, data2);
7219
7220 ir_variable *retval = body.make_temp(type, "atomic_retval");
7221 body.emit(call(shader->symbols->get_function(intrinsic), retval,
7222 sig->parameters));
7223 body.emit(ret(retval));
7224 return sig;
7225 }
7226
7227 ir_function_signature *
7228 builtin_builder::_min3(const glsl_type *type)
7229 {
7230 ir_variable *x = in_var(type, "x");
7231 ir_variable *y = in_var(type, "y");
7232 ir_variable *z = in_var(type, "z");
7233 MAKE_SIG(type, shader_trinary_minmax, 3, x, y, z);
7234
7235 ir_expression *min3 = min2(x, min2(y,z));
7236 body.emit(ret(min3));
7237
7238 return sig;
7239 }
7240
7241 ir_function_signature *
7242 builtin_builder::_max3(const glsl_type *type)
7243 {
7244 ir_variable *x = in_var(type, "x");
7245 ir_variable *y = in_var(type, "y");
7246 ir_variable *z = in_var(type, "z");
7247 MAKE_SIG(type, shader_trinary_minmax, 3, x, y, z);
7248
7249 ir_expression *max3 = max2(x, max2(y,z));
7250 body.emit(ret(max3));
7251
7252 return sig;
7253 }
7254
7255 ir_function_signature *
7256 builtin_builder::_mid3(const glsl_type *type)
7257 {
7258 ir_variable *x = in_var(type, "x");
7259 ir_variable *y = in_var(type, "y");
7260 ir_variable *z = in_var(type, "z");
7261 MAKE_SIG(type, shader_trinary_minmax, 3, x, y, z);
7262
7263 ir_expression *mid3 = max2(min2(x, y), max2(min2(x, z), min2(y, z)));
7264 body.emit(ret(mid3));
7265
7266 return sig;
7267 }
7268
7269 static builtin_available_predicate
7270 get_image_available_predicate(const glsl_type *type, unsigned flags)
7271 {
7272 if ((flags & IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE) &&
7273 type->sampled_type == GLSL_TYPE_FLOAT)
7274 return shader_image_atomic_exchange_float;
7275
7276 if ((flags & IMAGE_FUNCTION_AVAIL_ATOMIC_ADD) &&
7277 type->sampled_type == GLSL_TYPE_FLOAT)
7278 return shader_image_atomic_add_float;
7279
7280 else if (flags & (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE |
7281 IMAGE_FUNCTION_AVAIL_ATOMIC_ADD |
7282 IMAGE_FUNCTION_AVAIL_ATOMIC))
7283 return shader_image_atomic;
7284
7285 else if (flags & IMAGE_FUNCTION_EXT_ONLY)
7286 return shader_image_load_store_ext;
7287
7288 else
7289 return shader_image_load_store;
7290 }
7291
7292 ir_function_signature *
7293 builtin_builder::_image_prototype(const glsl_type *image_type,
7294 unsigned num_arguments,
7295 unsigned flags)
7296 {
7297 const glsl_type *data_type = glsl_type::get_instance(
7298 image_type->sampled_type,
7299 (flags & IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE ? 4 : 1),
7300 1);
7301 const glsl_type *ret_type = (flags & IMAGE_FUNCTION_RETURNS_VOID ?
7302 glsl_type::void_type : data_type);
7303
7304 /* Addressing arguments that are always present. */
7305 ir_variable *image = in_var(image_type, "image");
7306 ir_variable *coord = in_var(
7307 glsl_type::ivec(image_type->coordinate_components()), "coord");
7308
7309 ir_function_signature *sig = new_sig(
7310 ret_type, get_image_available_predicate(image_type, flags),
7311 2, image, coord);
7312
7313 /* Sample index for multisample images. */
7314 if (image_type->sampler_dimensionality == GLSL_SAMPLER_DIM_MS)
7315 sig->parameters.push_tail(in_var(glsl_type::int_type, "sample"));
7316
7317 /* Data arguments. */
7318 for (unsigned i = 0; i < num_arguments; ++i) {
7319 char *arg_name = ralloc_asprintf(NULL, "arg%d", i);
7320 sig->parameters.push_tail(in_var(data_type, arg_name));
7321 ralloc_free(arg_name);
7322 }
7323
7324 /* Set the maximal set of qualifiers allowed for this image
7325 * built-in. Function calls with arguments having fewer
7326 * qualifiers than present in the prototype are allowed by the
7327 * spec, but not with more, i.e. this will make the compiler
7328 * accept everything that needs to be accepted, and reject cases
7329 * like loads from write-only or stores to read-only images.
7330 */
7331 image->data.memory_read_only = (flags & IMAGE_FUNCTION_READ_ONLY) != 0;
7332 image->data.memory_write_only = (flags & IMAGE_FUNCTION_WRITE_ONLY) != 0;
7333 image->data.memory_coherent = true;
7334 image->data.memory_volatile = true;
7335 image->data.memory_restrict = true;
7336
7337 return sig;
7338 }
7339
7340 ir_function_signature *
7341 builtin_builder::_image_size_prototype(const glsl_type *image_type,
7342 unsigned /* num_arguments */,
7343 unsigned /* flags */)
7344 {
7345 const glsl_type *ret_type;
7346 unsigned num_components = image_type->coordinate_components();
7347
7348 /* From the ARB_shader_image_size extension:
7349 * "Cube images return the dimensions of one face."
7350 */
7351 if (image_type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE &&
7352 !image_type->sampler_array) {
7353 num_components = 2;
7354 }
7355
7356 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
7357 * supported by mesa.
7358 */
7359 ret_type = glsl_type::get_instance(GLSL_TYPE_INT, num_components, 1);
7360
7361 ir_variable *image = in_var(image_type, "image");
7362 ir_function_signature *sig = new_sig(ret_type, shader_image_size, 1, image);
7363
7364 /* Set the maximal set of qualifiers allowed for this image
7365 * built-in. Function calls with arguments having fewer
7366 * qualifiers than present in the prototype are allowed by the
7367 * spec, but not with more, i.e. this will make the compiler
7368 * accept everything that needs to be accepted, and reject cases
7369 * like loads from write-only or stores to read-only images.
7370 */
7371 image->data.memory_read_only = true;
7372 image->data.memory_write_only = true;
7373 image->data.memory_coherent = true;
7374 image->data.memory_volatile = true;
7375 image->data.memory_restrict = true;
7376
7377 return sig;
7378 }
7379
7380 ir_function_signature *
7381 builtin_builder::_image_samples_prototype(const glsl_type *image_type,
7382 unsigned /* num_arguments */,
7383 unsigned /* flags */)
7384 {
7385 ir_variable *image = in_var(image_type, "image");
7386 ir_function_signature *sig =
7387 new_sig(glsl_type::int_type, shader_samples, 1, image);
7388
7389 /* Set the maximal set of qualifiers allowed for this image
7390 * built-in. Function calls with arguments having fewer
7391 * qualifiers than present in the prototype are allowed by the
7392 * spec, but not with more, i.e. this will make the compiler
7393 * accept everything that needs to be accepted, and reject cases
7394 * like loads from write-only or stores to read-only images.
7395 */
7396 image->data.memory_read_only = true;
7397 image->data.memory_write_only = true;
7398 image->data.memory_coherent = true;
7399 image->data.memory_volatile = true;
7400 image->data.memory_restrict = true;
7401
7402 return sig;
7403 }
7404
7405 ir_function_signature *
7406 builtin_builder::_image(image_prototype_ctr prototype,
7407 const glsl_type *image_type,
7408 const char *intrinsic_name,
7409 unsigned num_arguments,
7410 unsigned flags,
7411 enum ir_intrinsic_id id)
7412 {
7413 ir_function_signature *sig = (this->*prototype)(image_type,
7414 num_arguments, flags);
7415
7416 if (flags & IMAGE_FUNCTION_EMIT_STUB) {
7417 ir_factory body(&sig->body, mem_ctx);
7418 ir_function *f = shader->symbols->get_function(intrinsic_name);
7419
7420 if (flags & IMAGE_FUNCTION_RETURNS_VOID) {
7421 body.emit(call(f, NULL, sig->parameters));
7422 } else {
7423 ir_variable *ret_val =
7424 body.make_temp(sig->return_type, "_ret_val");
7425 body.emit(call(f, ret_val, sig->parameters));
7426 body.emit(ret(ret_val));
7427 }
7428
7429 sig->is_defined = true;
7430
7431 } else {
7432 sig->intrinsic_id = id;
7433 }
7434
7435 return sig;
7436 }
7437
7438 ir_function_signature *
7439 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail,
7440 enum ir_intrinsic_id id)
7441 {
7442 MAKE_INTRINSIC(glsl_type::void_type, id, avail, 0);
7443 return sig;
7444 }
7445
7446 ir_function_signature *
7447 builtin_builder::_memory_barrier(const char *intrinsic_name,
7448 builtin_available_predicate avail)
7449 {
7450 MAKE_SIG(glsl_type::void_type, avail, 0);
7451 body.emit(call(shader->symbols->get_function(intrinsic_name),
7452 NULL, sig->parameters));
7453 return sig;
7454 }
7455
7456 ir_function_signature *
7457 builtin_builder::_ballot_intrinsic()
7458 {
7459 ir_variable *value = in_var(glsl_type::bool_type, "value");
7460 MAKE_INTRINSIC(glsl_type::uint64_t_type, ir_intrinsic_ballot, shader_ballot,
7461 1, value);
7462 return sig;
7463 }
7464
7465 ir_function_signature *
7466 builtin_builder::_ballot()
7467 {
7468 ir_variable *value = in_var(glsl_type::bool_type, "value");
7469
7470 MAKE_SIG(glsl_type::uint64_t_type, shader_ballot, 1, value);
7471 ir_variable *retval = body.make_temp(glsl_type::uint64_t_type, "retval");
7472
7473 body.emit(call(shader->symbols->get_function("__intrinsic_ballot"),
7474 retval, sig->parameters));
7475 body.emit(ret(retval));
7476 return sig;
7477 }
7478
7479 ir_function_signature *
7480 builtin_builder::_read_first_invocation_intrinsic(const glsl_type *type)
7481 {
7482 ir_variable *value = in_var(type, "value");
7483 MAKE_INTRINSIC(type, ir_intrinsic_read_first_invocation, shader_ballot,
7484 1, value);
7485 return sig;
7486 }
7487
7488 ir_function_signature *
7489 builtin_builder::_read_first_invocation(const glsl_type *type)
7490 {
7491 ir_variable *value = in_var(type, "value");
7492
7493 MAKE_SIG(type, shader_ballot, 1, value);
7494 ir_variable *retval = body.make_temp(type, "retval");
7495
7496 body.emit(call(shader->symbols->get_function("__intrinsic_read_first_invocation"),
7497 retval, sig->parameters));
7498 body.emit(ret(retval));
7499 return sig;
7500 }
7501
7502 ir_function_signature *
7503 builtin_builder::_read_invocation_intrinsic(const glsl_type *type)
7504 {
7505 ir_variable *value = in_var(type, "value");
7506 ir_variable *invocation = in_var(glsl_type::uint_type, "invocation");
7507 MAKE_INTRINSIC(type, ir_intrinsic_read_invocation, shader_ballot,
7508 2, value, invocation);
7509 return sig;
7510 }
7511
7512 ir_function_signature *
7513 builtin_builder::_read_invocation(const glsl_type *type)
7514 {
7515 ir_variable *value = in_var(type, "value");
7516 ir_variable *invocation = in_var(glsl_type::uint_type, "invocation");
7517
7518 MAKE_SIG(type, shader_ballot, 2, value, invocation);
7519 ir_variable *retval = body.make_temp(type, "retval");
7520
7521 body.emit(call(shader->symbols->get_function("__intrinsic_read_invocation"),
7522 retval, sig->parameters));
7523 body.emit(ret(retval));
7524 return sig;
7525 }
7526
7527 ir_function_signature *
7528 builtin_builder::_invocation_interlock_intrinsic(builtin_available_predicate avail,
7529 enum ir_intrinsic_id id)
7530 {
7531 MAKE_INTRINSIC(glsl_type::void_type, id, avail, 0);
7532 return sig;
7533 }
7534
7535 ir_function_signature *
7536 builtin_builder::_invocation_interlock(const char *intrinsic_name,
7537 builtin_available_predicate avail)
7538 {
7539 MAKE_SIG(glsl_type::void_type, avail, 0);
7540 body.emit(call(shader->symbols->get_function(intrinsic_name),
7541 NULL, sig->parameters));
7542 return sig;
7543 }
7544
7545 ir_function_signature *
7546 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail,
7547 const glsl_type *type)
7548 {
7549 MAKE_INTRINSIC(type, ir_intrinsic_shader_clock, avail, 0);
7550 return sig;
7551 }
7552
7553 ir_function_signature *
7554 builtin_builder::_shader_clock(builtin_available_predicate avail,
7555 const glsl_type *type)
7556 {
7557 MAKE_SIG(type, avail, 0);
7558
7559 ir_variable *retval = body.make_temp(glsl_type::uvec2_type, "clock_retval");
7560
7561 body.emit(call(shader->symbols->get_function("__intrinsic_shader_clock"),
7562 retval, sig->parameters));
7563
7564 if (type == glsl_type::uint64_t_type) {
7565 body.emit(ret(expr(ir_unop_pack_uint_2x32, retval)));
7566 } else {
7567 body.emit(ret(retval));
7568 }
7569
7570 return sig;
7571 }
7572
7573 ir_function_signature *
7574 builtin_builder::_vote_intrinsic(builtin_available_predicate avail,
7575 enum ir_intrinsic_id id)
7576 {
7577 ir_variable *value = in_var(glsl_type::bool_type, "value");
7578 MAKE_INTRINSIC(glsl_type::bool_type, id, avail, 1, value);
7579 return sig;
7580 }
7581
7582 ir_function_signature *
7583 builtin_builder::_vote(const char *intrinsic_name,
7584 builtin_available_predicate avail)
7585 {
7586 ir_variable *value = in_var(glsl_type::bool_type, "value");
7587
7588 MAKE_SIG(glsl_type::bool_type, avail, 1, value);
7589
7590 ir_variable *retval = body.make_temp(glsl_type::bool_type, "retval");
7591
7592 body.emit(call(shader->symbols->get_function(intrinsic_name),
7593 retval, sig->parameters));
7594 body.emit(ret(retval));
7595 return sig;
7596 }
7597
7598 ir_function_signature *
7599 builtin_builder::_helper_invocation_intrinsic()
7600 {
7601 MAKE_INTRINSIC(glsl_type::bool_type, ir_intrinsic_helper_invocation,
7602 demote_to_helper_invocation, 0);
7603 return sig;
7604 }
7605
7606 ir_function_signature *
7607 builtin_builder::_helper_invocation()
7608 {
7609 MAKE_SIG(glsl_type::bool_type, demote_to_helper_invocation, 0);
7610
7611 ir_variable *retval = body.make_temp(glsl_type::bool_type, "retval");
7612
7613 body.emit(call(shader->symbols->get_function("__intrinsic_helper_invocation"),
7614 retval, sig->parameters));
7615 body.emit(ret(retval));
7616
7617 return sig;
7618 }
7619
7620 /** @} */
7621
7622 /******************************************************************************/
7623
7624 /* The singleton instance of builtin_builder. */
7625 static builtin_builder builtins;
7626 static mtx_t builtins_lock = _MTX_INITIALIZER_NP;
7627 static uint32_t builtin_users = 0;
7628
7629 /**
7630 * External API (exposing the built-in module to the rest of the compiler):
7631 * @{
7632 */
7633 extern "C" void
7634 _mesa_glsl_builtin_functions_init_or_ref()
7635 {
7636 mtx_lock(&builtins_lock);
7637 if (builtin_users++ == 0)
7638 builtins.initialize();
7639 mtx_unlock(&builtins_lock);
7640 }
7641
7642 extern "C" void
7643 _mesa_glsl_builtin_functions_decref()
7644 {
7645 mtx_lock(&builtins_lock);
7646 assert(builtin_users != 0);
7647 if (--builtin_users == 0)
7648 builtins.release();
7649 mtx_unlock(&builtins_lock);
7650 }
7651
7652 ir_function_signature *
7653 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,
7654 const char *name, exec_list *actual_parameters)
7655 {
7656 ir_function_signature *s;
7657 mtx_lock(&builtins_lock);
7658 s = builtins.find(state, name, actual_parameters);
7659 mtx_unlock(&builtins_lock);
7660
7661 return s;
7662 }
7663
7664 bool
7665 _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state *state, const char *name)
7666 {
7667 ir_function *f;
7668 bool ret = false;
7669 mtx_lock(&builtins_lock);
7670 f = builtins.shader->symbols->get_function(name);
7671 if (f != NULL) {
7672 foreach_in_list(ir_function_signature, sig, &f->signatures) {
7673 if (sig->is_builtin_available(state)) {
7674 ret = true;
7675 break;
7676 }
7677 }
7678 }
7679 mtx_unlock(&builtins_lock);
7680
7681 return ret;
7682 }
7683
7684 gl_shader *
7685 _mesa_glsl_get_builtin_function_shader()
7686 {
7687 return builtins.shader;
7688 }
7689
7690
7691 /**
7692 * Get the function signature for main from a shader
7693 */
7694 ir_function_signature *
7695 _mesa_get_main_function_signature(glsl_symbol_table *symbols)
7696 {
7697 ir_function *const f = symbols->get_function("main");
7698 if (f != NULL) {
7699 exec_list void_parameters;
7700
7701 /* Look for the 'void main()' signature and ensure that it's defined.
7702 * This keeps the linker from accidentally pick a shader that just
7703 * contains a prototype for main.
7704 *
7705 * We don't have to check for multiple definitions of main (in multiple
7706 * shaders) because that would have already been caught above.
7707 */
7708 ir_function_signature *sig =
7709 f->matching_signature(NULL, &void_parameters, false);
7710 if ((sig != NULL) && sig->is_defined) {
7711 return sig;
7712 }
7713 }
7714
7715 return NULL;
7716 }
7717
7718 /** @} */