2 * Copyright © 2013 Intel Corporation
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:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND 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.
25 * \file builtin_functions.cpp
27 * Support for GLSL built-in functions.
29 * This file is split into several main components:
31 * 1. Availability predicates
33 * A series of small functions that check whether the current shader
34 * supports the version/extensions required to expose a built-in.
36 * 2. Core builtin_builder class functionality
38 * 3. Lists of built-in functions
40 * The builtin_builder::create_builtins() function contains lists of all
41 * built-in function signatures, where they're available, what types they
44 * 4. Implementations of built-in function signatures
46 * A series of functions which create ir_function_signatures and emit IR
47 * via ir_builder to implement them.
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.
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.
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
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")
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"
84 #include "builtin_functions.h"
85 #include "util/hash_table.h"
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)
91 using namespace ir_builder
;
94 * Availability predicates:
98 always_available(const _mesa_glsl_parse_state
*)
104 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
106 return state
->stage
== MESA_SHADER_VERTEX
&&
107 (state
->compat_shader
|| state
->ARB_compatibility_enable
) &&
112 derivatives_only(const _mesa_glsl_parse_state
*state
)
114 return state
->stage
== MESA_SHADER_FRAGMENT
||
115 (state
->stage
== MESA_SHADER_COMPUTE
&&
116 state
->NV_compute_shader_derivatives_enable
);
120 gs_only(const _mesa_glsl_parse_state
*state
)
122 return state
->stage
== MESA_SHADER_GEOMETRY
;
126 v110(const _mesa_glsl_parse_state
*state
)
128 return !state
->es_shader
;
132 v110_derivatives_only(const _mesa_glsl_parse_state
*state
)
134 return !state
->es_shader
&&
135 (state
->stage
== MESA_SHADER_FRAGMENT
||
136 (state
->stage
== MESA_SHADER_COMPUTE
&&
137 state
->NV_compute_shader_derivatives_enable
));
141 v120(const _mesa_glsl_parse_state
*state
)
143 return state
->is_version(120, 300);
147 v130(const _mesa_glsl_parse_state
*state
)
149 return state
->is_version(130, 300);
153 v130_desktop(const _mesa_glsl_parse_state
*state
)
155 return state
->is_version(130, 0);
159 v460_desktop(const _mesa_glsl_parse_state
*state
)
161 return state
->is_version(460, 0);
165 v130_derivatives_only(const _mesa_glsl_parse_state
*state
)
167 return state
->is_version(130, 300) &&
168 (state
->stage
== MESA_SHADER_FRAGMENT
||
169 (state
->stage
== MESA_SHADER_COMPUTE
&&
170 state
->NV_compute_shader_derivatives_enable
));
174 v140_or_es3(const _mesa_glsl_parse_state
*state
)
176 return state
->is_version(140, 300);
180 v400_derivatives_only(const _mesa_glsl_parse_state
*state
)
182 return state
->is_version(400, 0) &&
183 (state
->stage
== MESA_SHADER_FRAGMENT
||
184 (state
->stage
== MESA_SHADER_COMPUTE
&&
185 state
->NV_compute_shader_derivatives_enable
));
189 texture_rectangle(const _mesa_glsl_parse_state
*state
)
191 return state
->ARB_texture_rectangle_enable
;
195 texture_external(const _mesa_glsl_parse_state
*state
)
197 return state
->OES_EGL_image_external_enable
;
201 texture_external_es3(const _mesa_glsl_parse_state
*state
)
203 return state
->OES_EGL_image_external_essl3_enable
&&
205 state
->is_version(0, 300);
208 /** True if texturing functions with explicit LOD are allowed. */
210 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
212 /* Texturing functions with "Lod" in their name exist:
213 * - In the vertex shader stage (for all languages)
214 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
215 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
217 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
218 * don't need to explicitly check state->es_shader.
220 return state
->stage
== MESA_SHADER_VERTEX
||
221 state
->is_version(130, 300) ||
222 state
->ARB_shader_texture_lod_enable
;
226 v110_lod(const _mesa_glsl_parse_state
*state
)
228 return !state
->es_shader
&& lod_exists_in_stage(state
);
232 texture_buffer(const _mesa_glsl_parse_state
*state
)
234 return state
->is_version(140, 320) ||
235 state
->EXT_texture_buffer_enable
||
236 state
->OES_texture_buffer_enable
;
240 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
242 return state
->ARB_shader_texture_lod_enable
;
246 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
248 return state
->ARB_shader_texture_lod_enable
&&
249 state
->ARB_texture_rectangle_enable
;
253 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
255 return state
->is_version(330, 300) ||
256 state
->ARB_shader_bit_encoding_enable
||
257 state
->ARB_gpu_shader5_enable
;
261 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
263 return state
->is_version(450, 310) ||
264 state
->ARB_ES3_1_compatibility_enable
||
265 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
269 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
271 return state
->ARB_shading_language_packing_enable
||
272 state
->is_version(420, 300);
276 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
278 return state
->ARB_shading_language_packing_enable
||
279 state
->ARB_gpu_shader5_enable
||
280 state
->is_version(400, 300);
284 gpu_shader4(const _mesa_glsl_parse_state
*state
)
286 return state
->EXT_gpu_shader4_enable
;
290 v130_or_gpu_shader4(const _mesa_glsl_parse_state
*state
)
292 return state
->is_version(130, 300) || state
->EXT_gpu_shader4_enable
;
296 gpu_shader5(const _mesa_glsl_parse_state
*state
)
298 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
302 gpu_shader5_es(const _mesa_glsl_parse_state
*state
)
304 return state
->is_version(400, 320) ||
305 state
->ARB_gpu_shader5_enable
||
306 state
->EXT_gpu_shader5_enable
||
307 state
->OES_gpu_shader5_enable
;
311 gpu_shader5_or_OES_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
313 return state
->is_version(400, 320) ||
314 state
->ARB_gpu_shader5_enable
||
315 state
->EXT_texture_cube_map_array_enable
||
316 state
->OES_texture_cube_map_array_enable
;
320 es31_not_gs5(const _mesa_glsl_parse_state
*state
)
322 return state
->is_version(0, 310) && !gpu_shader5_es(state
);
326 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
328 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
332 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
334 return state
->ARB_shading_language_packing_enable
||
335 state
->ARB_gpu_shader5_enable
||
336 state
->is_version(400, 310);
340 gpu_shader5_or_es31_or_integer_functions(const _mesa_glsl_parse_state
*state
)
342 return gpu_shader5_or_es31(state
) ||
343 state
->MESA_shader_integer_functions_enable
;
347 fs_interpolate_at(const _mesa_glsl_parse_state
*state
)
349 return state
->stage
== MESA_SHADER_FRAGMENT
&&
350 (state
->is_version(400, 320) ||
351 state
->ARB_gpu_shader5_enable
||
352 state
->OES_shader_multisample_interpolation_enable
);
357 texture_array_lod(const _mesa_glsl_parse_state
*state
)
359 return lod_exists_in_stage(state
) &&
360 state
->EXT_texture_array_enable
;
364 fs_texture_array(const _mesa_glsl_parse_state
*state
)
366 return state
->stage
== MESA_SHADER_FRAGMENT
&&
367 state
->EXT_texture_array_enable
;
371 texture_array(const _mesa_glsl_parse_state
*state
)
373 return state
->EXT_texture_array_enable
;
377 texture_multisample(const _mesa_glsl_parse_state
*state
)
379 return state
->is_version(150, 310) ||
380 state
->ARB_texture_multisample_enable
;
384 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
386 return state
->is_version(150, 320) ||
387 state
->ARB_texture_multisample_enable
||
388 state
->OES_texture_storage_multisample_2d_array_enable
;
392 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
394 return texture_multisample(state
) &&
395 state
->EXT_shader_samples_identical_enable
;
399 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
401 return texture_multisample_array(state
) &&
402 state
->EXT_shader_samples_identical_enable
;
406 derivatives_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
408 return state
->has_texture_cube_map_array() &&
409 (state
->stage
== MESA_SHADER_FRAGMENT
||
410 (state
->stage
== MESA_SHADER_COMPUTE
&&
411 state
->NV_compute_shader_derivatives_enable
));
415 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
417 return state
->has_texture_cube_map_array();
421 texture_query_levels(const _mesa_glsl_parse_state
*state
)
423 return state
->is_version(430, 0) ||
424 state
->ARB_texture_query_levels_enable
;
428 texture_query_lod(const _mesa_glsl_parse_state
*state
)
430 return state
->stage
== MESA_SHADER_FRAGMENT
&&
431 (state
->ARB_texture_query_lod_enable
||
432 state
->EXT_texture_query_lod_enable
);
436 texture_gather_cube_map_array(const _mesa_glsl_parse_state
*state
)
438 return state
->is_version(400, 320) ||
439 state
->ARB_texture_gather_enable
||
440 state
->ARB_gpu_shader5_enable
||
441 state
->EXT_texture_cube_map_array_enable
||
442 state
->OES_texture_cube_map_array_enable
;
446 texture_texture4(const _mesa_glsl_parse_state
*state
)
448 return state
->AMD_texture_texture4_enable
;
452 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
454 return state
->is_version(400, 310) ||
455 state
->ARB_texture_gather_enable
||
456 state
->ARB_gpu_shader5_enable
;
459 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
460 * used for relaxation of const offset requirements.
463 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
465 return !state
->is_version(400, 320) &&
466 !state
->ARB_gpu_shader5_enable
&&
467 !state
->EXT_gpu_shader5_enable
&&
468 !state
->OES_gpu_shader5_enable
&&
469 (state
->ARB_texture_gather_enable
||
470 state
->is_version(0, 310));
473 /* Desktop GL or OES_standard_derivatives + fragment shader only */
475 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
477 return state
->stage
== MESA_SHADER_FRAGMENT
&&
478 (state
->is_version(110, 300) ||
479 state
->OES_standard_derivatives_enable
||
480 state
->ctx
->Const
.AllowGLSLRelaxedES
);
484 derivatives(const _mesa_glsl_parse_state
*state
)
486 return fs_oes_derivatives(state
) ||
487 (state
->stage
== MESA_SHADER_COMPUTE
&&
488 state
->NV_compute_shader_derivatives_enable
);
492 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
494 return state
->stage
== MESA_SHADER_FRAGMENT
&&
495 (state
->is_version(450, 0) ||
496 state
->ARB_derivative_control_enable
);
500 derivative_control(const _mesa_glsl_parse_state
*state
)
502 return fs_derivative_control(state
) ||
503 (state
->stage
== MESA_SHADER_COMPUTE
&&
504 state
->NV_compute_shader_derivatives_enable
);
508 tex1d_lod(const _mesa_glsl_parse_state
*state
)
510 return !state
->es_shader
&& lod_exists_in_stage(state
);
513 /** True if sampler3D exists */
515 tex3d(const _mesa_glsl_parse_state
*state
)
517 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
518 * OES_texture_3D extension, and in GLSL ES 3.00.
520 return !state
->es_shader
||
521 state
->OES_texture_3D_enable
||
522 state
->language_version
>= 300;
526 derivatives_tex3d(const _mesa_glsl_parse_state
*state
)
528 return (!state
->es_shader
|| state
->OES_texture_3D_enable
) &&
529 (state
->stage
== MESA_SHADER_FRAGMENT
||
530 (state
->stage
== MESA_SHADER_COMPUTE
&&
531 state
->NV_compute_shader_derivatives_enable
));
535 tex3d_lod(const _mesa_glsl_parse_state
*state
)
537 return tex3d(state
) && lod_exists_in_stage(state
);
541 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
543 return state
->has_atomic_counters();
547 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
549 return state
->ARB_shader_atomic_counter_ops_enable
;
553 shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
555 return state
->ARB_shader_atomic_counter_ops_enable
|| v460_desktop(state
);
559 shader_ballot(const _mesa_glsl_parse_state
*state
)
561 return state
->ARB_shader_ballot_enable
;
565 supports_arb_fragment_shader_interlock(const _mesa_glsl_parse_state
*state
)
567 return state
->ARB_fragment_shader_interlock_enable
;
571 supports_nv_fragment_shader_interlock(const _mesa_glsl_parse_state
*state
)
573 return state
->NV_fragment_shader_interlock_enable
;
577 shader_clock(const _mesa_glsl_parse_state
*state
)
579 return state
->ARB_shader_clock_enable
;
583 shader_clock_int64(const _mesa_glsl_parse_state
*state
)
585 return state
->ARB_shader_clock_enable
&&
586 (state
->ARB_gpu_shader_int64_enable
||
587 state
->AMD_gpu_shader_int64_enable
);
591 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
593 return state
->has_shader_storage_buffer_objects();
597 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
599 return state
->AMD_shader_trinary_minmax_enable
;
603 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
605 return (state
->is_version(420, 310) ||
606 state
->ARB_shader_image_load_store_enable
);
610 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
612 return (state
->is_version(420, 320) ||
613 state
->ARB_shader_image_load_store_enable
||
614 state
->OES_shader_image_atomic_enable
);
618 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
620 return (state
->is_version(450, 320) ||
621 state
->ARB_ES3_1_compatibility_enable
||
622 state
->OES_shader_image_atomic_enable
||
623 state
->NV_shader_atomic_float_enable
);
627 shader_image_atomic_add_float(const _mesa_glsl_parse_state
*state
)
629 return state
->NV_shader_atomic_float_enable
;
633 shader_image_size(const _mesa_glsl_parse_state
*state
)
635 return state
->is_version(430, 310) ||
636 state
->ARB_shader_image_size_enable
;
640 shader_samples(const _mesa_glsl_parse_state
*state
)
642 return state
->is_version(450, 0) ||
643 state
->ARB_shader_texture_image_samples_enable
;
647 gs_streams(const _mesa_glsl_parse_state
*state
)
649 return gpu_shader5(state
) && gs_only(state
);
653 fp64(const _mesa_glsl_parse_state
*state
)
655 return state
->has_double();
659 int64(const _mesa_glsl_parse_state
*state
)
661 return state
->has_int64();
665 int64_fp64(const _mesa_glsl_parse_state
*state
)
667 return state
->has_int64() && state
->has_double();
671 compute_shader(const _mesa_glsl_parse_state
*state
)
673 return state
->stage
== MESA_SHADER_COMPUTE
;
677 compute_shader_supported(const _mesa_glsl_parse_state
*state
)
679 return state
->has_compute_shader();
683 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
685 return compute_shader(state
) || shader_storage_buffer_object(state
);
689 barrier_supported(const _mesa_glsl_parse_state
*state
)
691 return compute_shader(state
) ||
692 state
->stage
== MESA_SHADER_TESS_CTRL
;
696 vote(const _mesa_glsl_parse_state
*state
)
698 return state
->ARB_shader_group_vote_enable
;
702 vote_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
704 return state
->ARB_shader_group_vote_enable
|| v460_desktop(state
);
708 integer_functions_supported(const _mesa_glsl_parse_state
*state
)
710 return state
->extensions
->MESA_shader_integer_functions
;
714 NV_shader_atomic_float_supported(const _mesa_glsl_parse_state
*state
)
716 return state
->extensions
->NV_shader_atomic_float
;
720 shader_atomic_float_add(const _mesa_glsl_parse_state
*state
)
722 return state
->NV_shader_atomic_float_enable
;
726 shader_atomic_float_exchange(const _mesa_glsl_parse_state
*state
)
728 return state
->NV_shader_atomic_float_enable
||
729 state
->INTEL_shader_atomic_float_minmax_enable
;
733 INTEL_shader_atomic_float_minmax_supported(const _mesa_glsl_parse_state
*state
)
735 return state
->extensions
->INTEL_shader_atomic_float_minmax
;
739 shader_atomic_float_minmax(const _mesa_glsl_parse_state
*state
)
741 return state
->INTEL_shader_atomic_float_minmax_enable
;
745 /******************************************************************************/
750 * builtin_builder: A singleton object representing the core of the built-in
753 * It generates IR for every built-in function signature, and organizes them
756 class builtin_builder
{
763 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
764 const char *name
, exec_list
*actual_parameters
);
767 * A shader to hold all the built-in signatures; created by this module.
769 * This includes signatures for every built-in, regardless of version or
770 * enabled extensions. The availability predicate associated with each
771 * signature allows matching_signature() to filter out the irrelevant ones.
778 void create_shader();
779 void create_intrinsics();
780 void create_builtins();
783 * IR builder helpers:
785 * These convenience functions assist in emitting IR, but don't necessarily
786 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
789 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
790 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
791 ir_constant
*imm(float f
, unsigned vector_elements
=1);
792 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
793 ir_constant
*imm(int i
, unsigned vector_elements
=1);
794 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
795 ir_constant
*imm(double d
, unsigned vector_elements
=1);
796 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
797 ir_dereference_variable
*var_ref(ir_variable
*var
);
798 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
799 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
801 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
802 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
805 * Call function \param f with parameters specified as the linked
806 * list \param params of \c ir_variable objects. \param ret should
807 * point to the ir_variable that will hold the function return
808 * value, or be \c NULL if the function has void return type.
810 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
812 /** Create a new function and add the given signatures. */
813 void add_function(const char *name
, ...);
815 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
816 unsigned num_arguments
,
820 * Create a new image built-in function for all known image types.
821 * \p flags is a bitfield of \c image_function_flags flags.
823 void add_image_function(const char *name
,
824 const char *intrinsic_name
,
825 image_prototype_ctr prototype
,
826 unsigned num_arguments
,
828 enum ir_intrinsic_id id
);
831 * Create new functions for all known image built-ins and types.
832 * If \p glsl is \c true, use the GLSL built-in names and emit code
833 * to call into the actual compiler intrinsic. If \p glsl is
834 * false, emit a function prototype with no body for each image
837 void add_image_functions(bool glsl
);
839 ir_function_signature
*new_sig(const glsl_type
*return_type
,
840 builtin_available_predicate avail
,
841 int num_params
, ...);
844 * Function signature generators:
847 ir_function_signature
*unop(builtin_available_predicate avail
,
848 ir_expression_operation opcode
,
849 const glsl_type
*return_type
,
850 const glsl_type
*param_type
);
851 ir_function_signature
*binop(builtin_available_predicate avail
,
852 ir_expression_operation opcode
,
853 const glsl_type
*return_type
,
854 const glsl_type
*param0_type
,
855 const glsl_type
*param1_type
,
856 bool swap_operands
= false);
858 #define B0(X) ir_function_signature *_##X();
859 #define B1(X) ir_function_signature *_##X(const glsl_type *);
860 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
861 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
862 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
863 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
901 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
902 const glsl_type
*val_type
,
903 const glsl_type
*blend_type
);
913 BA1(doubleBitsToInt64
)
914 BA1(doubleBitsToUint64
)
915 BA1(int64BitsToDouble
)
916 BA1(uint64BitsToDouble
)
918 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
919 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
920 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
921 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
922 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
923 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
924 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
925 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
926 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
927 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
928 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
929 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
930 ir_function_signature
*_packInt2x32(builtin_available_predicate avail
);
931 ir_function_signature
*_unpackInt2x32(builtin_available_predicate avail
);
932 ir_function_signature
*_packUint2x32(builtin_available_predicate avail
);
933 ir_function_signature
*_unpackUint2x32(builtin_available_predicate avail
);
946 BA1(determinant_mat2
);
947 BA1(determinant_mat3
);
948 BA1(determinant_mat4
);
956 BA1(greaterThanEqual
);
965 /** Flags to _texture() */
966 #define TEX_PROJECT 1
968 #define TEX_COMPONENT 4
969 #define TEX_OFFSET_NONCONST 8
970 #define TEX_OFFSET_ARRAY 16
972 ir_function_signature
*_texture(ir_texture_opcode opcode
,
973 builtin_available_predicate avail
,
974 const glsl_type
*return_type
,
975 const glsl_type
*sampler_type
,
976 const glsl_type
*coord_type
,
978 BA1(textureCubeArrayShadow
);
979 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
980 const glsl_type
*return_type
,
981 const glsl_type
*sampler_type
,
982 const glsl_type
*coord_type
,
983 const glsl_type
*offset_type
= NULL
);
987 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
988 const glsl_type
*stream_type
);
989 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
990 const glsl_type
*stream_type
);
993 BA2(textureQueryLod
);
994 BA1(textureQueryLevels
);
995 BA2(textureSamplesIdentical
);
1023 B1(interpolateAtCentroid
)
1024 B1(interpolateAtOffset
)
1025 B1(interpolateAtSample
)
1027 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
,
1028 enum ir_intrinsic_id id
);
1029 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
,
1030 enum ir_intrinsic_id id
);
1031 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
,
1032 enum ir_intrinsic_id id
);
1033 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
1034 builtin_available_predicate avail
);
1035 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
1036 builtin_available_predicate avail
);
1037 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
1038 builtin_available_predicate avail
);
1040 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
1041 const glsl_type
*type
,
1042 enum ir_intrinsic_id id
);
1043 ir_function_signature
*_atomic_op2(const char *intrinsic
,
1044 builtin_available_predicate avail
,
1045 const glsl_type
*type
);
1046 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
1047 const glsl_type
*type
,
1048 enum ir_intrinsic_id id
);
1049 ir_function_signature
*_atomic_op3(const char *intrinsic
,
1050 builtin_available_predicate avail
,
1051 const glsl_type
*type
);
1057 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
1058 unsigned num_arguments
,
1060 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
1061 unsigned num_arguments
,
1063 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
1064 unsigned num_arguments
,
1066 ir_function_signature
*_image(image_prototype_ctr prototype
,
1067 const glsl_type
*image_type
,
1068 const char *intrinsic_name
,
1069 unsigned num_arguments
,
1071 enum ir_intrinsic_id id
);
1073 ir_function_signature
*_memory_barrier_intrinsic(
1074 builtin_available_predicate avail
,
1075 enum ir_intrinsic_id id
);
1076 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
1077 builtin_available_predicate avail
);
1079 ir_function_signature
*_ballot_intrinsic();
1080 ir_function_signature
*_ballot();
1081 ir_function_signature
*_read_first_invocation_intrinsic(const glsl_type
*type
);
1082 ir_function_signature
*_read_first_invocation(const glsl_type
*type
);
1083 ir_function_signature
*_read_invocation_intrinsic(const glsl_type
*type
);
1084 ir_function_signature
*_read_invocation(const glsl_type
*type
);
1087 ir_function_signature
*_invocation_interlock_intrinsic(
1088 builtin_available_predicate avail
,
1089 enum ir_intrinsic_id id
);
1090 ir_function_signature
*_invocation_interlock(
1091 const char *intrinsic_name
,
1092 builtin_available_predicate avail
);
1094 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
1095 const glsl_type
*type
);
1096 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
1097 const glsl_type
*type
);
1099 ir_function_signature
*_vote_intrinsic(builtin_available_predicate avail
,
1100 enum ir_intrinsic_id id
);
1101 ir_function_signature
*_vote(const char *intrinsic_name
,
1102 builtin_available_predicate avail
);
1113 enum image_function_flags
{
1114 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
1115 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
1116 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
1117 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
1118 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
1119 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
1120 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
1121 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
1122 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8),
1123 IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
= (1 << 9),
1126 } /* anonymous namespace */
1129 * Core builtin_builder functionality:
1132 builtin_builder::builtin_builder()
1138 builtin_builder::~builtin_builder()
1140 ralloc_free(mem_ctx
);
1143 ir_function_signature
*
1144 builtin_builder::find(_mesa_glsl_parse_state
*state
,
1145 const char *name
, exec_list
*actual_parameters
)
1147 /* The shader currently being compiled requested a built-in function;
1148 * it needs to link against builtin_builder::shader in order to get them.
1150 * Even if we don't find a matching signature, we still need to do this so
1151 * that the "no matching signature" error will list potential candidates
1152 * from the available built-ins.
1154 state
->uses_builtin_functions
= true;
1156 ir_function
*f
= shader
->symbols
->get_function(name
);
1160 ir_function_signature
*sig
=
1161 f
->matching_signature(state
, actual_parameters
, true);
1169 builtin_builder::initialize()
1171 /* If already initialized, don't do it again. */
1172 if (mem_ctx
!= NULL
)
1175 mem_ctx
= ralloc_context(NULL
);
1177 create_intrinsics();
1182 builtin_builder::release()
1184 ralloc_free(mem_ctx
);
1187 ralloc_free(shader
);
1192 builtin_builder::create_shader()
1194 /* The target doesn't actually matter. There's no target for generic
1195 * GLSL utility code that could be linked against any stage, so just
1196 * arbitrarily pick GL_VERTEX_SHADER.
1198 shader
= _mesa_new_shader(0, MESA_SHADER_VERTEX
);
1199 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
1205 * Create ir_function and ir_function_signature objects for each
1209 builtin_builder::create_intrinsics()
1211 add_function("__intrinsic_atomic_read",
1212 _atomic_counter_intrinsic(shader_atomic_counters
,
1213 ir_intrinsic_atomic_counter_read
),
1215 add_function("__intrinsic_atomic_increment",
1216 _atomic_counter_intrinsic(shader_atomic_counters
,
1217 ir_intrinsic_atomic_counter_increment
),
1219 add_function("__intrinsic_atomic_predecrement",
1220 _atomic_counter_intrinsic(shader_atomic_counters
,
1221 ir_intrinsic_atomic_counter_predecrement
),
1224 add_function("__intrinsic_atomic_add",
1225 _atomic_intrinsic2(buffer_atomics_supported
,
1226 glsl_type::uint_type
,
1227 ir_intrinsic_generic_atomic_add
),
1228 _atomic_intrinsic2(buffer_atomics_supported
,
1229 glsl_type::int_type
,
1230 ir_intrinsic_generic_atomic_add
),
1231 _atomic_intrinsic2(NV_shader_atomic_float_supported
,
1232 glsl_type::float_type
,
1233 ir_intrinsic_generic_atomic_add
),
1234 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1235 ir_intrinsic_atomic_counter_add
),
1237 add_function("__intrinsic_atomic_min",
1238 _atomic_intrinsic2(buffer_atomics_supported
,
1239 glsl_type::uint_type
,
1240 ir_intrinsic_generic_atomic_min
),
1241 _atomic_intrinsic2(buffer_atomics_supported
,
1242 glsl_type::int_type
,
1243 ir_intrinsic_generic_atomic_min
),
1244 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported
,
1245 glsl_type::float_type
,
1246 ir_intrinsic_generic_atomic_min
),
1247 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1248 ir_intrinsic_atomic_counter_min
),
1250 add_function("__intrinsic_atomic_max",
1251 _atomic_intrinsic2(buffer_atomics_supported
,
1252 glsl_type::uint_type
,
1253 ir_intrinsic_generic_atomic_max
),
1254 _atomic_intrinsic2(buffer_atomics_supported
,
1255 glsl_type::int_type
,
1256 ir_intrinsic_generic_atomic_max
),
1257 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported
,
1258 glsl_type::float_type
,
1259 ir_intrinsic_generic_atomic_max
),
1260 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1261 ir_intrinsic_atomic_counter_max
),
1263 add_function("__intrinsic_atomic_and",
1264 _atomic_intrinsic2(buffer_atomics_supported
,
1265 glsl_type::uint_type
,
1266 ir_intrinsic_generic_atomic_and
),
1267 _atomic_intrinsic2(buffer_atomics_supported
,
1268 glsl_type::int_type
,
1269 ir_intrinsic_generic_atomic_and
),
1270 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1271 ir_intrinsic_atomic_counter_and
),
1273 add_function("__intrinsic_atomic_or",
1274 _atomic_intrinsic2(buffer_atomics_supported
,
1275 glsl_type::uint_type
,
1276 ir_intrinsic_generic_atomic_or
),
1277 _atomic_intrinsic2(buffer_atomics_supported
,
1278 glsl_type::int_type
,
1279 ir_intrinsic_generic_atomic_or
),
1280 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1281 ir_intrinsic_atomic_counter_or
),
1283 add_function("__intrinsic_atomic_xor",
1284 _atomic_intrinsic2(buffer_atomics_supported
,
1285 glsl_type::uint_type
,
1286 ir_intrinsic_generic_atomic_xor
),
1287 _atomic_intrinsic2(buffer_atomics_supported
,
1288 glsl_type::int_type
,
1289 ir_intrinsic_generic_atomic_xor
),
1290 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1291 ir_intrinsic_atomic_counter_xor
),
1293 add_function("__intrinsic_atomic_exchange",
1294 _atomic_intrinsic2(buffer_atomics_supported
,
1295 glsl_type::uint_type
,
1296 ir_intrinsic_generic_atomic_exchange
),
1297 _atomic_intrinsic2(buffer_atomics_supported
,
1298 glsl_type::int_type
,
1299 ir_intrinsic_generic_atomic_exchange
),
1300 _atomic_intrinsic2(NV_shader_atomic_float_supported
,
1301 glsl_type::float_type
,
1302 ir_intrinsic_generic_atomic_exchange
),
1303 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1304 ir_intrinsic_atomic_counter_exchange
),
1306 add_function("__intrinsic_atomic_comp_swap",
1307 _atomic_intrinsic3(buffer_atomics_supported
,
1308 glsl_type::uint_type
,
1309 ir_intrinsic_generic_atomic_comp_swap
),
1310 _atomic_intrinsic3(buffer_atomics_supported
,
1311 glsl_type::int_type
,
1312 ir_intrinsic_generic_atomic_comp_swap
),
1313 _atomic_intrinsic3(INTEL_shader_atomic_float_minmax_supported
,
1314 glsl_type::float_type
,
1315 ir_intrinsic_generic_atomic_comp_swap
),
1316 _atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop
,
1317 ir_intrinsic_atomic_counter_comp_swap
),
1320 add_image_functions(false);
1322 add_function("__intrinsic_memory_barrier",
1323 _memory_barrier_intrinsic(shader_image_load_store
,
1324 ir_intrinsic_memory_barrier
),
1326 add_function("__intrinsic_group_memory_barrier",
1327 _memory_barrier_intrinsic(compute_shader
,
1328 ir_intrinsic_group_memory_barrier
),
1330 add_function("__intrinsic_memory_barrier_atomic_counter",
1331 _memory_barrier_intrinsic(compute_shader_supported
,
1332 ir_intrinsic_memory_barrier_atomic_counter
),
1334 add_function("__intrinsic_memory_barrier_buffer",
1335 _memory_barrier_intrinsic(compute_shader_supported
,
1336 ir_intrinsic_memory_barrier_buffer
),
1338 add_function("__intrinsic_memory_barrier_image",
1339 _memory_barrier_intrinsic(compute_shader_supported
,
1340 ir_intrinsic_memory_barrier_image
),
1342 add_function("__intrinsic_memory_barrier_shared",
1343 _memory_barrier_intrinsic(compute_shader
,
1344 ir_intrinsic_memory_barrier_shared
),
1347 add_function("__intrinsic_begin_invocation_interlock",
1348 _invocation_interlock_intrinsic(
1349 supports_arb_fragment_shader_interlock
,
1350 ir_intrinsic_begin_invocation_interlock
), NULL
);
1352 add_function("__intrinsic_end_invocation_interlock",
1353 _invocation_interlock_intrinsic(
1354 supports_arb_fragment_shader_interlock
,
1355 ir_intrinsic_end_invocation_interlock
), NULL
);
1357 add_function("__intrinsic_shader_clock",
1358 _shader_clock_intrinsic(shader_clock
,
1359 glsl_type::uvec2_type
),
1362 add_function("__intrinsic_vote_all",
1363 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_all
),
1365 add_function("__intrinsic_vote_any",
1366 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_any
),
1368 add_function("__intrinsic_vote_eq",
1369 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_eq
),
1372 add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL
);
1374 add_function("__intrinsic_read_invocation",
1375 _read_invocation_intrinsic(glsl_type::float_type
),
1376 _read_invocation_intrinsic(glsl_type::vec2_type
),
1377 _read_invocation_intrinsic(glsl_type::vec3_type
),
1378 _read_invocation_intrinsic(glsl_type::vec4_type
),
1380 _read_invocation_intrinsic(glsl_type::int_type
),
1381 _read_invocation_intrinsic(glsl_type::ivec2_type
),
1382 _read_invocation_intrinsic(glsl_type::ivec3_type
),
1383 _read_invocation_intrinsic(glsl_type::ivec4_type
),
1385 _read_invocation_intrinsic(glsl_type::uint_type
),
1386 _read_invocation_intrinsic(glsl_type::uvec2_type
),
1387 _read_invocation_intrinsic(glsl_type::uvec3_type
),
1388 _read_invocation_intrinsic(glsl_type::uvec4_type
),
1391 add_function("__intrinsic_read_first_invocation",
1392 _read_first_invocation_intrinsic(glsl_type::float_type
),
1393 _read_first_invocation_intrinsic(glsl_type::vec2_type
),
1394 _read_first_invocation_intrinsic(glsl_type::vec3_type
),
1395 _read_first_invocation_intrinsic(glsl_type::vec4_type
),
1397 _read_first_invocation_intrinsic(glsl_type::int_type
),
1398 _read_first_invocation_intrinsic(glsl_type::ivec2_type
),
1399 _read_first_invocation_intrinsic(glsl_type::ivec3_type
),
1400 _read_first_invocation_intrinsic(glsl_type::ivec4_type
),
1402 _read_first_invocation_intrinsic(glsl_type::uint_type
),
1403 _read_first_invocation_intrinsic(glsl_type::uvec2_type
),
1404 _read_first_invocation_intrinsic(glsl_type::uvec3_type
),
1405 _read_first_invocation_intrinsic(glsl_type::uvec4_type
),
1411 * Create ir_function and ir_function_signature objects for each built-in.
1413 * Contains a list of every available built-in.
1416 builtin_builder::create_builtins()
1419 add_function(#NAME, \
1420 _##NAME(glsl_type::float_type), \
1421 _##NAME(glsl_type::vec2_type), \
1422 _##NAME(glsl_type::vec3_type), \
1423 _##NAME(glsl_type::vec4_type), \
1427 add_function(#NAME, \
1428 _##NAME(always_available, glsl_type::float_type), \
1429 _##NAME(always_available, glsl_type::vec2_type), \
1430 _##NAME(always_available, glsl_type::vec3_type), \
1431 _##NAME(always_available, glsl_type::vec4_type), \
1432 _##NAME(fp64, glsl_type::double_type), \
1433 _##NAME(fp64, glsl_type::dvec2_type), \
1434 _##NAME(fp64, glsl_type::dvec3_type), \
1435 _##NAME(fp64, glsl_type::dvec4_type), \
1438 #define FD130(NAME) \
1439 add_function(#NAME, \
1440 _##NAME(v130, glsl_type::float_type), \
1441 _##NAME(v130, glsl_type::vec2_type), \
1442 _##NAME(v130, glsl_type::vec3_type), \
1443 _##NAME(v130, glsl_type::vec4_type), \
1444 _##NAME(fp64, glsl_type::double_type), \
1445 _##NAME(fp64, glsl_type::dvec2_type), \
1446 _##NAME(fp64, glsl_type::dvec3_type), \
1447 _##NAME(fp64, glsl_type::dvec4_type), \
1450 #define FDGS5(NAME) \
1451 add_function(#NAME, \
1452 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1453 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1454 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1455 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1456 _##NAME(fp64, glsl_type::double_type), \
1457 _##NAME(fp64, glsl_type::dvec2_type), \
1458 _##NAME(fp64, glsl_type::dvec3_type), \
1459 _##NAME(fp64, glsl_type::dvec4_type), \
1463 add_function(#NAME, \
1464 _##NAME(glsl_type::float_type), \
1465 _##NAME(glsl_type::vec2_type), \
1466 _##NAME(glsl_type::vec3_type), \
1467 _##NAME(glsl_type::vec4_type), \
1468 _##NAME(glsl_type::int_type), \
1469 _##NAME(glsl_type::ivec2_type), \
1470 _##NAME(glsl_type::ivec3_type), \
1471 _##NAME(glsl_type::ivec4_type), \
1474 #define FI64(NAME) \
1475 add_function(#NAME, \
1476 _##NAME(always_available, glsl_type::float_type), \
1477 _##NAME(always_available, glsl_type::vec2_type), \
1478 _##NAME(always_available, glsl_type::vec3_type), \
1479 _##NAME(always_available, glsl_type::vec4_type), \
1480 _##NAME(always_available, glsl_type::int_type), \
1481 _##NAME(always_available, glsl_type::ivec2_type), \
1482 _##NAME(always_available, glsl_type::ivec3_type), \
1483 _##NAME(always_available, glsl_type::ivec4_type), \
1484 _##NAME(fp64, glsl_type::double_type), \
1485 _##NAME(fp64, glsl_type::dvec2_type), \
1486 _##NAME(fp64, glsl_type::dvec3_type), \
1487 _##NAME(fp64, glsl_type::dvec4_type), \
1488 _##NAME(int64, glsl_type::int64_t_type), \
1489 _##NAME(int64, glsl_type::i64vec2_type), \
1490 _##NAME(int64, glsl_type::i64vec3_type), \
1491 _##NAME(int64, glsl_type::i64vec4_type), \
1494 #define FIUD_VEC(NAME) \
1495 add_function(#NAME, \
1496 _##NAME(always_available, glsl_type::vec2_type), \
1497 _##NAME(always_available, glsl_type::vec3_type), \
1498 _##NAME(always_available, glsl_type::vec4_type), \
1500 _##NAME(always_available, glsl_type::ivec2_type), \
1501 _##NAME(always_available, glsl_type::ivec3_type), \
1502 _##NAME(always_available, glsl_type::ivec4_type), \
1504 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \
1505 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \
1506 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \
1507 _##NAME(fp64, glsl_type::dvec2_type), \
1508 _##NAME(fp64, glsl_type::dvec3_type), \
1509 _##NAME(fp64, glsl_type::dvec4_type), \
1510 _##NAME(int64, glsl_type::int64_t_type), \
1511 _##NAME(int64, glsl_type::i64vec2_type), \
1512 _##NAME(int64, glsl_type::i64vec3_type), \
1513 _##NAME(int64, glsl_type::i64vec4_type), \
1514 _##NAME(int64, glsl_type::uint64_t_type), \
1515 _##NAME(int64, glsl_type::u64vec2_type), \
1516 _##NAME(int64, glsl_type::u64vec3_type), \
1517 _##NAME(int64, glsl_type::u64vec4_type), \
1521 add_function(#NAME, \
1522 _##NAME(glsl_type::int_type), \
1523 _##NAME(glsl_type::ivec2_type), \
1524 _##NAME(glsl_type::ivec3_type), \
1525 _##NAME(glsl_type::ivec4_type), \
1527 _##NAME(glsl_type::uint_type), \
1528 _##NAME(glsl_type::uvec2_type), \
1529 _##NAME(glsl_type::uvec3_type), \
1530 _##NAME(glsl_type::uvec4_type), \
1533 #define FIUBD_VEC(NAME) \
1534 add_function(#NAME, \
1535 _##NAME(always_available, glsl_type::vec2_type), \
1536 _##NAME(always_available, glsl_type::vec3_type), \
1537 _##NAME(always_available, glsl_type::vec4_type), \
1539 _##NAME(always_available, glsl_type::ivec2_type), \
1540 _##NAME(always_available, glsl_type::ivec3_type), \
1541 _##NAME(always_available, glsl_type::ivec4_type), \
1543 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \
1544 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \
1545 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \
1547 _##NAME(always_available, glsl_type::bvec2_type), \
1548 _##NAME(always_available, glsl_type::bvec3_type), \
1549 _##NAME(always_available, glsl_type::bvec4_type), \
1551 _##NAME(fp64, glsl_type::dvec2_type), \
1552 _##NAME(fp64, glsl_type::dvec3_type), \
1553 _##NAME(fp64, glsl_type::dvec4_type), \
1554 _##NAME(int64, glsl_type::int64_t_type), \
1555 _##NAME(int64, glsl_type::i64vec2_type), \
1556 _##NAME(int64, glsl_type::i64vec3_type), \
1557 _##NAME(int64, glsl_type::i64vec4_type), \
1558 _##NAME(int64, glsl_type::uint64_t_type), \
1559 _##NAME(int64, glsl_type::u64vec2_type), \
1560 _##NAME(int64, glsl_type::u64vec3_type), \
1561 _##NAME(int64, glsl_type::u64vec4_type), \
1564 #define FIUD2_MIXED(NAME) \
1565 add_function(#NAME, \
1566 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1567 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1568 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1569 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1571 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1572 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1573 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1575 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1576 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1577 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1578 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1580 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1581 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1582 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1584 _##NAME(v130_or_gpu_shader4, glsl_type::uint_type, glsl_type::uint_type), \
1585 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uint_type), \
1586 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uint_type), \
1587 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uint_type), \
1589 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1590 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1591 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1593 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1594 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1595 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1596 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1597 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1598 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1599 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1601 _##NAME(int64, glsl_type::int64_t_type, glsl_type::int64_t_type), \
1602 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::int64_t_type), \
1603 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::int64_t_type), \
1604 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::int64_t_type), \
1605 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::i64vec2_type), \
1606 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::i64vec3_type), \
1607 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::i64vec4_type), \
1608 _##NAME(int64, glsl_type::uint64_t_type, glsl_type::uint64_t_type), \
1609 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::uint64_t_type), \
1610 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::uint64_t_type), \
1611 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::uint64_t_type), \
1612 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::u64vec2_type), \
1613 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::u64vec3_type), \
1614 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::u64vec4_type), \
1625 add_function("atan",
1626 _atan(glsl_type::float_type
),
1627 _atan(glsl_type::vec2_type
),
1628 _atan(glsl_type::vec3_type
),
1629 _atan(glsl_type::vec4_type
),
1630 _atan2(glsl_type::float_type
),
1631 _atan2(glsl_type::vec2_type
),
1632 _atan2(glsl_type::vec3_type
),
1633 _atan2(glsl_type::vec4_type
),
1658 add_function("truncate",
1659 _truncate(gpu_shader4
, glsl_type::float_type
),
1660 _truncate(gpu_shader4
, glsl_type::vec2_type
),
1661 _truncate(gpu_shader4
, glsl_type::vec3_type
),
1662 _truncate(gpu_shader4
, glsl_type::vec4_type
),
1667 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1668 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1669 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1670 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1672 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1673 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1674 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1676 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1677 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1678 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1679 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1681 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1682 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1683 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1693 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1694 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1695 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1696 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1698 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1699 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1700 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1702 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1703 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1704 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1705 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1707 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1708 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1709 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1711 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1712 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1713 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1714 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1716 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1717 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1718 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1719 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1721 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1722 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1723 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1724 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1726 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1727 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1728 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1729 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1731 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1732 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1733 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1734 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1736 _mix_sel(int64
, glsl_type::int64_t_type
, glsl_type::bool_type
),
1737 _mix_sel(int64
, glsl_type::i64vec2_type
, glsl_type::bvec2_type
),
1738 _mix_sel(int64
, glsl_type::i64vec3_type
, glsl_type::bvec3_type
),
1739 _mix_sel(int64
, glsl_type::i64vec4_type
, glsl_type::bvec4_type
),
1741 _mix_sel(int64
, glsl_type::uint64_t_type
, glsl_type::bool_type
),
1742 _mix_sel(int64
, glsl_type::u64vec2_type
, glsl_type::bvec2_type
),
1743 _mix_sel(int64
, glsl_type::u64vec3_type
, glsl_type::bvec3_type
),
1744 _mix_sel(int64
, glsl_type::u64vec4_type
, glsl_type::bvec4_type
),
1747 add_function("step",
1748 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1749 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1750 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1751 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1753 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1754 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1755 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1756 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1757 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1758 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1759 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1761 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1762 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1763 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1766 add_function("smoothstep",
1767 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1768 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1769 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1770 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1772 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1773 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1774 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1775 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1776 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1777 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1778 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1780 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1781 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1782 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1790 add_function("intBitsToFloat",
1791 _intBitsToFloat(glsl_type::int_type
),
1792 _intBitsToFloat(glsl_type::ivec2_type
),
1793 _intBitsToFloat(glsl_type::ivec3_type
),
1794 _intBitsToFloat(glsl_type::ivec4_type
),
1796 add_function("uintBitsToFloat",
1797 _uintBitsToFloat(glsl_type::uint_type
),
1798 _uintBitsToFloat(glsl_type::uvec2_type
),
1799 _uintBitsToFloat(glsl_type::uvec3_type
),
1800 _uintBitsToFloat(glsl_type::uvec4_type
),
1803 add_function("doubleBitsToInt64",
1804 _doubleBitsToInt64(int64_fp64
, glsl_type::double_type
),
1805 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec2_type
),
1806 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec3_type
),
1807 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec4_type
),
1810 add_function("doubleBitsToUint64",
1811 _doubleBitsToUint64(int64_fp64
, glsl_type::double_type
),
1812 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec2_type
),
1813 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec3_type
),
1814 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec4_type
),
1817 add_function("int64BitsToDouble",
1818 _int64BitsToDouble(int64_fp64
, glsl_type::int64_t_type
),
1819 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec2_type
),
1820 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec3_type
),
1821 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec4_type
),
1824 add_function("uint64BitsToDouble",
1825 _uint64BitsToDouble(int64_fp64
, glsl_type::uint64_t_type
),
1826 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec2_type
),
1827 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec3_type
),
1828 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec4_type
),
1831 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1832 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1833 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1834 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1835 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1836 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1837 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1838 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1839 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1840 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1841 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1842 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1844 add_function("packInt2x32", _packInt2x32(int64
), NULL
);
1845 add_function("unpackInt2x32", _unpackInt2x32(int64
), NULL
);
1846 add_function("packUint2x32", _packUint2x32(int64
), NULL
);
1847 add_function("unpackUint2x32", _unpackUint2x32(int64
), NULL
);
1853 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1854 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1857 add_function("ftransform", _ftransform(), NULL
);
1862 add_function("matrixCompMult",
1863 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1864 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1865 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1866 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1867 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1868 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1869 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1870 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1871 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1872 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1873 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1874 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1875 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1876 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1877 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1878 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1879 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1880 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1882 add_function("outerProduct",
1883 _outerProduct(v120
, glsl_type::mat2_type
),
1884 _outerProduct(v120
, glsl_type::mat3_type
),
1885 _outerProduct(v120
, glsl_type::mat4_type
),
1886 _outerProduct(v120
, glsl_type::mat2x3_type
),
1887 _outerProduct(v120
, glsl_type::mat2x4_type
),
1888 _outerProduct(v120
, glsl_type::mat3x2_type
),
1889 _outerProduct(v120
, glsl_type::mat3x4_type
),
1890 _outerProduct(v120
, glsl_type::mat4x2_type
),
1891 _outerProduct(v120
, glsl_type::mat4x3_type
),
1892 _outerProduct(fp64
, glsl_type::dmat2_type
),
1893 _outerProduct(fp64
, glsl_type::dmat3_type
),
1894 _outerProduct(fp64
, glsl_type::dmat4_type
),
1895 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1896 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1897 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1898 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1899 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1900 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1902 add_function("determinant",
1903 _determinant_mat2(v120
, glsl_type::mat2_type
),
1904 _determinant_mat3(v120
, glsl_type::mat3_type
),
1905 _determinant_mat4(v120
, glsl_type::mat4_type
),
1906 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1907 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1908 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1911 add_function("inverse",
1912 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1913 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1914 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1915 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1916 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1917 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1919 add_function("transpose",
1920 _transpose(v120
, glsl_type::mat2_type
),
1921 _transpose(v120
, glsl_type::mat3_type
),
1922 _transpose(v120
, glsl_type::mat4_type
),
1923 _transpose(v120
, glsl_type::mat2x3_type
),
1924 _transpose(v120
, glsl_type::mat2x4_type
),
1925 _transpose(v120
, glsl_type::mat3x2_type
),
1926 _transpose(v120
, glsl_type::mat3x4_type
),
1927 _transpose(v120
, glsl_type::mat4x2_type
),
1928 _transpose(v120
, glsl_type::mat4x3_type
),
1929 _transpose(fp64
, glsl_type::dmat2_type
),
1930 _transpose(fp64
, glsl_type::dmat3_type
),
1931 _transpose(fp64
, glsl_type::dmat4_type
),
1932 _transpose(fp64
, glsl_type::dmat2x3_type
),
1933 _transpose(fp64
, glsl_type::dmat2x4_type
),
1934 _transpose(fp64
, glsl_type::dmat3x2_type
),
1935 _transpose(fp64
, glsl_type::dmat3x4_type
),
1936 _transpose(fp64
, glsl_type::dmat4x2_type
),
1937 _transpose(fp64
, glsl_type::dmat4x3_type
),
1940 FIUD_VEC(lessThanEqual
)
1941 FIUD_VEC(greaterThan
)
1942 FIUD_VEC(greaterThanEqual
)
1947 _any(glsl_type::bvec2_type
),
1948 _any(glsl_type::bvec3_type
),
1949 _any(glsl_type::bvec4_type
),
1953 _all(glsl_type::bvec2_type
),
1954 _all(glsl_type::bvec3_type
),
1955 _all(glsl_type::bvec4_type
),
1959 _not(glsl_type::bvec2_type
),
1960 _not(glsl_type::bvec3_type
),
1961 _not(glsl_type::bvec4_type
),
1964 add_function("textureSize",
1965 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1966 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1967 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1969 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1970 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1971 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1973 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1974 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1975 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1977 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1978 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1979 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1981 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1982 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1983 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1985 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1986 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1987 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1988 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1989 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1990 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1992 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1993 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1995 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1996 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1997 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1998 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
2000 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
2001 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
2002 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
2003 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
2005 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
2006 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
2007 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
2008 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
2009 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
2010 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
2012 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
2013 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
2014 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
2017 add_function("textureSamples",
2018 _textureSamples(shader_samples
, glsl_type::sampler2DMS_type
),
2019 _textureSamples(shader_samples
, glsl_type::isampler2DMS_type
),
2020 _textureSamples(shader_samples
, glsl_type::usampler2DMS_type
),
2022 _textureSamples(shader_samples
, glsl_type::sampler2DMSArray_type
),
2023 _textureSamples(shader_samples
, glsl_type::isampler2DMSArray_type
),
2024 _textureSamples(shader_samples
, glsl_type::usampler2DMSArray_type
),
2027 add_function("texture",
2028 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2029 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2030 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2032 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2033 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2034 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2036 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2037 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2038 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2040 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2041 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2042 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2044 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2045 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2046 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2048 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2049 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2050 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2052 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2053 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2054 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2056 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2057 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2058 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2060 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2061 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2062 /* samplerCubeArrayShadow is special; it has an extra parameter
2063 * for the shadow comparator since there is no vec5 type.
2065 _textureCubeArrayShadow(texture_cube_map_array
, glsl_type::samplerCubeArrayShadow_type
),
2067 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2068 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2069 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2071 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2073 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2075 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2076 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2077 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2079 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2080 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2081 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2083 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2084 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2085 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2087 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2088 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2089 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2091 _texture(ir_txb
, v130_derivatives_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2092 _texture(ir_txb
, v130_derivatives_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2093 _texture(ir_txb
, v130_derivatives_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2095 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2096 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2097 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2099 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2100 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2101 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2103 _texture(ir_txb
, derivatives_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2104 _texture(ir_txb
, derivatives_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2105 _texture(ir_txb
, derivatives_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2107 _texture(ir_txb
, v130_derivatives_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2110 add_function("textureLod",
2111 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2112 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2113 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2115 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2116 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2117 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2119 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2120 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2121 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2123 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2124 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2125 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2127 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2128 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2130 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2131 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2132 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2134 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2135 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2136 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2138 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2139 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2140 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2142 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2145 add_function("textureOffset",
2146 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2147 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2148 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2150 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2151 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2152 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2154 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2155 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2156 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2158 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2159 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2160 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2162 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2164 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2165 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2167 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2168 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2169 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2171 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2172 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2173 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2175 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2176 /* The next one was forgotten in GLSL 1.30 spec. It's from
2177 * EXT_gpu_shader4 originally. It was added in 4.30 with the
2178 * wrong syntax. This was corrected in 4.40. 4.30 indicates
2179 * that it was intended to be included previously, so allow it
2182 _texture(ir_tex
, v130_desktop
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2184 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2185 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2186 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2188 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2189 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2190 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2192 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2193 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2194 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2196 _texture(ir_txb
, v130_derivatives_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2197 _texture(ir_txb
, v130_derivatives_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2199 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2200 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2201 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2203 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2204 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2205 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2207 _texture(ir_txb
, v130_derivatives_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2210 add_function("textureProj",
2211 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2212 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2213 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2214 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2215 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2216 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2218 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2219 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2220 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2221 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2222 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2223 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2225 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2226 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2227 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2229 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2230 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2232 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2233 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2234 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2235 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2237 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2238 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2239 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2240 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2242 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2244 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2245 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2246 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2247 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2248 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2249 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2251 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2252 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2253 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2254 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2255 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2256 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2258 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2259 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2260 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2262 _texture(ir_txb
, v130_derivatives_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2263 _texture(ir_txb
, v130_derivatives_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2266 add_function("texelFetch",
2267 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
2268 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
2269 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
2271 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
2272 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
2273 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
2275 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
2276 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
2277 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
2279 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
2280 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
2281 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
2283 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
2284 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
2285 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
2287 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
2288 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
2289 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
2291 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
2292 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
2293 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
2295 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2296 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2297 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2299 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2300 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2301 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2303 _texelFetch(texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::ivec2_type
),
2308 add_function("texelFetchOffset",
2309 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2310 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2311 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2313 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2314 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2315 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2317 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2318 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2319 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2321 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2322 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2323 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2325 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2326 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2327 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2329 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2330 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2331 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2335 add_function("textureProjOffset",
2336 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2337 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2338 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2339 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2340 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2341 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2343 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2344 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2345 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2346 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2347 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2348 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2350 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2351 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2352 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2354 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2355 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2357 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2358 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2359 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2360 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2361 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2362 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2364 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2366 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2367 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2368 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2369 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2370 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2371 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2373 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2374 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2375 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2376 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2377 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2378 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2380 _texture(ir_txb
, v130_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2381 _texture(ir_txb
, v130_derivatives_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2382 _texture(ir_txb
, v130_derivatives_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2384 _texture(ir_txb
, v130_derivatives_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2385 _texture(ir_txb
, v130_derivatives_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2388 add_function("textureLodOffset",
2389 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2390 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2391 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2393 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2394 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2395 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2397 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2398 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2399 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2401 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2402 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2404 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2405 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2406 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2408 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2409 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2410 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2412 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2415 add_function("textureProjLod",
2416 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2417 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2418 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2419 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2420 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2421 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2423 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2424 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2425 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2426 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2427 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2428 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2430 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2431 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2432 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2434 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2435 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2438 add_function("textureProjLodOffset",
2439 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2440 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2441 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2442 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2443 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2444 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2446 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2447 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2448 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2449 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2450 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2451 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2453 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2454 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2455 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2457 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2458 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2461 add_function("textureGrad",
2462 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2463 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2464 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2466 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2467 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2468 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2470 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2471 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2472 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2474 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2475 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2476 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2478 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2479 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2480 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2482 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2484 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2485 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2486 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2488 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2489 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2490 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2492 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2493 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2494 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2496 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2497 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2498 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2500 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2501 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2504 add_function("textureGradOffset",
2505 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2506 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2507 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2509 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2510 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2511 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2513 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2514 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2515 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2517 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2518 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2519 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2521 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2523 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2524 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2526 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2527 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2528 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2530 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2531 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2532 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2534 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2535 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2538 add_function("textureProjGrad",
2539 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2540 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2541 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2542 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2543 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2544 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2546 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2547 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2548 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2549 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2550 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2551 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2553 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2554 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2555 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2557 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2558 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2559 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2560 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2561 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2562 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2564 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2566 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2567 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2570 add_function("textureProjGradOffset",
2571 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2572 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2573 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2574 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2575 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2576 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2578 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2579 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2580 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2581 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2582 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2583 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2585 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2586 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2587 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2589 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2590 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2591 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2592 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2593 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2594 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2596 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2598 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2599 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2602 add_function("EmitVertex", _EmitVertex(), NULL
);
2603 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2604 add_function("EmitStreamVertex",
2605 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2606 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2608 add_function("EndStreamPrimitive",
2609 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2610 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2612 add_function("barrier", _barrier(), NULL
);
2614 add_function("textureQueryLOD",
2615 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2616 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2617 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2619 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2620 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2621 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2623 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2624 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2625 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2627 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2628 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2629 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2631 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2632 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2633 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2635 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2636 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2637 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2639 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2640 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2641 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2643 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2644 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2645 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2646 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2647 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2648 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2651 add_function("textureQueryLod",
2652 _textureQueryLod(v400_derivatives_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2653 _textureQueryLod(v400_derivatives_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2654 _textureQueryLod(v400_derivatives_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2656 _textureQueryLod(v400_derivatives_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2657 _textureQueryLod(v400_derivatives_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2658 _textureQueryLod(v400_derivatives_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2660 _textureQueryLod(v400_derivatives_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2661 _textureQueryLod(v400_derivatives_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2662 _textureQueryLod(v400_derivatives_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2664 _textureQueryLod(v400_derivatives_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2665 _textureQueryLod(v400_derivatives_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2666 _textureQueryLod(v400_derivatives_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2668 _textureQueryLod(v400_derivatives_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2669 _textureQueryLod(v400_derivatives_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2670 _textureQueryLod(v400_derivatives_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2672 _textureQueryLod(v400_derivatives_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2673 _textureQueryLod(v400_derivatives_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2674 _textureQueryLod(v400_derivatives_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2676 _textureQueryLod(v400_derivatives_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2677 _textureQueryLod(v400_derivatives_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2678 _textureQueryLod(v400_derivatives_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2680 _textureQueryLod(v400_derivatives_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2681 _textureQueryLod(v400_derivatives_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2682 _textureQueryLod(v400_derivatives_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2683 _textureQueryLod(v400_derivatives_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2684 _textureQueryLod(v400_derivatives_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2685 _textureQueryLod(v400_derivatives_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2688 add_function("textureQueryLevels",
2689 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1D_type
),
2690 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2D_type
),
2691 _textureQueryLevels(texture_query_levels
, glsl_type::sampler3D_type
),
2692 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCube_type
),
2693 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArray_type
),
2694 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArray_type
),
2695 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArray_type
),
2696 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DShadow_type
),
2697 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DShadow_type
),
2698 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeShadow_type
),
2699 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArrayShadow_type
),
2700 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArrayShadow_type
),
2701 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArrayShadow_type
),
2703 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1D_type
),
2704 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2D_type
),
2705 _textureQueryLevels(texture_query_levels
, glsl_type::isampler3D_type
),
2706 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCube_type
),
2707 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1DArray_type
),
2708 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2DArray_type
),
2709 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCubeArray_type
),
2711 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1D_type
),
2712 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2D_type
),
2713 _textureQueryLevels(texture_query_levels
, glsl_type::usampler3D_type
),
2714 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCube_type
),
2715 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1DArray_type
),
2716 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2DArray_type
),
2717 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCubeArray_type
),
2721 add_function("textureSamplesIdenticalEXT",
2722 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2723 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2724 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2726 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2727 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2728 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2731 add_function("texture1D",
2732 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2733 _texture(ir_txb
, v110_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2736 add_function("texture1DArray",
2737 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2738 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2741 add_function("texture1DProj",
2742 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2743 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2744 _texture(ir_txb
, v110_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2745 _texture(ir_txb
, v110_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2748 add_function("texture1DLod",
2749 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2752 add_function("texture1DArrayLod",
2753 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2756 add_function("texture1DProjLod",
2757 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2758 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2761 add_function("texture2D",
2762 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2763 _texture(ir_txb
, derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2764 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2767 add_function("texture2DArray",
2768 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2769 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2772 add_function("texture2DProj",
2773 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2774 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2775 _texture(ir_txb
, derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2776 _texture(ir_txb
, derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2777 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2778 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2781 add_function("texture2DLod",
2782 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2785 add_function("texture2DArrayLod",
2786 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2789 add_function("texture2DProjLod",
2790 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2791 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2794 add_function("texture3D",
2795 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2796 _texture(ir_txb
, derivatives_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2799 add_function("texture3DProj",
2800 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2801 _texture(ir_txb
, derivatives_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2804 add_function("texture3DLod",
2805 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2808 add_function("texture3DProjLod",
2809 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2812 add_function("textureCube",
2813 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2814 _texture(ir_txb
, derivatives_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2817 add_function("textureCubeLod",
2818 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2821 add_function("texture2DRect",
2822 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2825 add_function("texture2DRectProj",
2826 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2827 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2830 add_function("shadow1D",
2831 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2832 _texture(ir_txb
, v110_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2835 add_function("shadow1DArray",
2836 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2837 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2840 add_function("shadow2D",
2841 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2842 _texture(ir_txb
, v110_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2845 add_function("shadow2DArray",
2846 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2847 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2850 add_function("shadow1DProj",
2851 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2852 _texture(ir_txb
, v110_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2855 add_function("shadow2DProj",
2856 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2857 _texture(ir_txb
, v110_derivatives_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2860 add_function("shadow1DLod",
2861 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2864 add_function("shadow2DLod",
2865 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2868 add_function("shadow1DArrayLod",
2869 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2872 add_function("shadow1DProjLod",
2873 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2876 add_function("shadow2DProjLod",
2877 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2880 add_function("shadow2DRect",
2881 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2884 add_function("shadow2DRectProj",
2885 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2888 add_function("texture1DGradARB",
2889 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2892 add_function("texture1DProjGradARB",
2893 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2894 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2897 add_function("texture2DGradARB",
2898 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2901 add_function("texture2DProjGradARB",
2902 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2903 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2906 add_function("texture3DGradARB",
2907 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2910 add_function("texture3DProjGradARB",
2911 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2914 add_function("textureCubeGradARB",
2915 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2918 add_function("shadow1DGradARB",
2919 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2922 add_function("shadow1DProjGradARB",
2923 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2926 add_function("shadow2DGradARB",
2927 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2930 add_function("shadow2DProjGradARB",
2931 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2934 add_function("texture2DRectGradARB",
2935 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2938 add_function("texture2DRectProjGradARB",
2939 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2940 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2943 add_function("shadow2DRectGradARB",
2944 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2947 add_function("shadow2DRectProjGradARB",
2948 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2951 add_function("texture4",
2952 _texture(ir_tg4
, texture_texture4
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2955 add_function("textureGather",
2956 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2957 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2958 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2960 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2961 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2962 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2964 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2965 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2966 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2968 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2969 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2970 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2972 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2973 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2974 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2976 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2977 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2978 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2980 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2981 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2982 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2984 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2985 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2986 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2988 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2989 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2990 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2992 _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
),
2993 _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
),
2994 _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
),
2996 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2997 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2998 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2999 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
3000 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
3003 add_function("textureGatherOffset",
3004 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
3005 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
3006 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
3008 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
3009 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
3010 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
3012 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
3013 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
3014 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
3016 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
3017 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
3018 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
3020 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
3021 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
3022 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
3024 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
3025 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
3026 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
3028 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
3029 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
3030 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
3032 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
3033 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
3034 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
3036 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
3037 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
3038 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
3040 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
3041 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
3042 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
3044 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
3045 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
3046 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
3048 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
3049 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
3052 add_function("textureGatherOffsets",
3053 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3054 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3055 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3057 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3058 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3059 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3061 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3062 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3063 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3065 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3066 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3067 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3069 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3070 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3071 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3073 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3074 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3075 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3077 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3078 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3079 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3104 add_function("ldexp",
3105 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
3106 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
3107 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
3108 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
3109 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
3110 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
3111 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
3112 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
3115 add_function("frexp",
3116 _frexp(glsl_type::float_type
, glsl_type::int_type
),
3117 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
3118 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
3119 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
3120 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
3121 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
3122 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
3123 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
3125 add_function("uaddCarry",
3126 _uaddCarry(glsl_type::uint_type
),
3127 _uaddCarry(glsl_type::uvec2_type
),
3128 _uaddCarry(glsl_type::uvec3_type
),
3129 _uaddCarry(glsl_type::uvec4_type
),
3131 add_function("usubBorrow",
3132 _usubBorrow(glsl_type::uint_type
),
3133 _usubBorrow(glsl_type::uvec2_type
),
3134 _usubBorrow(glsl_type::uvec3_type
),
3135 _usubBorrow(glsl_type::uvec4_type
),
3137 add_function("imulExtended",
3138 _mulExtended(glsl_type::int_type
),
3139 _mulExtended(glsl_type::ivec2_type
),
3140 _mulExtended(glsl_type::ivec3_type
),
3141 _mulExtended(glsl_type::ivec4_type
),
3143 add_function("umulExtended",
3144 _mulExtended(glsl_type::uint_type
),
3145 _mulExtended(glsl_type::uvec2_type
),
3146 _mulExtended(glsl_type::uvec3_type
),
3147 _mulExtended(glsl_type::uvec4_type
),
3149 add_function("interpolateAtCentroid",
3150 _interpolateAtCentroid(glsl_type::float_type
),
3151 _interpolateAtCentroid(glsl_type::vec2_type
),
3152 _interpolateAtCentroid(glsl_type::vec3_type
),
3153 _interpolateAtCentroid(glsl_type::vec4_type
),
3155 add_function("interpolateAtOffset",
3156 _interpolateAtOffset(glsl_type::float_type
),
3157 _interpolateAtOffset(glsl_type::vec2_type
),
3158 _interpolateAtOffset(glsl_type::vec3_type
),
3159 _interpolateAtOffset(glsl_type::vec4_type
),
3161 add_function("interpolateAtSample",
3162 _interpolateAtSample(glsl_type::float_type
),
3163 _interpolateAtSample(glsl_type::vec2_type
),
3164 _interpolateAtSample(glsl_type::vec3_type
),
3165 _interpolateAtSample(glsl_type::vec4_type
),
3168 add_function("atomicCounter",
3169 _atomic_counter_op("__intrinsic_atomic_read",
3170 shader_atomic_counters
),
3172 add_function("atomicCounterIncrement",
3173 _atomic_counter_op("__intrinsic_atomic_increment",
3174 shader_atomic_counters
),
3176 add_function("atomicCounterDecrement",
3177 _atomic_counter_op("__intrinsic_atomic_predecrement",
3178 shader_atomic_counters
),
3181 add_function("atomicCounterAddARB",
3182 _atomic_counter_op1("__intrinsic_atomic_add",
3183 shader_atomic_counter_ops
),
3185 add_function("atomicCounterSubtractARB",
3186 _atomic_counter_op1("__intrinsic_atomic_sub",
3187 shader_atomic_counter_ops
),
3189 add_function("atomicCounterMinARB",
3190 _atomic_counter_op1("__intrinsic_atomic_min",
3191 shader_atomic_counter_ops
),
3193 add_function("atomicCounterMaxARB",
3194 _atomic_counter_op1("__intrinsic_atomic_max",
3195 shader_atomic_counter_ops
),
3197 add_function("atomicCounterAndARB",
3198 _atomic_counter_op1("__intrinsic_atomic_and",
3199 shader_atomic_counter_ops
),
3201 add_function("atomicCounterOrARB",
3202 _atomic_counter_op1("__intrinsic_atomic_or",
3203 shader_atomic_counter_ops
),
3205 add_function("atomicCounterXorARB",
3206 _atomic_counter_op1("__intrinsic_atomic_xor",
3207 shader_atomic_counter_ops
),
3209 add_function("atomicCounterExchangeARB",
3210 _atomic_counter_op1("__intrinsic_atomic_exchange",
3211 shader_atomic_counter_ops
),
3213 add_function("atomicCounterCompSwapARB",
3214 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3215 shader_atomic_counter_ops
),
3218 add_function("atomicCounterAdd",
3219 _atomic_counter_op1("__intrinsic_atomic_add",
3222 add_function("atomicCounterSubtract",
3223 _atomic_counter_op1("__intrinsic_atomic_sub",
3226 add_function("atomicCounterMin",
3227 _atomic_counter_op1("__intrinsic_atomic_min",
3230 add_function("atomicCounterMax",
3231 _atomic_counter_op1("__intrinsic_atomic_max",
3234 add_function("atomicCounterAnd",
3235 _atomic_counter_op1("__intrinsic_atomic_and",
3238 add_function("atomicCounterOr",
3239 _atomic_counter_op1("__intrinsic_atomic_or",
3242 add_function("atomicCounterXor",
3243 _atomic_counter_op1("__intrinsic_atomic_xor",
3246 add_function("atomicCounterExchange",
3247 _atomic_counter_op1("__intrinsic_atomic_exchange",
3250 add_function("atomicCounterCompSwap",
3251 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3255 add_function("atomicAdd",
3256 _atomic_op2("__intrinsic_atomic_add",
3257 buffer_atomics_supported
,
3258 glsl_type::uint_type
),
3259 _atomic_op2("__intrinsic_atomic_add",
3260 buffer_atomics_supported
,
3261 glsl_type::int_type
),
3262 _atomic_op2("__intrinsic_atomic_add",
3263 shader_atomic_float_add
,
3264 glsl_type::float_type
),
3266 add_function("atomicMin",
3267 _atomic_op2("__intrinsic_atomic_min",
3268 buffer_atomics_supported
,
3269 glsl_type::uint_type
),
3270 _atomic_op2("__intrinsic_atomic_min",
3271 buffer_atomics_supported
,
3272 glsl_type::int_type
),
3273 _atomic_op2("__intrinsic_atomic_min",
3274 shader_atomic_float_minmax
,
3275 glsl_type::float_type
),
3277 add_function("atomicMax",
3278 _atomic_op2("__intrinsic_atomic_max",
3279 buffer_atomics_supported
,
3280 glsl_type::uint_type
),
3281 _atomic_op2("__intrinsic_atomic_max",
3282 buffer_atomics_supported
,
3283 glsl_type::int_type
),
3284 _atomic_op2("__intrinsic_atomic_max",
3285 shader_atomic_float_minmax
,
3286 glsl_type::float_type
),
3288 add_function("atomicAnd",
3289 _atomic_op2("__intrinsic_atomic_and",
3290 buffer_atomics_supported
,
3291 glsl_type::uint_type
),
3292 _atomic_op2("__intrinsic_atomic_and",
3293 buffer_atomics_supported
,
3294 glsl_type::int_type
),
3296 add_function("atomicOr",
3297 _atomic_op2("__intrinsic_atomic_or",
3298 buffer_atomics_supported
,
3299 glsl_type::uint_type
),
3300 _atomic_op2("__intrinsic_atomic_or",
3301 buffer_atomics_supported
,
3302 glsl_type::int_type
),
3304 add_function("atomicXor",
3305 _atomic_op2("__intrinsic_atomic_xor",
3306 buffer_atomics_supported
,
3307 glsl_type::uint_type
),
3308 _atomic_op2("__intrinsic_atomic_xor",
3309 buffer_atomics_supported
,
3310 glsl_type::int_type
),
3312 add_function("atomicExchange",
3313 _atomic_op2("__intrinsic_atomic_exchange",
3314 buffer_atomics_supported
,
3315 glsl_type::uint_type
),
3316 _atomic_op2("__intrinsic_atomic_exchange",
3317 buffer_atomics_supported
,
3318 glsl_type::int_type
),
3319 _atomic_op2("__intrinsic_atomic_exchange",
3320 shader_atomic_float_exchange
,
3321 glsl_type::float_type
),
3323 add_function("atomicCompSwap",
3324 _atomic_op3("__intrinsic_atomic_comp_swap",
3325 buffer_atomics_supported
,
3326 glsl_type::uint_type
),
3327 _atomic_op3("__intrinsic_atomic_comp_swap",
3328 buffer_atomics_supported
,
3329 glsl_type::int_type
),
3330 _atomic_op3("__intrinsic_atomic_comp_swap",
3331 shader_atomic_float_minmax
,
3332 glsl_type::float_type
),
3335 add_function("min3",
3336 _min3(glsl_type::float_type
),
3337 _min3(glsl_type::vec2_type
),
3338 _min3(glsl_type::vec3_type
),
3339 _min3(glsl_type::vec4_type
),
3341 _min3(glsl_type::int_type
),
3342 _min3(glsl_type::ivec2_type
),
3343 _min3(glsl_type::ivec3_type
),
3344 _min3(glsl_type::ivec4_type
),
3346 _min3(glsl_type::uint_type
),
3347 _min3(glsl_type::uvec2_type
),
3348 _min3(glsl_type::uvec3_type
),
3349 _min3(glsl_type::uvec4_type
),
3352 add_function("max3",
3353 _max3(glsl_type::float_type
),
3354 _max3(glsl_type::vec2_type
),
3355 _max3(glsl_type::vec3_type
),
3356 _max3(glsl_type::vec4_type
),
3358 _max3(glsl_type::int_type
),
3359 _max3(glsl_type::ivec2_type
),
3360 _max3(glsl_type::ivec3_type
),
3361 _max3(glsl_type::ivec4_type
),
3363 _max3(glsl_type::uint_type
),
3364 _max3(glsl_type::uvec2_type
),
3365 _max3(glsl_type::uvec3_type
),
3366 _max3(glsl_type::uvec4_type
),
3369 add_function("mid3",
3370 _mid3(glsl_type::float_type
),
3371 _mid3(glsl_type::vec2_type
),
3372 _mid3(glsl_type::vec3_type
),
3373 _mid3(glsl_type::vec4_type
),
3375 _mid3(glsl_type::int_type
),
3376 _mid3(glsl_type::ivec2_type
),
3377 _mid3(glsl_type::ivec3_type
),
3378 _mid3(glsl_type::ivec4_type
),
3380 _mid3(glsl_type::uint_type
),
3381 _mid3(glsl_type::uvec2_type
),
3382 _mid3(glsl_type::uvec3_type
),
3383 _mid3(glsl_type::uvec4_type
),
3386 add_image_functions(true);
3388 add_function("memoryBarrier",
3389 _memory_barrier("__intrinsic_memory_barrier",
3390 shader_image_load_store
),
3392 add_function("groupMemoryBarrier",
3393 _memory_barrier("__intrinsic_group_memory_barrier",
3396 add_function("memoryBarrierAtomicCounter",
3397 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
3398 compute_shader_supported
),
3400 add_function("memoryBarrierBuffer",
3401 _memory_barrier("__intrinsic_memory_barrier_buffer",
3402 compute_shader_supported
),
3404 add_function("memoryBarrierImage",
3405 _memory_barrier("__intrinsic_memory_barrier_image",
3406 compute_shader_supported
),
3408 add_function("memoryBarrierShared",
3409 _memory_barrier("__intrinsic_memory_barrier_shared",
3413 add_function("ballotARB", _ballot(), NULL
);
3415 add_function("readInvocationARB",
3416 _read_invocation(glsl_type::float_type
),
3417 _read_invocation(glsl_type::vec2_type
),
3418 _read_invocation(glsl_type::vec3_type
),
3419 _read_invocation(glsl_type::vec4_type
),
3421 _read_invocation(glsl_type::int_type
),
3422 _read_invocation(glsl_type::ivec2_type
),
3423 _read_invocation(glsl_type::ivec3_type
),
3424 _read_invocation(glsl_type::ivec4_type
),
3426 _read_invocation(glsl_type::uint_type
),
3427 _read_invocation(glsl_type::uvec2_type
),
3428 _read_invocation(glsl_type::uvec3_type
),
3429 _read_invocation(glsl_type::uvec4_type
),
3432 add_function("readFirstInvocationARB",
3433 _read_first_invocation(glsl_type::float_type
),
3434 _read_first_invocation(glsl_type::vec2_type
),
3435 _read_first_invocation(glsl_type::vec3_type
),
3436 _read_first_invocation(glsl_type::vec4_type
),
3438 _read_first_invocation(glsl_type::int_type
),
3439 _read_first_invocation(glsl_type::ivec2_type
),
3440 _read_first_invocation(glsl_type::ivec3_type
),
3441 _read_first_invocation(glsl_type::ivec4_type
),
3443 _read_first_invocation(glsl_type::uint_type
),
3444 _read_first_invocation(glsl_type::uvec2_type
),
3445 _read_first_invocation(glsl_type::uvec3_type
),
3446 _read_first_invocation(glsl_type::uvec4_type
),
3449 add_function("clock2x32ARB",
3450 _shader_clock(shader_clock
,
3451 glsl_type::uvec2_type
),
3454 add_function("clockARB",
3455 _shader_clock(shader_clock_int64
,
3456 glsl_type::uint64_t_type
),
3459 add_function("beginInvocationInterlockARB",
3460 _invocation_interlock(
3461 "__intrinsic_begin_invocation_interlock",
3462 supports_arb_fragment_shader_interlock
),
3465 add_function("endInvocationInterlockARB",
3466 _invocation_interlock(
3467 "__intrinsic_end_invocation_interlock",
3468 supports_arb_fragment_shader_interlock
),
3471 add_function("beginInvocationInterlockNV",
3472 _invocation_interlock(
3473 "__intrinsic_begin_invocation_interlock",
3474 supports_nv_fragment_shader_interlock
),
3477 add_function("endInvocationInterlockNV",
3478 _invocation_interlock(
3479 "__intrinsic_end_invocation_interlock",
3480 supports_nv_fragment_shader_interlock
),
3483 add_function("anyInvocationARB",
3484 _vote("__intrinsic_vote_any", vote
),
3487 add_function("allInvocationsARB",
3488 _vote("__intrinsic_vote_all", vote
),
3491 add_function("allInvocationsEqualARB",
3492 _vote("__intrinsic_vote_eq", vote
),
3495 add_function("anyInvocation",
3496 _vote("__intrinsic_vote_any", v460_desktop
),
3499 add_function("allInvocations",
3500 _vote("__intrinsic_vote_all", v460_desktop
),
3503 add_function("allInvocationsEqual",
3504 _vote("__intrinsic_vote_eq", v460_desktop
),
3507 add_function("__builtin_idiv64",
3508 generate_ir::idiv64(mem_ctx
, integer_functions_supported
),
3511 add_function("__builtin_imod64",
3512 generate_ir::imod64(mem_ctx
, integer_functions_supported
),
3515 add_function("__builtin_sign64",
3516 generate_ir::sign64(mem_ctx
, integer_functions_supported
),
3519 add_function("__builtin_udiv64",
3520 generate_ir::udiv64(mem_ctx
, integer_functions_supported
),
3523 add_function("__builtin_umod64",
3524 generate_ir::umod64(mem_ctx
, integer_functions_supported
),
3527 add_function("__builtin_umul64",
3528 generate_ir::umul64(mem_ctx
, integer_functions_supported
),
3539 builtin_builder::add_function(const char *name
, ...)
3543 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3547 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
3553 stuff
.push_tail(sig
);
3554 validate_ir_tree(&stuff
);
3557 f
->add_signature(sig
);
3561 shader
->symbols
->add_function(f
);
3565 builtin_builder::add_image_function(const char *name
,
3566 const char *intrinsic_name
,
3567 image_prototype_ctr prototype
,
3568 unsigned num_arguments
,
3570 enum ir_intrinsic_id intrinsic_id
)
3572 static const glsl_type
*const types
[] = {
3573 glsl_type::image1D_type
,
3574 glsl_type::image2D_type
,
3575 glsl_type::image3D_type
,
3576 glsl_type::image2DRect_type
,
3577 glsl_type::imageCube_type
,
3578 glsl_type::imageBuffer_type
,
3579 glsl_type::image1DArray_type
,
3580 glsl_type::image2DArray_type
,
3581 glsl_type::imageCubeArray_type
,
3582 glsl_type::image2DMS_type
,
3583 glsl_type::image2DMSArray_type
,
3584 glsl_type::iimage1D_type
,
3585 glsl_type::iimage2D_type
,
3586 glsl_type::iimage3D_type
,
3587 glsl_type::iimage2DRect_type
,
3588 glsl_type::iimageCube_type
,
3589 glsl_type::iimageBuffer_type
,
3590 glsl_type::iimage1DArray_type
,
3591 glsl_type::iimage2DArray_type
,
3592 glsl_type::iimageCubeArray_type
,
3593 glsl_type::iimage2DMS_type
,
3594 glsl_type::iimage2DMSArray_type
,
3595 glsl_type::uimage1D_type
,
3596 glsl_type::uimage2D_type
,
3597 glsl_type::uimage3D_type
,
3598 glsl_type::uimage2DRect_type
,
3599 glsl_type::uimageCube_type
,
3600 glsl_type::uimageBuffer_type
,
3601 glsl_type::uimage1DArray_type
,
3602 glsl_type::uimage2DArray_type
,
3603 glsl_type::uimageCubeArray_type
,
3604 glsl_type::uimage2DMS_type
,
3605 glsl_type::uimage2DMSArray_type
3608 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3610 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3611 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3612 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3613 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3614 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3615 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3616 num_arguments
, flags
, intrinsic_id
));
3619 shader
->symbols
->add_function(f
);
3623 builtin_builder::add_image_functions(bool glsl
)
3625 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3627 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3628 "__intrinsic_image_load",
3629 &builtin_builder::_image_prototype
, 0,
3630 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3631 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3632 IMAGE_FUNCTION_READ_ONLY
),
3633 ir_intrinsic_image_load
);
3635 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3636 "__intrinsic_image_store",
3637 &builtin_builder::_image_prototype
, 1,
3638 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3639 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3640 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3641 IMAGE_FUNCTION_WRITE_ONLY
),
3642 ir_intrinsic_image_store
);
3644 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3646 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3647 "__intrinsic_image_atomic_add",
3648 &builtin_builder::_image_prototype
, 1,
3649 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
|
3650 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3651 ir_intrinsic_image_atomic_add
);
3653 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3654 "__intrinsic_image_atomic_min",
3655 &builtin_builder::_image_prototype
, 1, atom_flags
,
3656 ir_intrinsic_image_atomic_min
);
3658 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3659 "__intrinsic_image_atomic_max",
3660 &builtin_builder::_image_prototype
, 1, atom_flags
,
3661 ir_intrinsic_image_atomic_max
);
3663 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3664 "__intrinsic_image_atomic_and",
3665 &builtin_builder::_image_prototype
, 1, atom_flags
,
3666 ir_intrinsic_image_atomic_and
);
3668 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3669 "__intrinsic_image_atomic_or",
3670 &builtin_builder::_image_prototype
, 1, atom_flags
,
3671 ir_intrinsic_image_atomic_or
);
3673 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3674 "__intrinsic_image_atomic_xor",
3675 &builtin_builder::_image_prototype
, 1, atom_flags
,
3676 ir_intrinsic_image_atomic_xor
);
3678 add_image_function((glsl
? "imageAtomicExchange" :
3679 "__intrinsic_image_atomic_exchange"),
3680 "__intrinsic_image_atomic_exchange",
3681 &builtin_builder::_image_prototype
, 1,
3682 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3683 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3684 ir_intrinsic_image_atomic_exchange
);
3686 add_image_function((glsl
? "imageAtomicCompSwap" :
3687 "__intrinsic_image_atomic_comp_swap"),
3688 "__intrinsic_image_atomic_comp_swap",
3689 &builtin_builder::_image_prototype
, 2, atom_flags
,
3690 ir_intrinsic_image_atomic_comp_swap
);
3692 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3693 "__intrinsic_image_size",
3694 &builtin_builder::_image_size_prototype
, 1,
3695 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
,
3696 ir_intrinsic_image_size
);
3698 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3699 "__intrinsic_image_samples",
3700 &builtin_builder::_image_samples_prototype
, 1,
3701 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3702 IMAGE_FUNCTION_MS_ONLY
,
3703 ir_intrinsic_image_samples
);
3707 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3709 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3713 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3715 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3719 builtin_builder::imm(bool b
, unsigned vector_elements
)
3721 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3725 builtin_builder::imm(float f
, unsigned vector_elements
)
3727 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3731 builtin_builder::imm(int i
, unsigned vector_elements
)
3733 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3737 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3739 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3743 builtin_builder::imm(double d
, unsigned vector_elements
)
3745 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3749 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3751 return new(mem_ctx
) ir_constant(type
, &data
);
3754 #define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)
3756 ir_dereference_variable
*
3757 builtin_builder::var_ref(ir_variable
*var
)
3759 return new(mem_ctx
) ir_dereference_variable(var
);
3762 ir_dereference_array
*
3763 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3765 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3768 /** Return an element of a matrix */
3770 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3772 return swizzle(array_ref(var
, column
), row
, 1);
3776 * Implementations of built-in functions:
3779 ir_function_signature
*
3780 builtin_builder::new_sig(const glsl_type
*return_type
,
3781 builtin_available_predicate avail
,
3787 ir_function_signature
*sig
=
3788 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3791 va_start(ap
, num_params
);
3792 for (int i
= 0; i
< num_params
; i
++) {
3793 plist
.push_tail(va_arg(ap
, ir_variable
*));
3797 sig
->replace_parameters(&plist
);
3801 #define MAKE_SIG(return_type, avail, ...) \
3802 ir_function_signature *sig = \
3803 new_sig(return_type, avail, __VA_ARGS__); \
3804 ir_factory body(&sig->body, mem_ctx); \
3805 sig->is_defined = true;
3807 #define MAKE_INTRINSIC(return_type, id, avail, ...) \
3808 ir_function_signature *sig = \
3809 new_sig(return_type, avail, __VA_ARGS__); \
3810 sig->intrinsic_id = id;
3812 ir_function_signature
*
3813 builtin_builder::unop(builtin_available_predicate avail
,
3814 ir_expression_operation opcode
,
3815 const glsl_type
*return_type
,
3816 const glsl_type
*param_type
)
3818 ir_variable
*x
= in_var(param_type
, "x");
3819 MAKE_SIG(return_type
, avail
, 1, x
);
3820 body
.emit(ret(expr(opcode
, x
)));
3824 #define UNOP(NAME, OPCODE, AVAIL) \
3825 ir_function_signature * \
3826 builtin_builder::_##NAME(const glsl_type *type) \
3828 return unop(&AVAIL, OPCODE, type, type); \
3831 #define UNOPA(NAME, OPCODE) \
3832 ir_function_signature * \
3833 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3835 return unop(avail, OPCODE, type, type); \
3838 ir_function_signature
*
3839 builtin_builder::binop(builtin_available_predicate avail
,
3840 ir_expression_operation opcode
,
3841 const glsl_type
*return_type
,
3842 const glsl_type
*param0_type
,
3843 const glsl_type
*param1_type
,
3846 ir_variable
*x
= in_var(param0_type
, "x");
3847 ir_variable
*y
= in_var(param1_type
, "y");
3848 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3851 body
.emit(ret(expr(opcode
, y
, x
)));
3853 body
.emit(ret(expr(opcode
, x
, y
)));
3858 #define BINOP(NAME, OPCODE, AVAIL) \
3859 ir_function_signature * \
3860 builtin_builder::_##NAME(const glsl_type *return_type, \
3861 const glsl_type *param0_type, \
3862 const glsl_type *param1_type) \
3864 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3868 * Angle and Trigonometry Functions @{
3871 ir_function_signature
*
3872 builtin_builder::_radians(const glsl_type
*type
)
3874 ir_variable
*degrees
= in_var(type
, "degrees");
3875 MAKE_SIG(type
, always_available
, 1, degrees
);
3876 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3880 ir_function_signature
*
3881 builtin_builder::_degrees(const glsl_type
*type
)
3883 ir_variable
*radians
= in_var(type
, "radians");
3884 MAKE_SIG(type
, always_available
, 1, radians
);
3885 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3889 UNOP(sin
, ir_unop_sin
, always_available
)
3890 UNOP(cos
, ir_unop_cos
, always_available
)
3892 ir_function_signature
*
3893 builtin_builder::_tan(const glsl_type
*type
)
3895 ir_variable
*theta
= in_var(type
, "theta");
3896 MAKE_SIG(type
, always_available
, 1, theta
);
3897 body
.emit(ret(div(sin(theta
), cos(theta
))));
3902 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3906 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3909 add(imm(M_PI_4f
- 1.0f
),
3912 mul(abs(x
), imm(p1
))))))))));
3916 * Generate a ir_call to a function with a set of parameters
3918 * The input \c params can either be a list of \c ir_variable or a list of
3919 * \c ir_dereference_variable. In the latter case, all nodes will be removed
3920 * from \c params and used directly as the parameters to the generated
3924 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3926 exec_list actual_params
;
3928 foreach_in_list_safe(ir_instruction
, ir
, ¶ms
) {
3929 ir_dereference_variable
*d
= ir
->as_dereference_variable();
3932 actual_params
.push_tail(d
);
3934 ir_variable
*var
= ir
->as_variable();
3935 assert(var
!= NULL
);
3936 actual_params
.push_tail(var_ref(var
));
3940 ir_function_signature
*sig
=
3941 f
->exact_matching_signature(NULL
, &actual_params
);
3945 ir_dereference_variable
*deref
=
3946 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3948 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3951 ir_function_signature
*
3952 builtin_builder::_asin(const glsl_type
*type
)
3954 ir_variable
*x
= in_var(type
, "x");
3955 MAKE_SIG(type
, always_available
, 1, x
);
3957 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3962 ir_function_signature
*
3963 builtin_builder::_acos(const glsl_type
*type
)
3965 ir_variable
*x
= in_var(type
, "x");
3966 MAKE_SIG(type
, always_available
, 1, x
);
3968 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3973 ir_function_signature
*
3974 builtin_builder::_atan2(const glsl_type
*type
)
3976 const unsigned n
= type
->vector_elements
;
3977 ir_variable
*y
= in_var(type
, "y");
3978 ir_variable
*x
= in_var(type
, "x");
3979 MAKE_SIG(type
, always_available
, 2, y
, x
);
3981 /* If we're on the left half-plane rotate the coordinates π/2 clock-wise
3982 * for the y=0 discontinuity to end up aligned with the vertical
3983 * discontinuity of atan(s/t) along t=0. This also makes sure that we
3984 * don't attempt to divide by zero along the vertical line, which may give
3985 * unspecified results on non-GLSL 4.1-capable hardware.
3987 ir_variable
*flip
= body
.make_temp(glsl_type::bvec(n
), "flip");
3988 body
.emit(assign(flip
, gequal(imm(0.0f
, n
), x
)));
3989 ir_variable
*s
= body
.make_temp(type
, "s");
3990 body
.emit(assign(s
, csel(flip
, abs(x
), y
)));
3991 ir_variable
*t
= body
.make_temp(type
, "t");
3992 body
.emit(assign(t
, csel(flip
, y
, abs(x
))));
3994 /* If the magnitude of the denominator exceeds some huge value, scale down
3995 * the arguments in order to prevent the reciprocal operation from flushing
3996 * its result to zero, which would cause precision problems, and for s
3997 * infinite would cause us to return a NaN instead of the correct finite
4000 * If fmin and fmax are respectively the smallest and largest positive
4001 * normalized floating point values representable by the implementation,
4002 * the constants below should be in agreement with:
4005 * scale <= 1 / fmin / fmax (for |t| >= huge)
4007 * In addition scale should be a negative power of two in order to avoid
4008 * loss of precision. The values chosen below should work for most usual
4009 * floating point representations with at least the dynamic range of ATI's
4010 * 24-bit representation.
4012 ir_constant
*huge
= imm(1e18f
, n
);
4013 ir_variable
*scale
= body
.make_temp(type
, "scale");
4014 body
.emit(assign(scale
, csel(gequal(abs(t
), huge
),
4015 imm(0.25f
, n
), imm(1.0f
, n
))));
4016 ir_variable
*rcp_scaled_t
= body
.make_temp(type
, "rcp_scaled_t");
4017 body
.emit(assign(rcp_scaled_t
, rcp(mul(t
, scale
))));
4018 ir_expression
*s_over_t
= mul(mul(s
, scale
), rcp_scaled_t
);
4020 /* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily
4021 * that ∞/∞ = 1) in order to comply with the rather artificial rules
4022 * inherited from IEEE 754-2008, namely:
4024 * "atan2(±∞, −∞) is ±3π/4
4025 * atan2(±∞, +∞) is ±π/4"
4027 * Note that this is inconsistent with the rules for the neighborhood of
4028 * zero that are based on iterated limits:
4030 * "atan2(±0, −0) is ±π
4031 * atan2(±0, +0) is ±0"
4033 * but GLSL specifically allows implementations to deviate from IEEE rules
4034 * at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as
4037 ir_expression
*tan
= csel(equal(abs(x
), abs(y
)),
4038 imm(1.0f
, n
), abs(s_over_t
));
4040 /* Calculate the arctangent and fix up the result if we had flipped the
4041 * coordinate system.
4043 ir_variable
*arc
= body
.make_temp(type
, "arc");
4044 do_atan(body
, type
, arc
, tan
);
4045 body
.emit(assign(arc
, add(arc
, mul(b2f(flip
), imm(M_PI_2f
)))));
4047 /* Rather convoluted calculation of the sign of the result. When x < 0 we
4048 * cannot use fsign because we need to be able to distinguish between
4049 * negative and positive zero. Unfortunately we cannot use bitwise
4050 * arithmetic tricks either because of back-ends without integer support.
4051 * When x >= 0 rcp_scaled_t will always be non-negative so this won't be
4052 * able to distinguish between negative and positive zero, but we don't
4053 * care because atan2 is continuous along the whole positive y = 0
4054 * half-line, so it won't affect the result significantly.
4056 body
.emit(ret(csel(less(min2(y
, rcp_scaled_t
), imm(0.0f
, n
)),
4063 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
4066 * range-reduction, first step:
4068 * / y_over_x if |y_over_x| <= 1.0;
4070 * \ 1.0 / y_over_x otherwise
4072 ir_variable
*x
= body
.make_temp(type
, "atan_x");
4073 body
.emit(assign(x
, div(min2(abs(y_over_x
),
4079 * approximate atan by evaluating polynomial:
4081 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
4082 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
4083 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
4085 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
4086 body
.emit(assign(tmp
, mul(x
, x
)));
4087 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
4089 imm(0.0536813784310406f
)),
4091 imm(0.1173503194786851f
)),
4093 imm(0.1938924977115610f
)),
4095 imm(0.3326756418091246f
)),
4097 imm(0.9999793128310355f
)),
4100 /* range-reduction fixup */
4101 body
.emit(assign(tmp
, add(tmp
,
4102 mul(b2f(greater(abs(y_over_x
),
4103 imm(1.0f
, type
->components()))),
4109 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
4112 ir_function_signature
*
4113 builtin_builder::_atan(const glsl_type
*type
)
4115 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
4116 MAKE_SIG(type
, always_available
, 1, y_over_x
);
4118 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
4119 do_atan(body
, type
, tmp
, y_over_x
);
4120 body
.emit(ret(tmp
));
4125 ir_function_signature
*
4126 builtin_builder::_sinh(const glsl_type
*type
)
4128 ir_variable
*x
= in_var(type
, "x");
4129 MAKE_SIG(type
, v130
, 1, x
);
4131 /* 0.5 * (e^x - e^(-x)) */
4132 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
4137 ir_function_signature
*
4138 builtin_builder::_cosh(const glsl_type
*type
)
4140 ir_variable
*x
= in_var(type
, "x");
4141 MAKE_SIG(type
, v130
, 1, x
);
4143 /* 0.5 * (e^x + e^(-x)) */
4144 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
4149 ir_function_signature
*
4150 builtin_builder::_tanh(const glsl_type
*type
)
4152 ir_variable
*x
= in_var(type
, "x");
4153 MAKE_SIG(type
, v130
, 1, x
);
4155 /* tanh(x) := (0.5 * (e^x - e^(-x))) / (0.5 * (e^x + e^(-x)))
4157 * With a little algebra this reduces to (e^2x - 1) / (e^2x + 1)
4159 * Clamp x to (-inf, +10] to avoid precision problems. When x > 10, e^2x
4160 * is so much larger than 1.0 that 1.0 gets flushed to zero in the
4161 * computation e^2x +/- 1 so it can be ignored.
4163 ir_variable
*t
= body
.make_temp(type
, "tmp");
4164 body
.emit(assign(t
, min2(x
, imm(10.0f
))));
4166 body
.emit(ret(div(sub(exp(mul(t
, imm(2.0f
))), imm(1.0f
)),
4167 add(exp(mul(t
, imm(2.0f
))), imm(1.0f
)))));
4172 ir_function_signature
*
4173 builtin_builder::_asinh(const glsl_type
*type
)
4175 ir_variable
*x
= in_var(type
, "x");
4176 MAKE_SIG(type
, v130
, 1, x
);
4178 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
4183 ir_function_signature
*
4184 builtin_builder::_acosh(const glsl_type
*type
)
4186 ir_variable
*x
= in_var(type
, "x");
4187 MAKE_SIG(type
, v130
, 1, x
);
4189 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
4193 ir_function_signature
*
4194 builtin_builder::_atanh(const glsl_type
*type
)
4196 ir_variable
*x
= in_var(type
, "x");
4197 MAKE_SIG(type
, v130
, 1, x
);
4199 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
4200 sub(imm(1.0f
), x
))))));
4206 * Exponential Functions @{
4209 ir_function_signature
*
4210 builtin_builder::_pow(const glsl_type
*type
)
4212 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
4215 UNOP(exp
, ir_unop_exp
, always_available
)
4216 UNOP(log
, ir_unop_log
, always_available
)
4217 UNOP(exp2
, ir_unop_exp2
, always_available
)
4218 UNOP(log2
, ir_unop_log2
, always_available
)
4219 UNOPA(sqrt
, ir_unop_sqrt
)
4220 UNOPA(inversesqrt
, ir_unop_rsq
)
4224 UNOPA(abs
, ir_unop_abs
)
4225 UNOPA(sign
, ir_unop_sign
)
4226 UNOPA(floor
, ir_unop_floor
)
4227 UNOPA(truncate
, ir_unop_trunc
)
4228 UNOPA(trunc
, ir_unop_trunc
)
4229 UNOPA(round
, ir_unop_round_even
)
4230 UNOPA(roundEven
, ir_unop_round_even
)
4231 UNOPA(ceil
, ir_unop_ceil
)
4232 UNOPA(fract
, ir_unop_fract
)
4234 ir_function_signature
*
4235 builtin_builder::_mod(builtin_available_predicate avail
,
4236 const glsl_type
*x_type
, const glsl_type
*y_type
)
4238 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
4241 ir_function_signature
*
4242 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
4244 ir_variable
*x
= in_var(type
, "x");
4245 ir_variable
*i
= out_var(type
, "i");
4246 MAKE_SIG(type
, avail
, 2, x
, i
);
4248 ir_variable
*t
= body
.make_temp(type
, "t");
4249 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
4250 body
.emit(assign(i
, t
));
4251 body
.emit(ret(sub(x
, t
)));
4256 ir_function_signature
*
4257 builtin_builder::_min(builtin_available_predicate avail
,
4258 const glsl_type
*x_type
, const glsl_type
*y_type
)
4260 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
4263 ir_function_signature
*
4264 builtin_builder::_max(builtin_available_predicate avail
,
4265 const glsl_type
*x_type
, const glsl_type
*y_type
)
4267 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
4270 ir_function_signature
*
4271 builtin_builder::_clamp(builtin_available_predicate avail
,
4272 const glsl_type
*val_type
, const glsl_type
*bound_type
)
4274 ir_variable
*x
= in_var(val_type
, "x");
4275 ir_variable
*minVal
= in_var(bound_type
, "minVal");
4276 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
4277 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
4279 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
4284 ir_function_signature
*
4285 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
4287 ir_variable
*x
= in_var(val_type
, "x");
4288 ir_variable
*y
= in_var(val_type
, "y");
4289 ir_variable
*a
= in_var(blend_type
, "a");
4290 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4292 body
.emit(ret(lrp(x
, y
, a
)));
4297 ir_function_signature
*
4298 builtin_builder::_mix_sel(builtin_available_predicate avail
,
4299 const glsl_type
*val_type
,
4300 const glsl_type
*blend_type
)
4302 ir_variable
*x
= in_var(val_type
, "x");
4303 ir_variable
*y
= in_var(val_type
, "y");
4304 ir_variable
*a
= in_var(blend_type
, "a");
4305 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4307 /* csel matches the ternary operator in that a selector of true choses the
4308 * first argument. This differs from mix(x, y, false) which choses the
4309 * second argument (to remain consistent with the interpolating version of
4310 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
4312 * To handle the behavior mismatch, reverse the x and y arguments.
4314 body
.emit(ret(csel(a
, y
, x
)));
4319 ir_function_signature
*
4320 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4322 ir_variable
*edge
= in_var(edge_type
, "edge");
4323 ir_variable
*x
= in_var(x_type
, "x");
4324 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
4326 ir_variable
*t
= body
.make_temp(x_type
, "t");
4327 if (x_type
->vector_elements
== 1) {
4328 /* Both are floats */
4329 if (edge_type
->is_double())
4330 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
4332 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
4333 } else if (edge_type
->vector_elements
== 1) {
4334 /* x is a vector but edge is a float */
4335 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4336 if (edge_type
->is_double())
4337 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
4339 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
4342 /* Both are vectors */
4343 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4344 if (edge_type
->is_double())
4345 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
4348 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
4358 ir_function_signature
*
4359 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4361 ir_variable
*edge0
= in_var(edge_type
, "edge0");
4362 ir_variable
*edge1
= in_var(edge_type
, "edge1");
4363 ir_variable
*x
= in_var(x_type
, "x");
4364 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
4366 /* From the GLSL 1.10 specification:
4369 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
4370 * return t * t * (3 - 2 * t);
4373 ir_variable
*t
= body
.make_temp(x_type
, "t");
4374 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
4375 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
4377 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
4382 ir_function_signature
*
4383 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
4385 ir_variable
*x
= in_var(type
, "x");
4386 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4388 body
.emit(ret(nequal(x
, x
)));
4393 ir_function_signature
*
4394 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
4396 ir_variable
*x
= in_var(type
, "x");
4397 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4399 ir_constant_data infinities
;
4400 for (int i
= 0; i
< type
->vector_elements
; i
++) {
4401 switch (type
->base_type
) {
4402 case GLSL_TYPE_FLOAT
:
4403 infinities
.f
[i
] = INFINITY
;
4405 case GLSL_TYPE_DOUBLE
:
4406 infinities
.d
[i
] = INFINITY
;
4409 unreachable("unknown type");
4413 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
4418 ir_function_signature
*
4419 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
4421 ir_variable
*x
= in_var(type
, "x");
4422 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4423 body
.emit(ret(bitcast_f2i(x
)));
4427 ir_function_signature
*
4428 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
4430 ir_variable
*x
= in_var(type
, "x");
4431 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4432 body
.emit(ret(bitcast_f2u(x
)));
4436 ir_function_signature
*
4437 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
4439 ir_variable
*x
= in_var(type
, "x");
4440 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4441 body
.emit(ret(bitcast_i2f(x
)));
4445 ir_function_signature
*
4446 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
4448 ir_variable
*x
= in_var(type
, "x");
4449 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4450 body
.emit(ret(bitcast_u2f(x
)));
4454 ir_function_signature
*
4455 builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail
, const glsl_type
*type
)
4457 ir_variable
*x
= in_var(type
, "x");
4458 MAKE_SIG(glsl_type::i64vec(type
->vector_elements
), avail
, 1, x
);
4459 body
.emit(ret(bitcast_d2i64(x
)));
4463 ir_function_signature
*
4464 builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail
, const glsl_type
*type
)
4466 ir_variable
*x
= in_var(type
, "x");
4467 MAKE_SIG(glsl_type::u64vec(type
->vector_elements
), avail
, 1, x
);
4468 body
.emit(ret(bitcast_d2u64(x
)));
4472 ir_function_signature
*
4473 builtin_builder::_int64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4475 ir_variable
*x
= in_var(type
, "x");
4476 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4477 body
.emit(ret(bitcast_i642d(x
)));
4481 ir_function_signature
*
4482 builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4484 ir_variable
*x
= in_var(type
, "x");
4485 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4486 body
.emit(ret(bitcast_u642d(x
)));
4490 ir_function_signature
*
4491 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
4493 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4494 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4495 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
4499 ir_function_signature
*
4500 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
4502 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4503 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4504 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
4508 ir_function_signature
*
4509 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
4511 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4512 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4513 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
4517 ir_function_signature
*
4518 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
4520 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4521 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4522 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
4526 ir_function_signature
*
4527 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
4529 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4530 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4531 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
4535 ir_function_signature
*
4536 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
4538 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4539 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4540 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
4545 ir_function_signature
*
4546 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
4548 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4549 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4550 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
4554 ir_function_signature
*
4555 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
4557 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4558 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4559 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
4563 ir_function_signature
*
4564 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
4566 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4567 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4568 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
4572 ir_function_signature
*
4573 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
4575 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4576 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4577 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
4581 ir_function_signature
*
4582 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
4584 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4585 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
4586 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
4590 ir_function_signature
*
4591 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
4593 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
4594 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4595 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
4599 ir_function_signature
*
4600 builtin_builder::_packInt2x32(builtin_available_predicate avail
)
4602 ir_variable
*v
= in_var(glsl_type::ivec2_type
, "v");
4603 MAKE_SIG(glsl_type::int64_t_type
, avail
, 1, v
);
4604 body
.emit(ret(expr(ir_unop_pack_int_2x32
, v
)));
4608 ir_function_signature
*
4609 builtin_builder::_unpackInt2x32(builtin_available_predicate avail
)
4611 ir_variable
*p
= in_var(glsl_type::int64_t_type
, "p");
4612 MAKE_SIG(glsl_type::ivec2_type
, avail
, 1, p
);
4613 body
.emit(ret(expr(ir_unop_unpack_int_2x32
, p
)));
4617 ir_function_signature
*
4618 builtin_builder::_packUint2x32(builtin_available_predicate avail
)
4620 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4621 MAKE_SIG(glsl_type::uint64_t_type
, avail
, 1, v
);
4622 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, v
)));
4626 ir_function_signature
*
4627 builtin_builder::_unpackUint2x32(builtin_available_predicate avail
)
4629 ir_variable
*p
= in_var(glsl_type::uint64_t_type
, "p");
4630 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4631 body
.emit(ret(expr(ir_unop_unpack_uint_2x32
, p
)));
4635 ir_function_signature
*
4636 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
4638 ir_variable
*x
= in_var(type
, "x");
4639 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
4641 body
.emit(ret(sqrt(dot(x
, x
))));
4646 ir_function_signature
*
4647 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
4649 ir_variable
*p0
= in_var(type
, "p0");
4650 ir_variable
*p1
= in_var(type
, "p1");
4651 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
4653 if (type
->vector_elements
== 1) {
4654 body
.emit(ret(abs(sub(p0
, p1
))));
4656 ir_variable
*p
= body
.make_temp(type
, "p");
4657 body
.emit(assign(p
, sub(p0
, p1
)));
4658 body
.emit(ret(sqrt(dot(p
, p
))));
4664 ir_function_signature
*
4665 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
4667 if (type
->vector_elements
== 1)
4668 return binop(avail
, ir_binop_mul
, type
, type
, type
);
4670 return binop(avail
, ir_binop_dot
,
4671 type
->get_base_type(), type
, type
);
4674 ir_function_signature
*
4675 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
4677 ir_variable
*a
= in_var(type
, "a");
4678 ir_variable
*b
= in_var(type
, "b");
4679 MAKE_SIG(type
, avail
, 2, a
, b
);
4681 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
4682 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
4684 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
4685 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
4690 ir_function_signature
*
4691 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
4693 ir_variable
*x
= in_var(type
, "x");
4694 MAKE_SIG(type
, avail
, 1, x
);
4696 if (type
->vector_elements
== 1) {
4697 body
.emit(ret(sign(x
)));
4699 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
4705 ir_function_signature
*
4706 builtin_builder::_ftransform()
4708 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
4710 /* ftransform() refers to global variables, and is always emitted
4711 * directly by ast_function.cpp. Just emit a prototype here so we
4712 * can recognize calls to it.
4717 ir_function_signature
*
4718 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
4720 ir_variable
*N
= in_var(type
, "N");
4721 ir_variable
*I
= in_var(type
, "I");
4722 ir_variable
*Nref
= in_var(type
, "Nref");
4723 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
4725 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
4726 ret(N
), ret(neg(N
))));
4731 ir_function_signature
*
4732 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
4734 ir_variable
*I
= in_var(type
, "I");
4735 ir_variable
*N
= in_var(type
, "N");
4736 MAKE_SIG(type
, avail
, 2, I
, N
);
4738 /* I - 2 * dot(N, I) * N */
4739 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
4744 ir_function_signature
*
4745 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
4747 ir_variable
*I
= in_var(type
, "I");
4748 ir_variable
*N
= in_var(type
, "N");
4749 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
4750 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4752 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4753 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4755 /* From the GLSL 1.10 specification:
4756 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4758 * return genType(0.0)
4760 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4762 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4763 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4764 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4765 mul(n_dot_i
, n_dot_i
)))))));
4766 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4767 ret(ir_constant::zero(mem_ctx
, type
)),
4768 ret(sub(mul(eta
, I
),
4769 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4774 ir_function_signature
*
4775 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4777 ir_variable
*x
= in_var(type
, "x");
4778 ir_variable
*y
= in_var(type
, "y");
4779 MAKE_SIG(type
, avail
, 2, x
, y
);
4781 ir_variable
*z
= body
.make_temp(type
, "z");
4782 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4783 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4790 ir_function_signature
*
4791 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4796 if (type
->is_double()) {
4797 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4798 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4800 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4801 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4803 MAKE_SIG(type
, avail
, 2, c
, r
);
4805 ir_variable
*m
= body
.make_temp(type
, "m");
4806 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4807 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4814 ir_function_signature
*
4815 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4817 const glsl_type
*transpose_type
=
4818 glsl_type::get_instance(orig_type
->base_type
,
4819 orig_type
->matrix_columns
,
4820 orig_type
->vector_elements
);
4822 ir_variable
*m
= in_var(orig_type
, "m");
4823 MAKE_SIG(transpose_type
, avail
, 1, m
);
4825 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4826 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4827 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4828 body
.emit(assign(array_ref(t
, j
),
4829 matrix_elt(m
, i
, j
),
4838 ir_function_signature
*
4839 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4841 ir_variable
*m
= in_var(type
, "m");
4842 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4844 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4845 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4850 ir_function_signature
*
4851 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4853 ir_variable
*m
= in_var(type
, "m");
4854 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4857 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4858 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4861 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4862 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4865 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4866 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4868 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4869 mul(matrix_elt(m
, 0, 1), f2
)),
4870 mul(matrix_elt(m
, 0, 2), f3
))));
4875 ir_function_signature
*
4876 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4878 ir_variable
*m
= in_var(type
, "m");
4879 const glsl_type
*btype
= type
->get_base_type();
4880 MAKE_SIG(btype
, avail
, 1, m
);
4882 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4883 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4884 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4885 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4886 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4887 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4888 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4889 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4890 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4891 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4892 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4893 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4894 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4895 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4896 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4897 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4898 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4899 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4900 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4902 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)))));
4903 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)))));
4904 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)))));
4905 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)))));
4906 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)))));
4907 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)))));
4908 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)))));
4909 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)))));
4910 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)))));
4911 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)))));
4912 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)))));
4913 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)))));
4914 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)))));
4915 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)))));
4916 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)))));
4917 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)))));
4918 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)))));
4919 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)))));
4920 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)))));
4922 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4924 body
.emit(assign(adj_0
,
4925 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4926 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4927 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4929 body
.emit(assign(adj_0
, neg(
4930 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4931 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4932 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4934 body
.emit(assign(adj_0
,
4935 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4936 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4937 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4939 body
.emit(assign(adj_0
, neg(
4940 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4941 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4942 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4945 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4950 ir_function_signature
*
4951 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4953 ir_variable
*m
= in_var(type
, "m");
4954 MAKE_SIG(type
, avail
, 1, m
);
4956 ir_variable
*adj
= body
.make_temp(type
, "adj");
4957 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4958 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4959 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4960 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4962 ir_expression
*det
=
4963 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4964 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4966 body
.emit(ret(div(adj
, det
)));
4970 ir_function_signature
*
4971 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4973 ir_variable
*m
= in_var(type
, "m");
4974 const glsl_type
*btype
= type
->get_base_type();
4975 MAKE_SIG(type
, avail
, 1, m
);
4977 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4978 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4979 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4981 body
.emit(assign(f11_22_21_12
,
4982 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4983 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4984 body
.emit(assign(f10_22_20_12
,
4985 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4986 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4987 body
.emit(assign(f10_21_20_11
,
4988 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4989 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4991 ir_variable
*adj
= body
.make_temp(type
, "adj");
4992 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4993 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4994 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4996 body
.emit(assign(array_ref(adj
, 0), neg(
4997 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4998 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
5000 body
.emit(assign(array_ref(adj
, 1),
5001 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
5002 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
5004 body
.emit(assign(array_ref(adj
, 2), neg(
5005 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
5006 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
5009 body
.emit(assign(array_ref(adj
, 0),
5010 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
5011 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
5013 body
.emit(assign(array_ref(adj
, 1), neg(
5014 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
5015 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
5017 body
.emit(assign(array_ref(adj
, 2),
5018 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
5019 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
5022 ir_expression
*det
=
5023 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
5024 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
5025 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
5027 body
.emit(ret(div(adj
, det
)));
5032 ir_function_signature
*
5033 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
5035 ir_variable
*m
= in_var(type
, "m");
5036 const glsl_type
*btype
= type
->get_base_type();
5037 MAKE_SIG(type
, avail
, 1, m
);
5039 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
5040 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
5041 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
5042 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
5043 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
5044 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
5045 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
5046 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
5047 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
5048 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
5049 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
5050 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
5051 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
5052 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
5053 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
5054 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
5055 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
5056 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
5057 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
5059 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)))));
5060 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)))));
5061 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)))));
5062 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)))));
5063 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)))));
5064 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)))));
5065 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)))));
5066 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)))));
5067 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)))));
5068 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)))));
5069 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)))));
5070 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)))));
5071 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)))));
5072 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)))));
5073 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)))));
5074 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)))));
5075 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)))));
5076 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)))));
5077 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)))));
5079 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
5080 body
.emit(assign(array_ref(adj
, 0),
5081 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
5082 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
5083 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
5085 body
.emit(assign(array_ref(adj
, 1), neg(
5086 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
5087 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
5088 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
5090 body
.emit(assign(array_ref(adj
, 2),
5091 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
5092 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
5093 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
5095 body
.emit(assign(array_ref(adj
, 3), neg(
5096 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
5097 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
5098 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
5101 body
.emit(assign(array_ref(adj
, 0), neg(
5102 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
5103 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
5104 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
5106 body
.emit(assign(array_ref(adj
, 1),
5107 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
5108 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
5109 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
5111 body
.emit(assign(array_ref(adj
, 2), neg(
5112 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
5113 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
5114 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
5116 body
.emit(assign(array_ref(adj
, 3),
5117 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
5118 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
5119 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
5122 body
.emit(assign(array_ref(adj
, 0),
5123 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
5124 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
5125 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
5127 body
.emit(assign(array_ref(adj
, 1), neg(
5128 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
5129 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
5130 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
5132 body
.emit(assign(array_ref(adj
, 2),
5133 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
5134 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
5135 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
5137 body
.emit(assign(array_ref(adj
, 3), neg(
5138 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
5139 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
5140 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
5143 body
.emit(assign(array_ref(adj
, 0), neg(
5144 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
5145 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
5146 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
5148 body
.emit(assign(array_ref(adj
, 1),
5149 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
5150 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
5151 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
5153 body
.emit(assign(array_ref(adj
, 2), neg(
5154 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
5155 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
5156 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
5158 body
.emit(assign(array_ref(adj
, 3),
5159 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
5160 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
5161 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
5164 ir_expression
*det
=
5165 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
5166 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
5167 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
5168 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
5170 body
.emit(ret(div(adj
, det
)));
5176 ir_function_signature
*
5177 builtin_builder::_lessThan(builtin_available_predicate avail
,
5178 const glsl_type
*type
)
5180 return binop(avail
, ir_binop_less
,
5181 glsl_type::bvec(type
->vector_elements
), type
, type
);
5184 ir_function_signature
*
5185 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
5186 const glsl_type
*type
)
5188 return binop(avail
, ir_binop_gequal
,
5189 glsl_type::bvec(type
->vector_elements
), type
, type
,
5193 ir_function_signature
*
5194 builtin_builder::_greaterThan(builtin_available_predicate avail
,
5195 const glsl_type
*type
)
5197 return binop(avail
, ir_binop_less
,
5198 glsl_type::bvec(type
->vector_elements
), type
, type
,
5202 ir_function_signature
*
5203 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
5204 const glsl_type
*type
)
5206 return binop(avail
, ir_binop_gequal
,
5207 glsl_type::bvec(type
->vector_elements
), type
, type
);
5210 ir_function_signature
*
5211 builtin_builder::_equal(builtin_available_predicate avail
,
5212 const glsl_type
*type
)
5214 return binop(avail
, ir_binop_equal
,
5215 glsl_type::bvec(type
->vector_elements
), type
, type
);
5218 ir_function_signature
*
5219 builtin_builder::_notEqual(builtin_available_predicate avail
,
5220 const glsl_type
*type
)
5222 return binop(avail
, ir_binop_nequal
,
5223 glsl_type::bvec(type
->vector_elements
), type
, type
);
5226 ir_function_signature
*
5227 builtin_builder::_any(const glsl_type
*type
)
5229 ir_variable
*v
= in_var(type
, "v");
5230 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5232 const unsigned vec_elem
= v
->type
->vector_elements
;
5233 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
5238 ir_function_signature
*
5239 builtin_builder::_all(const glsl_type
*type
)
5241 ir_variable
*v
= in_var(type
, "v");
5242 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5244 const unsigned vec_elem
= v
->type
->vector_elements
;
5245 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
5250 UNOP(not, ir_unop_logic_not
, always_available
)
5253 has_lod(const glsl_type
*sampler_type
)
5255 assert(sampler_type
->is_sampler());
5257 switch (sampler_type
->sampler_dimensionality
) {
5258 case GLSL_SAMPLER_DIM_RECT
:
5259 case GLSL_SAMPLER_DIM_BUF
:
5260 case GLSL_SAMPLER_DIM_MS
:
5267 ir_function_signature
*
5268 builtin_builder::_textureSize(builtin_available_predicate avail
,
5269 const glsl_type
*return_type
,
5270 const glsl_type
*sampler_type
)
5272 ir_variable
*s
= in_var(sampler_type
, "sampler");
5273 /* The sampler always exists; add optional lod later. */
5274 MAKE_SIG(return_type
, avail
, 1, s
);
5276 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
5277 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
5279 if (has_lod(sampler_type
)) {
5280 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5281 sig
->parameters
.push_tail(lod
);
5282 tex
->lod_info
.lod
= var_ref(lod
);
5284 tex
->lod_info
.lod
= imm(0u);
5287 body
.emit(ret(tex
));
5292 ir_function_signature
*
5293 builtin_builder::_textureSamples(builtin_available_predicate avail
,
5294 const glsl_type
*sampler_type
)
5296 ir_variable
*s
= in_var(sampler_type
, "sampler");
5297 MAKE_SIG(glsl_type::int_type
, avail
, 1, s
);
5299 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
5300 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
5301 body
.emit(ret(tex
));
5306 ir_function_signature
*
5307 builtin_builder::_texture(ir_texture_opcode opcode
,
5308 builtin_available_predicate avail
,
5309 const glsl_type
*return_type
,
5310 const glsl_type
*sampler_type
,
5311 const glsl_type
*coord_type
,
5314 ir_variable
*s
= in_var(sampler_type
, "sampler");
5315 ir_variable
*P
= in_var(coord_type
, "P");
5316 /* The sampler and coordinate always exist; add optional parameters later. */
5317 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5319 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
5320 tex
->set_sampler(var_ref(s
), return_type
);
5322 const int coord_size
= sampler_type
->coordinate_components();
5324 if (coord_size
== coord_type
->vector_elements
) {
5325 tex
->coordinate
= var_ref(P
);
5327 /* The incoming coordinate also has the projector or shadow comparator,
5328 * so we need to swizzle those away.
5330 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
5333 /* The projector is always in the last component. */
5334 if (flags
& TEX_PROJECT
)
5335 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
5337 if (sampler_type
->sampler_shadow
) {
5338 if (opcode
== ir_tg4
) {
5339 /* gather has refz as a separate parameter, immediately after the
5342 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
5343 sig
->parameters
.push_tail(refz
);
5344 tex
->shadow_comparator
= var_ref(refz
);
5346 /* The shadow comparator is normally in the Z component, but a few types
5347 * have sufficiently large coordinates that it's in W.
5349 tex
->shadow_comparator
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
5353 if (opcode
== ir_txl
) {
5354 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
5355 sig
->parameters
.push_tail(lod
);
5356 tex
->lod_info
.lod
= var_ref(lod
);
5357 } else if (opcode
== ir_txd
) {
5358 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5359 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
5360 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
5361 sig
->parameters
.push_tail(dPdx
);
5362 sig
->parameters
.push_tail(dPdy
);
5363 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
5364 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
5367 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
5368 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5369 ir_variable
*offset
=
5370 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
5371 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
5372 sig
->parameters
.push_tail(offset
);
5373 tex
->offset
= var_ref(offset
);
5376 if (flags
& TEX_OFFSET_ARRAY
) {
5377 ir_variable
*offsets
=
5378 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
5379 "offsets", ir_var_const_in
);
5380 sig
->parameters
.push_tail(offsets
);
5381 tex
->offset
= var_ref(offsets
);
5384 if (opcode
== ir_tg4
) {
5385 if (flags
& TEX_COMPONENT
) {
5386 ir_variable
*component
=
5387 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
5388 sig
->parameters
.push_tail(component
);
5389 tex
->lod_info
.component
= var_ref(component
);
5392 tex
->lod_info
.component
= imm(0);
5396 /* The "bias" parameter comes /after/ the "offset" parameter, which is
5397 * inconsistent with both textureLodOffset and textureGradOffset.
5399 if (opcode
== ir_txb
) {
5400 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
5401 sig
->parameters
.push_tail(bias
);
5402 tex
->lod_info
.bias
= var_ref(bias
);
5405 body
.emit(ret(tex
));
5410 ir_function_signature
*
5411 builtin_builder::_textureCubeArrayShadow(builtin_available_predicate avail
,
5412 const glsl_type
*sampler_type
)
5414 ir_variable
*s
= in_var(sampler_type
, "sampler");
5415 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
5416 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
5417 MAKE_SIG(glsl_type::float_type
, avail
, 3, s
, P
, compare
);
5419 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
5420 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
5422 tex
->coordinate
= var_ref(P
);
5423 tex
->shadow_comparator
= var_ref(compare
);
5425 body
.emit(ret(tex
));
5430 ir_function_signature
*
5431 builtin_builder::_texelFetch(builtin_available_predicate avail
,
5432 const glsl_type
*return_type
,
5433 const glsl_type
*sampler_type
,
5434 const glsl_type
*coord_type
,
5435 const glsl_type
*offset_type
)
5437 ir_variable
*s
= in_var(sampler_type
, "sampler");
5438 ir_variable
*P
= in_var(coord_type
, "P");
5439 /* The sampler and coordinate always exist; add optional parameters later. */
5440 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5442 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
5443 tex
->coordinate
= var_ref(P
);
5444 tex
->set_sampler(var_ref(s
), return_type
);
5446 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
5447 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
5448 sig
->parameters
.push_tail(sample
);
5449 tex
->lod_info
.sample_index
= var_ref(sample
);
5450 tex
->op
= ir_txf_ms
;
5451 } else if (has_lod(sampler_type
)) {
5452 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5453 sig
->parameters
.push_tail(lod
);
5454 tex
->lod_info
.lod
= var_ref(lod
);
5456 tex
->lod_info
.lod
= imm(0u);
5459 if (offset_type
!= NULL
) {
5460 ir_variable
*offset
=
5461 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
5462 sig
->parameters
.push_tail(offset
);
5463 tex
->offset
= var_ref(offset
);
5466 body
.emit(ret(tex
));
5471 ir_function_signature
*
5472 builtin_builder::_EmitVertex()
5474 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5476 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5477 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
5482 ir_function_signature
*
5483 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
5484 const glsl_type
*stream_type
)
5486 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5488 * "Emit the current values of output variables to the current output
5489 * primitive on stream stream. The argument to stream must be a constant
5490 * integral expression."
5492 ir_variable
*stream
=
5493 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5495 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5497 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
5502 ir_function_signature
*
5503 builtin_builder::_EndPrimitive()
5505 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5507 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5508 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
5513 ir_function_signature
*
5514 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
5515 const glsl_type
*stream_type
)
5517 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5519 * "Completes the current output primitive on stream stream and starts
5520 * a new one. The argument to stream must be a constant integral
5523 ir_variable
*stream
=
5524 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5526 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5528 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
5533 ir_function_signature
*
5534 builtin_builder::_barrier()
5536 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
5538 body
.emit(new(mem_ctx
) ir_barrier());
5542 ir_function_signature
*
5543 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
5544 const glsl_type
*sampler_type
,
5545 const glsl_type
*coord_type
)
5547 ir_variable
*s
= in_var(sampler_type
, "sampler");
5548 ir_variable
*coord
= in_var(coord_type
, "coord");
5549 /* The sampler and coordinate always exist; add optional parameters later. */
5550 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
5552 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
5553 tex
->coordinate
= var_ref(coord
);
5554 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
5556 body
.emit(ret(tex
));
5561 ir_function_signature
*
5562 builtin_builder::_textureQueryLevels(builtin_available_predicate avail
,
5563 const glsl_type
*sampler_type
)
5565 ir_variable
*s
= in_var(sampler_type
, "sampler");
5566 const glsl_type
*return_type
= glsl_type::int_type
;
5567 MAKE_SIG(return_type
, avail
, 1, s
);
5569 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
5570 tex
->set_sampler(var_ref(s
), return_type
);
5572 body
.emit(ret(tex
));
5577 ir_function_signature
*
5578 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
5579 const glsl_type
*sampler_type
,
5580 const glsl_type
*coord_type
)
5582 ir_variable
*s
= in_var(sampler_type
, "sampler");
5583 ir_variable
*P
= in_var(coord_type
, "P");
5584 const glsl_type
*return_type
= glsl_type::bool_type
;
5585 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5587 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
5588 tex
->coordinate
= var_ref(P
);
5589 tex
->set_sampler(var_ref(s
), return_type
);
5591 body
.emit(ret(tex
));
5596 UNOP(dFdx
, ir_unop_dFdx
, derivatives
)
5597 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, derivative_control
)
5598 UNOP(dFdxFine
, ir_unop_dFdx_fine
, derivative_control
)
5599 UNOP(dFdy
, ir_unop_dFdy
, derivatives
)
5600 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, derivative_control
)
5601 UNOP(dFdyFine
, ir_unop_dFdy_fine
, derivative_control
)
5603 ir_function_signature
*
5604 builtin_builder::_fwidth(const glsl_type
*type
)
5606 ir_variable
*p
= in_var(type
, "p");
5607 MAKE_SIG(type
, derivatives
, 1, p
);
5609 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
5614 ir_function_signature
*
5615 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
5617 ir_variable
*p
= in_var(type
, "p");
5618 MAKE_SIG(type
, derivative_control
, 1, p
);
5620 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
5621 abs(expr(ir_unop_dFdy_coarse
, p
)))));
5626 ir_function_signature
*
5627 builtin_builder::_fwidthFine(const glsl_type
*type
)
5629 ir_variable
*p
= in_var(type
, "p");
5630 MAKE_SIG(type
, derivative_control
, 1, p
);
5632 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
5633 abs(expr(ir_unop_dFdy_fine
, p
)))));
5638 ir_function_signature
*
5639 builtin_builder::_noise1(const glsl_type
*type
)
5641 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
5644 ir_function_signature
*
5645 builtin_builder::_noise2(const glsl_type
*type
)
5647 ir_variable
*p
= in_var(type
, "p");
5648 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
5650 ir_constant_data b_offset
;
5651 b_offset
.f
[0] = 601.0f
;
5652 b_offset
.f
[1] = 313.0f
;
5653 b_offset
.f
[2] = 29.0f
;
5654 b_offset
.f
[3] = 277.0f
;
5656 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5657 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5658 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
5659 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5660 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5661 body
.emit(assign(t
, a
, WRITEMASK_X
));
5662 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5668 ir_function_signature
*
5669 builtin_builder::_noise3(const glsl_type
*type
)
5671 ir_variable
*p
= in_var(type
, "p");
5672 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
5674 ir_constant_data b_offset
;
5675 b_offset
.f
[0] = 601.0f
;
5676 b_offset
.f
[1] = 313.0f
;
5677 b_offset
.f
[2] = 29.0f
;
5678 b_offset
.f
[3] = 277.0f
;
5680 ir_constant_data c_offset
;
5681 c_offset
.f
[0] = 1559.0f
;
5682 c_offset
.f
[1] = 113.0f
;
5683 c_offset
.f
[2] = 1861.0f
;
5684 c_offset
.f
[3] = 797.0f
;
5686 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5687 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5688 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5689 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
5690 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5691 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5692 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
5693 body
.emit(assign(t
, a
, WRITEMASK_X
));
5694 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5695 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5701 ir_function_signature
*
5702 builtin_builder::_noise4(const glsl_type
*type
)
5704 ir_variable
*p
= in_var(type
, "p");
5705 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
5707 ir_variable
*_p
= body
.make_temp(type
, "_p");
5709 ir_constant_data p_offset
;
5710 p_offset
.f
[0] = 1559.0f
;
5711 p_offset
.f
[1] = 113.0f
;
5712 p_offset
.f
[2] = 1861.0f
;
5713 p_offset
.f
[3] = 797.0f
;
5715 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
5717 ir_constant_data offset
;
5718 offset
.f
[0] = 601.0f
;
5719 offset
.f
[1] = 313.0f
;
5720 offset
.f
[2] = 29.0f
;
5721 offset
.f
[3] = 277.0f
;
5723 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5724 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5725 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5726 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
5727 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
5728 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5729 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
5730 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
5731 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
5732 body
.emit(assign(t
, a
, WRITEMASK_X
));
5733 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5734 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5735 body
.emit(assign(t
, d
, WRITEMASK_W
));
5741 ir_function_signature
*
5742 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
5744 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5745 ir_variable
*value
= in_var(type
, "value");
5746 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5747 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5748 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, value
, offset
,
5751 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5752 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5754 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
5755 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5756 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5761 ir_function_signature
*
5762 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5764 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5765 ir_variable
*base
= in_var(type
, "base");
5766 ir_variable
*insert
= in_var(type
, "insert");
5767 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5768 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5769 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 4, base
, insert
,
5772 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5773 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5775 body
.emit(ret(bitfield_insert(base
, insert
,
5776 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5777 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5782 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31_or_integer_functions
)
5784 ir_function_signature
*
5785 builtin_builder::_bitCount(const glsl_type
*type
)
5787 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_bit_count
,
5788 glsl_type::ivec(type
->vector_elements
), type
);
5791 ir_function_signature
*
5792 builtin_builder::_findLSB(const glsl_type
*type
)
5794 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_lsb
,
5795 glsl_type::ivec(type
->vector_elements
), type
);
5798 ir_function_signature
*
5799 builtin_builder::_findMSB(const glsl_type
*type
)
5801 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_msb
,
5802 glsl_type::ivec(type
->vector_elements
), type
);
5805 ir_function_signature
*
5806 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5808 ir_variable
*a
= in_var(type
, "a");
5809 ir_variable
*b
= in_var(type
, "b");
5810 ir_variable
*c
= in_var(type
, "c");
5811 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5813 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5818 ir_function_signature
*
5819 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5821 return binop(x_type
->is_double() ? fp64
: gpu_shader5_or_es31_or_integer_functions
,
5822 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5825 ir_function_signature
*
5826 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5828 ir_variable
*x
= in_var(x_type
, "x");
5829 ir_variable
*exponent
= out_var(exp_type
, "exp");
5830 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5832 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5834 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5838 ir_function_signature
*
5839 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5841 ir_variable
*x
= in_var(x_type
, "x");
5842 ir_variable
*exponent
= out_var(exp_type
, "exp");
5843 MAKE_SIG(x_type
, gpu_shader5_or_es31_or_integer_functions
, 2, x
, exponent
);
5845 const unsigned vec_elem
= x_type
->vector_elements
;
5846 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5847 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5849 /* Single-precision floating-point values are stored as
5854 * An exponent shift of 23 will shift the mantissa out, leaving only the
5855 * exponent and sign bit (which itself may be zero, if the absolute value
5856 * was taken before the bitcast and shift.
5858 ir_constant
*exponent_shift
= imm(23);
5859 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5861 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5863 /* Exponent of floating-point values in the range [0.5, 1.0). */
5864 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5866 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5867 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5869 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5870 * to unsigned integers to ensure that 1 bits aren't shifted in.
5872 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5873 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5874 imm(0, vec_elem
)))));
5876 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5877 body
.emit(assign(bits
, bitcast_f2u(x
)));
5878 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5879 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5880 imm(0u, vec_elem
)))));
5881 body
.emit(ret(bitcast_u2f(bits
)));
5886 ir_function_signature
*
5887 builtin_builder::_uaddCarry(const glsl_type
*type
)
5889 ir_variable
*x
= in_var(type
, "x");
5890 ir_variable
*y
= in_var(type
, "y");
5891 ir_variable
*carry
= out_var(type
, "carry");
5892 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, carry
);
5894 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5895 body
.emit(ret(add(x
, y
)));
5900 ir_function_signature
*
5901 builtin_builder::_usubBorrow(const glsl_type
*type
)
5903 ir_variable
*x
= in_var(type
, "x");
5904 ir_variable
*y
= in_var(type
, "y");
5905 ir_variable
*borrow
= out_var(type
, "borrow");
5906 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, borrow
);
5908 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5909 body
.emit(ret(sub(x
, y
)));
5915 * For both imulExtended() and umulExtended() built-ins.
5917 ir_function_signature
*
5918 builtin_builder::_mulExtended(const glsl_type
*type
)
5920 const glsl_type
*mul_type
, *unpack_type
;
5921 ir_expression_operation unpack_op
;
5923 if (type
->base_type
== GLSL_TYPE_INT
) {
5924 unpack_op
= ir_unop_unpack_int_2x32
;
5925 mul_type
= glsl_type::get_instance(GLSL_TYPE_INT64
, type
->vector_elements
, 1);
5926 unpack_type
= glsl_type::ivec2_type
;
5928 unpack_op
= ir_unop_unpack_uint_2x32
;
5929 mul_type
= glsl_type::get_instance(GLSL_TYPE_UINT64
, type
->vector_elements
, 1);
5930 unpack_type
= glsl_type::uvec2_type
;
5933 ir_variable
*x
= in_var(type
, "x");
5934 ir_variable
*y
= in_var(type
, "y");
5935 ir_variable
*msb
= out_var(type
, "msb");
5936 ir_variable
*lsb
= out_var(type
, "lsb");
5937 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31_or_integer_functions
, 4, x
, y
, msb
, lsb
);
5939 ir_variable
*unpack_val
= body
.make_temp(unpack_type
, "_unpack_val");
5941 ir_expression
*mul_res
= new(mem_ctx
) ir_expression(ir_binop_mul
, mul_type
,
5942 new(mem_ctx
)ir_dereference_variable(x
),
5943 new(mem_ctx
)ir_dereference_variable(y
));
5945 if (type
->vector_elements
== 1) {
5946 body
.emit(assign(unpack_val
, expr(unpack_op
, mul_res
)));
5947 body
.emit(assign(msb
, swizzle_y(unpack_val
)));
5948 body
.emit(assign(lsb
, swizzle_x(unpack_val
)));
5950 for (int i
= 0; i
< type
->vector_elements
; i
++) {
5951 body
.emit(assign(unpack_val
, expr(unpack_op
, swizzle(mul_res
, i
, 1))));
5952 body
.emit(assign(array_ref(msb
, i
), swizzle_y(unpack_val
)));
5953 body
.emit(assign(array_ref(lsb
, i
), swizzle_x(unpack_val
)));
5960 ir_function_signature
*
5961 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5963 ir_variable
*interpolant
= in_var(type
, "interpolant");
5964 interpolant
->data
.must_be_shader_input
= 1;
5965 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5967 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5972 ir_function_signature
*
5973 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5975 ir_variable
*interpolant
= in_var(type
, "interpolant");
5976 interpolant
->data
.must_be_shader_input
= 1;
5977 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5978 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5980 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5985 ir_function_signature
*
5986 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5988 ir_variable
*interpolant
= in_var(type
, "interpolant");
5989 interpolant
->data
.must_be_shader_input
= 1;
5990 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5991 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5993 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5998 ir_function_signature
*
5999 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
,
6000 enum ir_intrinsic_id id
)
6002 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
6003 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 1, counter
);
6007 ir_function_signature
*
6008 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
,
6009 enum ir_intrinsic_id id
)
6011 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
6012 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
6013 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 2, counter
, data
);
6017 ir_function_signature
*
6018 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
,
6019 enum ir_intrinsic_id id
)
6021 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
6022 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
6023 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
6024 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 3, counter
, compare
, data
);
6028 ir_function_signature
*
6029 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
6030 const glsl_type
*type
,
6031 enum ir_intrinsic_id id
)
6033 ir_variable
*atomic
= in_var(type
, "atomic");
6034 ir_variable
*data
= in_var(type
, "data");
6035 MAKE_INTRINSIC(type
, id
, avail
, 2, atomic
, data
);
6039 ir_function_signature
*
6040 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
6041 const glsl_type
*type
,
6042 enum ir_intrinsic_id id
)
6044 ir_variable
*atomic
= in_var(type
, "atomic");
6045 ir_variable
*data1
= in_var(type
, "data1");
6046 ir_variable
*data2
= in_var(type
, "data2");
6047 MAKE_INTRINSIC(type
, id
, avail
, 3, atomic
, data1
, data2
);
6051 ir_function_signature
*
6052 builtin_builder::_atomic_counter_op(const char *intrinsic
,
6053 builtin_available_predicate avail
)
6055 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
6056 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
6058 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
6059 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6061 body
.emit(ret(retval
));
6065 ir_function_signature
*
6066 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
6067 builtin_available_predicate avail
)
6069 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
6070 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
6071 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
6073 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
6075 /* Instead of generating an __intrinsic_atomic_sub, generate an
6076 * __intrinsic_atomic_add with the data parameter negated.
6078 if (strcmp("__intrinsic_atomic_sub", intrinsic
) == 0) {
6079 ir_variable
*const neg_data
=
6080 body
.make_temp(glsl_type::uint_type
, "neg_data");
6082 body
.emit(assign(neg_data
, neg(data
)));
6084 exec_list parameters
;
6086 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(counter
));
6087 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(neg_data
));
6089 ir_function
*const func
=
6090 shader
->symbols
->get_function("__intrinsic_atomic_add");
6091 ir_instruction
*const c
= call(func
, retval
, parameters
);
6094 assert(parameters
.is_empty());
6098 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6102 body
.emit(ret(retval
));
6106 ir_function_signature
*
6107 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
6108 builtin_available_predicate avail
)
6110 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
6111 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
6112 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
6113 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
6115 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
6116 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6118 body
.emit(ret(retval
));
6122 ir_function_signature
*
6123 builtin_builder::_atomic_op2(const char *intrinsic
,
6124 builtin_available_predicate avail
,
6125 const glsl_type
*type
)
6127 ir_variable
*atomic
= in_var(type
, "atomic_var");
6128 ir_variable
*data
= in_var(type
, "atomic_data");
6129 MAKE_SIG(type
, avail
, 2, atomic
, data
);
6131 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
6132 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6134 body
.emit(ret(retval
));
6138 ir_function_signature
*
6139 builtin_builder::_atomic_op3(const char *intrinsic
,
6140 builtin_available_predicate avail
,
6141 const glsl_type
*type
)
6143 ir_variable
*atomic
= in_var(type
, "atomic_var");
6144 ir_variable
*data1
= in_var(type
, "atomic_data1");
6145 ir_variable
*data2
= in_var(type
, "atomic_data2");
6146 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
6148 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
6149 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6151 body
.emit(ret(retval
));
6155 ir_function_signature
*
6156 builtin_builder::_min3(const glsl_type
*type
)
6158 ir_variable
*x
= in_var(type
, "x");
6159 ir_variable
*y
= in_var(type
, "y");
6160 ir_variable
*z
= in_var(type
, "z");
6161 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6163 ir_expression
*min3
= min2(x
, min2(y
,z
));
6164 body
.emit(ret(min3
));
6169 ir_function_signature
*
6170 builtin_builder::_max3(const glsl_type
*type
)
6172 ir_variable
*x
= in_var(type
, "x");
6173 ir_variable
*y
= in_var(type
, "y");
6174 ir_variable
*z
= in_var(type
, "z");
6175 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6177 ir_expression
*max3
= max2(x
, max2(y
,z
));
6178 body
.emit(ret(max3
));
6183 ir_function_signature
*
6184 builtin_builder::_mid3(const glsl_type
*type
)
6186 ir_variable
*x
= in_var(type
, "x");
6187 ir_variable
*y
= in_var(type
, "y");
6188 ir_variable
*z
= in_var(type
, "z");
6189 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6191 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
6192 body
.emit(ret(mid3
));
6197 static builtin_available_predicate
6198 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
6200 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
6201 type
->sampled_type
== GLSL_TYPE_FLOAT
)
6202 return shader_image_atomic_exchange_float
;
6204 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
) &&
6205 type
->sampled_type
== GLSL_TYPE_FLOAT
)
6206 return shader_image_atomic_add_float
;
6208 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
6209 IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
|
6210 IMAGE_FUNCTION_AVAIL_ATOMIC
))
6211 return shader_image_atomic
;
6214 return shader_image_load_store
;
6217 ir_function_signature
*
6218 builtin_builder::_image_prototype(const glsl_type
*image_type
,
6219 unsigned num_arguments
,
6222 const glsl_type
*data_type
= glsl_type::get_instance(
6223 image_type
->sampled_type
,
6224 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
6226 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
6227 glsl_type::void_type
: data_type
);
6229 /* Addressing arguments that are always present. */
6230 ir_variable
*image
= in_var(image_type
, "image");
6231 ir_variable
*coord
= in_var(
6232 glsl_type::ivec(image_type
->coordinate_components()), "coord");
6234 ir_function_signature
*sig
= new_sig(
6235 ret_type
, get_image_available_predicate(image_type
, flags
),
6238 /* Sample index for multisample images. */
6239 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
6240 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
6242 /* Data arguments. */
6243 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
6244 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
6245 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
6246 ralloc_free(arg_name
);
6249 /* Set the maximal set of qualifiers allowed for this image
6250 * built-in. Function calls with arguments having fewer
6251 * qualifiers than present in the prototype are allowed by the
6252 * spec, but not with more, i.e. this will make the compiler
6253 * accept everything that needs to be accepted, and reject cases
6254 * like loads from write-only or stores to read-only images.
6256 image
->data
.memory_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
6257 image
->data
.memory_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
6258 image
->data
.memory_coherent
= true;
6259 image
->data
.memory_volatile
= true;
6260 image
->data
.memory_restrict
= true;
6265 ir_function_signature
*
6266 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
6267 unsigned /* num_arguments */,
6268 unsigned /* flags */)
6270 const glsl_type
*ret_type
;
6271 unsigned num_components
= image_type
->coordinate_components();
6273 /* From the ARB_shader_image_size extension:
6274 * "Cube images return the dimensions of one face."
6276 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
6277 !image_type
->sampler_array
) {
6281 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
6282 * supported by mesa.
6284 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
6286 ir_variable
*image
= in_var(image_type
, "image");
6287 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
6289 /* Set the maximal set of qualifiers allowed for this image
6290 * built-in. Function calls with arguments having fewer
6291 * qualifiers than present in the prototype are allowed by the
6292 * spec, but not with more, i.e. this will make the compiler
6293 * accept everything that needs to be accepted, and reject cases
6294 * like loads from write-only or stores to read-only images.
6296 image
->data
.memory_read_only
= true;
6297 image
->data
.memory_write_only
= true;
6298 image
->data
.memory_coherent
= true;
6299 image
->data
.memory_volatile
= true;
6300 image
->data
.memory_restrict
= true;
6305 ir_function_signature
*
6306 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
6307 unsigned /* num_arguments */,
6308 unsigned /* flags */)
6310 ir_variable
*image
= in_var(image_type
, "image");
6311 ir_function_signature
*sig
=
6312 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
6314 /* Set the maximal set of qualifiers allowed for this image
6315 * built-in. Function calls with arguments having fewer
6316 * qualifiers than present in the prototype are allowed by the
6317 * spec, but not with more, i.e. this will make the compiler
6318 * accept everything that needs to be accepted, and reject cases
6319 * like loads from write-only or stores to read-only images.
6321 image
->data
.memory_read_only
= true;
6322 image
->data
.memory_write_only
= true;
6323 image
->data
.memory_coherent
= true;
6324 image
->data
.memory_volatile
= true;
6325 image
->data
.memory_restrict
= true;
6330 ir_function_signature
*
6331 builtin_builder::_image(image_prototype_ctr prototype
,
6332 const glsl_type
*image_type
,
6333 const char *intrinsic_name
,
6334 unsigned num_arguments
,
6336 enum ir_intrinsic_id id
)
6338 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
6339 num_arguments
, flags
);
6341 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
6342 ir_factory
body(&sig
->body
, mem_ctx
);
6343 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
6345 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
6346 body
.emit(call(f
, NULL
, sig
->parameters
));
6348 ir_variable
*ret_val
=
6349 body
.make_temp(sig
->return_type
, "_ret_val");
6350 body
.emit(call(f
, ret_val
, sig
->parameters
));
6351 body
.emit(ret(ret_val
));
6354 sig
->is_defined
= true;
6357 sig
->intrinsic_id
= id
;
6363 ir_function_signature
*
6364 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
,
6365 enum ir_intrinsic_id id
)
6367 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6371 ir_function_signature
*
6372 builtin_builder::_memory_barrier(const char *intrinsic_name
,
6373 builtin_available_predicate avail
)
6375 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6376 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6377 NULL
, sig
->parameters
));
6381 ir_function_signature
*
6382 builtin_builder::_ballot_intrinsic()
6384 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6385 MAKE_INTRINSIC(glsl_type::uint64_t_type
, ir_intrinsic_ballot
, shader_ballot
,
6390 ir_function_signature
*
6391 builtin_builder::_ballot()
6393 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6395 MAKE_SIG(glsl_type::uint64_t_type
, shader_ballot
, 1, value
);
6396 ir_variable
*retval
= body
.make_temp(glsl_type::uint64_t_type
, "retval");
6398 body
.emit(call(shader
->symbols
->get_function("__intrinsic_ballot"),
6399 retval
, sig
->parameters
));
6400 body
.emit(ret(retval
));
6404 ir_function_signature
*
6405 builtin_builder::_read_first_invocation_intrinsic(const glsl_type
*type
)
6407 ir_variable
*value
= in_var(type
, "value");
6408 MAKE_INTRINSIC(type
, ir_intrinsic_read_first_invocation
, shader_ballot
,
6413 ir_function_signature
*
6414 builtin_builder::_read_first_invocation(const glsl_type
*type
)
6416 ir_variable
*value
= in_var(type
, "value");
6418 MAKE_SIG(type
, shader_ballot
, 1, value
);
6419 ir_variable
*retval
= body
.make_temp(type
, "retval");
6421 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_first_invocation"),
6422 retval
, sig
->parameters
));
6423 body
.emit(ret(retval
));
6427 ir_function_signature
*
6428 builtin_builder::_read_invocation_intrinsic(const glsl_type
*type
)
6430 ir_variable
*value
= in_var(type
, "value");
6431 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6432 MAKE_INTRINSIC(type
, ir_intrinsic_read_invocation
, shader_ballot
,
6433 2, value
, invocation
);
6437 ir_function_signature
*
6438 builtin_builder::_read_invocation(const glsl_type
*type
)
6440 ir_variable
*value
= in_var(type
, "value");
6441 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6443 MAKE_SIG(type
, shader_ballot
, 2, value
, invocation
);
6444 ir_variable
*retval
= body
.make_temp(type
, "retval");
6446 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_invocation"),
6447 retval
, sig
->parameters
));
6448 body
.emit(ret(retval
));
6452 ir_function_signature
*
6453 builtin_builder::_invocation_interlock_intrinsic(builtin_available_predicate avail
,
6454 enum ir_intrinsic_id id
)
6456 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6460 ir_function_signature
*
6461 builtin_builder::_invocation_interlock(const char *intrinsic_name
,
6462 builtin_available_predicate avail
)
6464 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6465 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6466 NULL
, sig
->parameters
));
6470 ir_function_signature
*
6471 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
6472 const glsl_type
*type
)
6474 MAKE_INTRINSIC(type
, ir_intrinsic_shader_clock
, avail
, 0);
6478 ir_function_signature
*
6479 builtin_builder::_shader_clock(builtin_available_predicate avail
,
6480 const glsl_type
*type
)
6482 MAKE_SIG(type
, avail
, 0);
6484 ir_variable
*retval
= body
.make_temp(glsl_type::uvec2_type
, "clock_retval");
6486 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
6487 retval
, sig
->parameters
));
6489 if (type
== glsl_type::uint64_t_type
) {
6490 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, retval
)));
6492 body
.emit(ret(retval
));
6498 ir_function_signature
*
6499 builtin_builder::_vote_intrinsic(builtin_available_predicate avail
,
6500 enum ir_intrinsic_id id
)
6502 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6503 MAKE_INTRINSIC(glsl_type::bool_type
, id
, avail
, 1, value
);
6507 ir_function_signature
*
6508 builtin_builder::_vote(const char *intrinsic_name
,
6509 builtin_available_predicate avail
)
6511 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6513 MAKE_SIG(glsl_type::bool_type
, avail
, 1, value
);
6515 ir_variable
*retval
= body
.make_temp(glsl_type::bool_type
, "retval");
6517 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6518 retval
, sig
->parameters
));
6519 body
.emit(ret(retval
));
6525 /******************************************************************************/
6527 /* The singleton instance of builtin_builder. */
6528 static builtin_builder builtins
;
6529 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
6532 * External API (exposing the built-in module to the rest of the compiler):
6536 _mesa_glsl_initialize_builtin_functions()
6538 mtx_lock(&builtins_lock
);
6539 builtins
.initialize();
6540 mtx_unlock(&builtins_lock
);
6544 _mesa_glsl_release_builtin_functions()
6546 mtx_lock(&builtins_lock
);
6548 mtx_unlock(&builtins_lock
);
6551 ir_function_signature
*
6552 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
6553 const char *name
, exec_list
*actual_parameters
)
6555 ir_function_signature
*s
;
6556 mtx_lock(&builtins_lock
);
6557 s
= builtins
.find(state
, name
, actual_parameters
);
6558 mtx_unlock(&builtins_lock
);
6564 _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state
*state
, const char *name
)
6568 mtx_lock(&builtins_lock
);
6569 f
= builtins
.shader
->symbols
->get_function(name
);
6571 foreach_in_list(ir_function_signature
, sig
, &f
->signatures
) {
6572 if (sig
->is_builtin_available(state
)) {
6578 mtx_unlock(&builtins_lock
);
6584 _mesa_glsl_get_builtin_function_shader()
6586 return builtins
.shader
;
6591 * Get the function signature for main from a shader
6593 ir_function_signature
*
6594 _mesa_get_main_function_signature(glsl_symbol_table
*symbols
)
6596 ir_function
*const f
= symbols
->get_function("main");
6598 exec_list void_parameters
;
6600 /* Look for the 'void main()' signature and ensure that it's defined.
6601 * This keeps the linker from accidentally pick a shader that just
6602 * contains a prototype for main.
6604 * We don't have to check for multiple definitions of main (in multiple
6605 * shaders) because that would have already been caught above.
6607 ir_function_signature
*sig
=
6608 f
->matching_signature(NULL
, &void_parameters
, false);
6609 if ((sig
!= NULL
) && sig
->is_defined
) {