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 fs_only(const _mesa_glsl_parse_state
*state
)
114 return state
->stage
== MESA_SHADER_FRAGMENT
;
118 gs_only(const _mesa_glsl_parse_state
*state
)
120 return state
->stage
== MESA_SHADER_GEOMETRY
;
124 v110(const _mesa_glsl_parse_state
*state
)
126 return !state
->es_shader
;
130 v110_fs_only(const _mesa_glsl_parse_state
*state
)
132 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
136 v120(const _mesa_glsl_parse_state
*state
)
138 return state
->is_version(120, 300);
142 v130(const _mesa_glsl_parse_state
*state
)
144 return state
->is_version(130, 300);
148 v130_desktop(const _mesa_glsl_parse_state
*state
)
150 return state
->is_version(130, 0);
154 v460_desktop(const _mesa_glsl_parse_state
*state
)
156 return state
->is_version(460, 0);
160 v130_fs_only(const _mesa_glsl_parse_state
*state
)
162 return state
->is_version(130, 300) &&
163 state
->stage
== MESA_SHADER_FRAGMENT
;
167 v140_or_es3(const _mesa_glsl_parse_state
*state
)
169 return state
->is_version(140, 300);
173 v400_fs_only(const _mesa_glsl_parse_state
*state
)
175 return state
->is_version(400, 0) &&
176 state
->stage
== MESA_SHADER_FRAGMENT
;
180 texture_rectangle(const _mesa_glsl_parse_state
*state
)
182 return state
->ARB_texture_rectangle_enable
;
186 texture_external(const _mesa_glsl_parse_state
*state
)
188 return state
->OES_EGL_image_external_enable
;
192 texture_external_es3(const _mesa_glsl_parse_state
*state
)
194 return state
->OES_EGL_image_external_essl3_enable
&&
196 state
->is_version(0, 300);
199 /** True if texturing functions with explicit LOD are allowed. */
201 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
203 /* Texturing functions with "Lod" in their name exist:
204 * - In the vertex shader stage (for all languages)
205 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
206 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
208 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
209 * don't need to explicitly check state->es_shader.
211 return state
->stage
== MESA_SHADER_VERTEX
||
212 state
->is_version(130, 300) ||
213 state
->ARB_shader_texture_lod_enable
;
217 v110_lod(const _mesa_glsl_parse_state
*state
)
219 return !state
->es_shader
&& lod_exists_in_stage(state
);
223 texture_buffer(const _mesa_glsl_parse_state
*state
)
225 return state
->is_version(140, 320) ||
226 state
->EXT_texture_buffer_enable
||
227 state
->OES_texture_buffer_enable
;
231 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
233 return state
->ARB_shader_texture_lod_enable
;
237 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
239 return state
->ARB_shader_texture_lod_enable
&&
240 state
->ARB_texture_rectangle_enable
;
244 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
246 return state
->is_version(330, 300) ||
247 state
->ARB_shader_bit_encoding_enable
||
248 state
->ARB_gpu_shader5_enable
;
252 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
254 return state
->is_version(450, 310) ||
255 state
->ARB_ES3_1_compatibility_enable
||
256 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
260 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
262 return state
->ARB_shading_language_packing_enable
||
263 state
->is_version(420, 300);
267 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
269 return state
->ARB_shading_language_packing_enable
||
270 state
->ARB_gpu_shader5_enable
||
271 state
->is_version(400, 300);
275 gpu_shader5(const _mesa_glsl_parse_state
*state
)
277 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
281 gpu_shader5_es(const _mesa_glsl_parse_state
*state
)
283 return state
->is_version(400, 320) ||
284 state
->ARB_gpu_shader5_enable
||
285 state
->EXT_gpu_shader5_enable
||
286 state
->OES_gpu_shader5_enable
;
290 gpu_shader5_or_OES_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
292 return state
->is_version(400, 320) ||
293 state
->ARB_gpu_shader5_enable
||
294 state
->EXT_texture_cube_map_array_enable
||
295 state
->OES_texture_cube_map_array_enable
;
299 es31_not_gs5(const _mesa_glsl_parse_state
*state
)
301 return state
->is_version(0, 310) && !gpu_shader5_es(state
);
305 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
307 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
311 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
313 return state
->ARB_shading_language_packing_enable
||
314 state
->ARB_gpu_shader5_enable
||
315 state
->is_version(400, 310);
319 gpu_shader5_or_es31_or_integer_functions(const _mesa_glsl_parse_state
*state
)
321 return gpu_shader5_or_es31(state
) ||
322 state
->MESA_shader_integer_functions_enable
;
326 fs_interpolate_at(const _mesa_glsl_parse_state
*state
)
328 return state
->stage
== MESA_SHADER_FRAGMENT
&&
329 (state
->is_version(400, 320) ||
330 state
->ARB_gpu_shader5_enable
||
331 state
->OES_shader_multisample_interpolation_enable
);
336 texture_array_lod(const _mesa_glsl_parse_state
*state
)
338 return lod_exists_in_stage(state
) &&
339 state
->EXT_texture_array_enable
;
343 fs_texture_array(const _mesa_glsl_parse_state
*state
)
345 return state
->stage
== MESA_SHADER_FRAGMENT
&&
346 state
->EXT_texture_array_enable
;
350 texture_array(const _mesa_glsl_parse_state
*state
)
352 return state
->EXT_texture_array_enable
;
356 texture_multisample(const _mesa_glsl_parse_state
*state
)
358 return state
->is_version(150, 310) ||
359 state
->ARB_texture_multisample_enable
;
363 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
365 return state
->is_version(150, 320) ||
366 state
->ARB_texture_multisample_enable
||
367 state
->OES_texture_storage_multisample_2d_array_enable
;
371 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
373 return texture_multisample(state
) &&
374 state
->EXT_shader_samples_identical_enable
;
378 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
380 return texture_multisample_array(state
) &&
381 state
->EXT_shader_samples_identical_enable
;
385 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
387 return state
->stage
== MESA_SHADER_FRAGMENT
&&
388 state
->has_texture_cube_map_array();
392 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
394 return state
->has_texture_cube_map_array();
398 texture_query_levels(const _mesa_glsl_parse_state
*state
)
400 return state
->is_version(430, 0) ||
401 state
->ARB_texture_query_levels_enable
;
405 texture_query_lod(const _mesa_glsl_parse_state
*state
)
407 return state
->stage
== MESA_SHADER_FRAGMENT
&&
408 state
->ARB_texture_query_lod_enable
;
412 texture_gather_cube_map_array(const _mesa_glsl_parse_state
*state
)
414 return state
->is_version(400, 320) ||
415 state
->ARB_texture_gather_enable
||
416 state
->ARB_gpu_shader5_enable
||
417 state
->EXT_texture_cube_map_array_enable
||
418 state
->OES_texture_cube_map_array_enable
;
422 texture_texture4(const _mesa_glsl_parse_state
*state
)
424 return state
->AMD_texture_texture4_enable
;
428 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
430 return state
->is_version(400, 310) ||
431 state
->ARB_texture_gather_enable
||
432 state
->ARB_gpu_shader5_enable
;
435 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
436 * used for relaxation of const offset requirements.
439 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
441 return !state
->is_version(400, 320) &&
442 !state
->ARB_gpu_shader5_enable
&&
443 !state
->EXT_gpu_shader5_enable
&&
444 !state
->OES_gpu_shader5_enable
&&
445 (state
->ARB_texture_gather_enable
||
446 state
->is_version(0, 310));
449 /* Desktop GL or OES_standard_derivatives + fragment shader only */
451 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
453 return state
->stage
== MESA_SHADER_FRAGMENT
&&
454 (state
->is_version(110, 300) ||
455 state
->OES_standard_derivatives_enable
||
456 state
->ctx
->Const
.AllowGLSLRelaxedES
);
460 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
462 return state
->stage
== MESA_SHADER_FRAGMENT
&&
463 (state
->is_version(450, 0) ||
464 state
->ARB_derivative_control_enable
);
468 tex1d_lod(const _mesa_glsl_parse_state
*state
)
470 return !state
->es_shader
&& lod_exists_in_stage(state
);
473 /** True if sampler3D exists */
475 tex3d(const _mesa_glsl_parse_state
*state
)
477 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
478 * OES_texture_3D extension, and in GLSL ES 3.00.
480 return !state
->es_shader
||
481 state
->OES_texture_3D_enable
||
482 state
->language_version
>= 300;
486 fs_tex3d(const _mesa_glsl_parse_state
*state
)
488 return state
->stage
== MESA_SHADER_FRAGMENT
&&
489 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
493 tex3d_lod(const _mesa_glsl_parse_state
*state
)
495 return tex3d(state
) && lod_exists_in_stage(state
);
499 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
501 return state
->has_atomic_counters();
505 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
507 return state
->ARB_shader_atomic_counter_ops_enable
;
511 shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
513 return state
->ARB_shader_atomic_counter_ops_enable
|| v460_desktop(state
);
517 shader_ballot(const _mesa_glsl_parse_state
*state
)
519 return state
->ARB_shader_ballot_enable
;
523 supports_arb_fragment_shader_interlock(const _mesa_glsl_parse_state
*state
)
525 return state
->ARB_fragment_shader_interlock_enable
;
529 supports_nv_fragment_shader_interlock(const _mesa_glsl_parse_state
*state
)
531 return state
->NV_fragment_shader_interlock_enable
;
535 shader_clock(const _mesa_glsl_parse_state
*state
)
537 return state
->ARB_shader_clock_enable
;
541 shader_clock_int64(const _mesa_glsl_parse_state
*state
)
543 return state
->ARB_shader_clock_enable
&&
544 (state
->ARB_gpu_shader_int64_enable
||
545 state
->AMD_gpu_shader_int64_enable
);
549 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
551 return state
->has_shader_storage_buffer_objects();
555 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
557 return state
->AMD_shader_trinary_minmax_enable
;
561 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
563 return (state
->is_version(420, 310) ||
564 state
->ARB_shader_image_load_store_enable
);
568 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
570 return (state
->is_version(420, 320) ||
571 state
->ARB_shader_image_load_store_enable
||
572 state
->OES_shader_image_atomic_enable
);
576 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
578 return (state
->is_version(450, 320) ||
579 state
->ARB_ES3_1_compatibility_enable
||
580 state
->OES_shader_image_atomic_enable
||
581 state
->NV_shader_atomic_float_enable
);
585 shader_image_atomic_add_float(const _mesa_glsl_parse_state
*state
)
587 return state
->NV_shader_atomic_float_enable
;
591 shader_image_size(const _mesa_glsl_parse_state
*state
)
593 return state
->is_version(430, 310) ||
594 state
->ARB_shader_image_size_enable
;
598 shader_samples(const _mesa_glsl_parse_state
*state
)
600 return state
->is_version(450, 0) ||
601 state
->ARB_shader_texture_image_samples_enable
;
605 gs_streams(const _mesa_glsl_parse_state
*state
)
607 return gpu_shader5(state
) && gs_only(state
);
611 fp64(const _mesa_glsl_parse_state
*state
)
613 return state
->has_double();
617 int64(const _mesa_glsl_parse_state
*state
)
619 return state
->has_int64();
623 int64_fp64(const _mesa_glsl_parse_state
*state
)
625 return state
->has_int64() && state
->has_double();
629 compute_shader(const _mesa_glsl_parse_state
*state
)
631 return state
->stage
== MESA_SHADER_COMPUTE
;
635 compute_shader_supported(const _mesa_glsl_parse_state
*state
)
637 return state
->has_compute_shader();
641 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
643 return compute_shader(state
) || shader_storage_buffer_object(state
);
647 barrier_supported(const _mesa_glsl_parse_state
*state
)
649 return compute_shader(state
) ||
650 state
->stage
== MESA_SHADER_TESS_CTRL
;
654 vote(const _mesa_glsl_parse_state
*state
)
656 return state
->ARB_shader_group_vote_enable
;
660 vote_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
662 return state
->ARB_shader_group_vote_enable
|| v460_desktop(state
);
666 integer_functions_supported(const _mesa_glsl_parse_state
*state
)
668 return state
->extensions
->MESA_shader_integer_functions
;
672 NV_shader_atomic_float_supported(const _mesa_glsl_parse_state
*state
)
674 return state
->extensions
->NV_shader_atomic_float
;
678 shader_atomic_float_add(const _mesa_glsl_parse_state
*state
)
680 return state
->NV_shader_atomic_float_enable
;
684 shader_atomic_float_exchange(const _mesa_glsl_parse_state
*state
)
686 return state
->NV_shader_atomic_float_enable
||
687 state
->INTEL_shader_atomic_float_minmax_enable
;
691 INTEL_shader_atomic_float_minmax_supported(const _mesa_glsl_parse_state
*state
)
693 return state
->extensions
->INTEL_shader_atomic_float_minmax
;
697 shader_atomic_float_minmax(const _mesa_glsl_parse_state
*state
)
699 return state
->INTEL_shader_atomic_float_minmax_enable
;
703 /******************************************************************************/
708 * builtin_builder: A singleton object representing the core of the built-in
711 * It generates IR for every built-in function signature, and organizes them
714 class builtin_builder
{
721 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
722 const char *name
, exec_list
*actual_parameters
);
725 * A shader to hold all the built-in signatures; created by this module.
727 * This includes signatures for every built-in, regardless of version or
728 * enabled extensions. The availability predicate associated with each
729 * signature allows matching_signature() to filter out the irrelevant ones.
736 void create_shader();
737 void create_intrinsics();
738 void create_builtins();
741 * IR builder helpers:
743 * These convenience functions assist in emitting IR, but don't necessarily
744 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
747 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
748 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
749 ir_constant
*imm(float f
, unsigned vector_elements
=1);
750 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
751 ir_constant
*imm(int i
, unsigned vector_elements
=1);
752 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
753 ir_constant
*imm(double d
, unsigned vector_elements
=1);
754 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
755 ir_dereference_variable
*var_ref(ir_variable
*var
);
756 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
757 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
759 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
760 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
763 * Call function \param f with parameters specified as the linked
764 * list \param params of \c ir_variable objects. \param ret should
765 * point to the ir_variable that will hold the function return
766 * value, or be \c NULL if the function has void return type.
768 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
770 /** Create a new function and add the given signatures. */
771 void add_function(const char *name
, ...);
773 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
774 unsigned num_arguments
,
778 * Create a new image built-in function for all known image types.
779 * \p flags is a bitfield of \c image_function_flags flags.
781 void add_image_function(const char *name
,
782 const char *intrinsic_name
,
783 image_prototype_ctr prototype
,
784 unsigned num_arguments
,
786 enum ir_intrinsic_id id
);
789 * Create new functions for all known image built-ins and types.
790 * If \p glsl is \c true, use the GLSL built-in names and emit code
791 * to call into the actual compiler intrinsic. If \p glsl is
792 * false, emit a function prototype with no body for each image
795 void add_image_functions(bool glsl
);
797 ir_function_signature
*new_sig(const glsl_type
*return_type
,
798 builtin_available_predicate avail
,
799 int num_params
, ...);
802 * Function signature generators:
805 ir_function_signature
*unop(builtin_available_predicate avail
,
806 ir_expression_operation opcode
,
807 const glsl_type
*return_type
,
808 const glsl_type
*param_type
);
809 ir_function_signature
*binop(builtin_available_predicate avail
,
810 ir_expression_operation opcode
,
811 const glsl_type
*return_type
,
812 const glsl_type
*param0_type
,
813 const glsl_type
*param1_type
,
814 bool swap_operands
= false);
816 #define B0(X) ir_function_signature *_##X();
817 #define B1(X) ir_function_signature *_##X(const glsl_type *);
818 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
819 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
820 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
821 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
858 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
859 const glsl_type
*val_type
,
860 const glsl_type
*blend_type
);
870 BA1(doubleBitsToInt64
)
871 BA1(doubleBitsToUint64
)
872 BA1(int64BitsToDouble
)
873 BA1(uint64BitsToDouble
)
875 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
876 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
877 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
878 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
879 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
880 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
881 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
882 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
883 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
884 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
885 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
886 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
887 ir_function_signature
*_packInt2x32(builtin_available_predicate avail
);
888 ir_function_signature
*_unpackInt2x32(builtin_available_predicate avail
);
889 ir_function_signature
*_packUint2x32(builtin_available_predicate avail
);
890 ir_function_signature
*_unpackUint2x32(builtin_available_predicate avail
);
903 BA1(determinant_mat2
);
904 BA1(determinant_mat3
);
905 BA1(determinant_mat4
);
913 BA1(greaterThanEqual
);
922 /** Flags to _texture() */
923 #define TEX_PROJECT 1
925 #define TEX_COMPONENT 4
926 #define TEX_OFFSET_NONCONST 8
927 #define TEX_OFFSET_ARRAY 16
929 ir_function_signature
*_texture(ir_texture_opcode opcode
,
930 builtin_available_predicate avail
,
931 const glsl_type
*return_type
,
932 const glsl_type
*sampler_type
,
933 const glsl_type
*coord_type
,
935 BA1(textureCubeArrayShadow
);
936 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
937 const glsl_type
*return_type
,
938 const glsl_type
*sampler_type
,
939 const glsl_type
*coord_type
,
940 const glsl_type
*offset_type
= NULL
);
944 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
945 const glsl_type
*stream_type
);
946 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
947 const glsl_type
*stream_type
);
950 BA2(textureQueryLod
);
951 BA1(textureQueryLevels
);
952 BA2(textureSamplesIdentical
);
980 B1(interpolateAtCentroid
)
981 B1(interpolateAtOffset
)
982 B1(interpolateAtSample
)
984 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
,
985 enum ir_intrinsic_id id
);
986 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
,
987 enum ir_intrinsic_id id
);
988 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
,
989 enum ir_intrinsic_id id
);
990 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
991 builtin_available_predicate avail
);
992 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
993 builtin_available_predicate avail
);
994 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
995 builtin_available_predicate avail
);
997 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
998 const glsl_type
*type
,
999 enum ir_intrinsic_id id
);
1000 ir_function_signature
*_atomic_op2(const char *intrinsic
,
1001 builtin_available_predicate avail
,
1002 const glsl_type
*type
);
1003 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
1004 const glsl_type
*type
,
1005 enum ir_intrinsic_id id
);
1006 ir_function_signature
*_atomic_op3(const char *intrinsic
,
1007 builtin_available_predicate avail
,
1008 const glsl_type
*type
);
1014 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
1015 unsigned num_arguments
,
1017 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
1018 unsigned num_arguments
,
1020 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
1021 unsigned num_arguments
,
1023 ir_function_signature
*_image(image_prototype_ctr prototype
,
1024 const glsl_type
*image_type
,
1025 const char *intrinsic_name
,
1026 unsigned num_arguments
,
1028 enum ir_intrinsic_id id
);
1030 ir_function_signature
*_memory_barrier_intrinsic(
1031 builtin_available_predicate avail
,
1032 enum ir_intrinsic_id id
);
1033 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
1034 builtin_available_predicate avail
);
1036 ir_function_signature
*_ballot_intrinsic();
1037 ir_function_signature
*_ballot();
1038 ir_function_signature
*_read_first_invocation_intrinsic(const glsl_type
*type
);
1039 ir_function_signature
*_read_first_invocation(const glsl_type
*type
);
1040 ir_function_signature
*_read_invocation_intrinsic(const glsl_type
*type
);
1041 ir_function_signature
*_read_invocation(const glsl_type
*type
);
1044 ir_function_signature
*_invocation_interlock_intrinsic(
1045 builtin_available_predicate avail
,
1046 enum ir_intrinsic_id id
);
1047 ir_function_signature
*_invocation_interlock(
1048 const char *intrinsic_name
,
1049 builtin_available_predicate avail
);
1051 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
1052 const glsl_type
*type
);
1053 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
1054 const glsl_type
*type
);
1056 ir_function_signature
*_vote_intrinsic(builtin_available_predicate avail
,
1057 enum ir_intrinsic_id id
);
1058 ir_function_signature
*_vote(const char *intrinsic_name
,
1059 builtin_available_predicate avail
);
1070 enum image_function_flags
{
1071 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
1072 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
1073 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
1074 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
1075 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
1076 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
1077 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
1078 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
1079 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8),
1080 IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
= (1 << 9),
1083 } /* anonymous namespace */
1086 * Core builtin_builder functionality:
1089 builtin_builder::builtin_builder()
1095 builtin_builder::~builtin_builder()
1097 ralloc_free(mem_ctx
);
1100 ir_function_signature
*
1101 builtin_builder::find(_mesa_glsl_parse_state
*state
,
1102 const char *name
, exec_list
*actual_parameters
)
1104 /* The shader currently being compiled requested a built-in function;
1105 * it needs to link against builtin_builder::shader in order to get them.
1107 * Even if we don't find a matching signature, we still need to do this so
1108 * that the "no matching signature" error will list potential candidates
1109 * from the available built-ins.
1111 state
->uses_builtin_functions
= true;
1113 ir_function
*f
= shader
->symbols
->get_function(name
);
1117 ir_function_signature
*sig
=
1118 f
->matching_signature(state
, actual_parameters
, true);
1126 builtin_builder::initialize()
1128 /* If already initialized, don't do it again. */
1129 if (mem_ctx
!= NULL
)
1132 mem_ctx
= ralloc_context(NULL
);
1134 create_intrinsics();
1139 builtin_builder::release()
1141 ralloc_free(mem_ctx
);
1144 ralloc_free(shader
);
1149 builtin_builder::create_shader()
1151 /* The target doesn't actually matter. There's no target for generic
1152 * GLSL utility code that could be linked against any stage, so just
1153 * arbitrarily pick GL_VERTEX_SHADER.
1155 shader
= _mesa_new_shader(0, MESA_SHADER_VERTEX
);
1156 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
1162 * Create ir_function and ir_function_signature objects for each
1166 builtin_builder::create_intrinsics()
1168 add_function("__intrinsic_atomic_read",
1169 _atomic_counter_intrinsic(shader_atomic_counters
,
1170 ir_intrinsic_atomic_counter_read
),
1172 add_function("__intrinsic_atomic_increment",
1173 _atomic_counter_intrinsic(shader_atomic_counters
,
1174 ir_intrinsic_atomic_counter_increment
),
1176 add_function("__intrinsic_atomic_predecrement",
1177 _atomic_counter_intrinsic(shader_atomic_counters
,
1178 ir_intrinsic_atomic_counter_predecrement
),
1181 add_function("__intrinsic_atomic_add",
1182 _atomic_intrinsic2(buffer_atomics_supported
,
1183 glsl_type::uint_type
,
1184 ir_intrinsic_generic_atomic_add
),
1185 _atomic_intrinsic2(buffer_atomics_supported
,
1186 glsl_type::int_type
,
1187 ir_intrinsic_generic_atomic_add
),
1188 _atomic_intrinsic2(NV_shader_atomic_float_supported
,
1189 glsl_type::float_type
,
1190 ir_intrinsic_generic_atomic_add
),
1191 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1192 ir_intrinsic_atomic_counter_add
),
1194 add_function("__intrinsic_atomic_min",
1195 _atomic_intrinsic2(buffer_atomics_supported
,
1196 glsl_type::uint_type
,
1197 ir_intrinsic_generic_atomic_min
),
1198 _atomic_intrinsic2(buffer_atomics_supported
,
1199 glsl_type::int_type
,
1200 ir_intrinsic_generic_atomic_min
),
1201 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported
,
1202 glsl_type::float_type
,
1203 ir_intrinsic_generic_atomic_min
),
1204 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1205 ir_intrinsic_atomic_counter_min
),
1207 add_function("__intrinsic_atomic_max",
1208 _atomic_intrinsic2(buffer_atomics_supported
,
1209 glsl_type::uint_type
,
1210 ir_intrinsic_generic_atomic_max
),
1211 _atomic_intrinsic2(buffer_atomics_supported
,
1212 glsl_type::int_type
,
1213 ir_intrinsic_generic_atomic_max
),
1214 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported
,
1215 glsl_type::float_type
,
1216 ir_intrinsic_generic_atomic_max
),
1217 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1218 ir_intrinsic_atomic_counter_max
),
1220 add_function("__intrinsic_atomic_and",
1221 _atomic_intrinsic2(buffer_atomics_supported
,
1222 glsl_type::uint_type
,
1223 ir_intrinsic_generic_atomic_and
),
1224 _atomic_intrinsic2(buffer_atomics_supported
,
1225 glsl_type::int_type
,
1226 ir_intrinsic_generic_atomic_and
),
1227 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1228 ir_intrinsic_atomic_counter_and
),
1230 add_function("__intrinsic_atomic_or",
1231 _atomic_intrinsic2(buffer_atomics_supported
,
1232 glsl_type::uint_type
,
1233 ir_intrinsic_generic_atomic_or
),
1234 _atomic_intrinsic2(buffer_atomics_supported
,
1235 glsl_type::int_type
,
1236 ir_intrinsic_generic_atomic_or
),
1237 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1238 ir_intrinsic_atomic_counter_or
),
1240 add_function("__intrinsic_atomic_xor",
1241 _atomic_intrinsic2(buffer_atomics_supported
,
1242 glsl_type::uint_type
,
1243 ir_intrinsic_generic_atomic_xor
),
1244 _atomic_intrinsic2(buffer_atomics_supported
,
1245 glsl_type::int_type
,
1246 ir_intrinsic_generic_atomic_xor
),
1247 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1248 ir_intrinsic_atomic_counter_xor
),
1250 add_function("__intrinsic_atomic_exchange",
1251 _atomic_intrinsic2(buffer_atomics_supported
,
1252 glsl_type::uint_type
,
1253 ir_intrinsic_generic_atomic_exchange
),
1254 _atomic_intrinsic2(buffer_atomics_supported
,
1255 glsl_type::int_type
,
1256 ir_intrinsic_generic_atomic_exchange
),
1257 _atomic_intrinsic2(NV_shader_atomic_float_supported
,
1258 glsl_type::float_type
,
1259 ir_intrinsic_generic_atomic_exchange
),
1260 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1261 ir_intrinsic_atomic_counter_exchange
),
1263 add_function("__intrinsic_atomic_comp_swap",
1264 _atomic_intrinsic3(buffer_atomics_supported
,
1265 glsl_type::uint_type
,
1266 ir_intrinsic_generic_atomic_comp_swap
),
1267 _atomic_intrinsic3(buffer_atomics_supported
,
1268 glsl_type::int_type
,
1269 ir_intrinsic_generic_atomic_comp_swap
),
1270 _atomic_intrinsic3(INTEL_shader_atomic_float_minmax_supported
,
1271 glsl_type::float_type
,
1272 ir_intrinsic_generic_atomic_comp_swap
),
1273 _atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop
,
1274 ir_intrinsic_atomic_counter_comp_swap
),
1277 add_image_functions(false);
1279 add_function("__intrinsic_memory_barrier",
1280 _memory_barrier_intrinsic(shader_image_load_store
,
1281 ir_intrinsic_memory_barrier
),
1283 add_function("__intrinsic_group_memory_barrier",
1284 _memory_barrier_intrinsic(compute_shader
,
1285 ir_intrinsic_group_memory_barrier
),
1287 add_function("__intrinsic_memory_barrier_atomic_counter",
1288 _memory_barrier_intrinsic(compute_shader_supported
,
1289 ir_intrinsic_memory_barrier_atomic_counter
),
1291 add_function("__intrinsic_memory_barrier_buffer",
1292 _memory_barrier_intrinsic(compute_shader_supported
,
1293 ir_intrinsic_memory_barrier_buffer
),
1295 add_function("__intrinsic_memory_barrier_image",
1296 _memory_barrier_intrinsic(compute_shader_supported
,
1297 ir_intrinsic_memory_barrier_image
),
1299 add_function("__intrinsic_memory_barrier_shared",
1300 _memory_barrier_intrinsic(compute_shader
,
1301 ir_intrinsic_memory_barrier_shared
),
1304 add_function("__intrinsic_begin_invocation_interlock",
1305 _invocation_interlock_intrinsic(
1306 supports_arb_fragment_shader_interlock
,
1307 ir_intrinsic_begin_invocation_interlock
), NULL
);
1309 add_function("__intrinsic_end_invocation_interlock",
1310 _invocation_interlock_intrinsic(
1311 supports_arb_fragment_shader_interlock
,
1312 ir_intrinsic_end_invocation_interlock
), NULL
);
1314 add_function("__intrinsic_shader_clock",
1315 _shader_clock_intrinsic(shader_clock
,
1316 glsl_type::uvec2_type
),
1319 add_function("__intrinsic_vote_all",
1320 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_all
),
1322 add_function("__intrinsic_vote_any",
1323 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_any
),
1325 add_function("__intrinsic_vote_eq",
1326 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_eq
),
1329 add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL
);
1331 add_function("__intrinsic_read_invocation",
1332 _read_invocation_intrinsic(glsl_type::float_type
),
1333 _read_invocation_intrinsic(glsl_type::vec2_type
),
1334 _read_invocation_intrinsic(glsl_type::vec3_type
),
1335 _read_invocation_intrinsic(glsl_type::vec4_type
),
1337 _read_invocation_intrinsic(glsl_type::int_type
),
1338 _read_invocation_intrinsic(glsl_type::ivec2_type
),
1339 _read_invocation_intrinsic(glsl_type::ivec3_type
),
1340 _read_invocation_intrinsic(glsl_type::ivec4_type
),
1342 _read_invocation_intrinsic(glsl_type::uint_type
),
1343 _read_invocation_intrinsic(glsl_type::uvec2_type
),
1344 _read_invocation_intrinsic(glsl_type::uvec3_type
),
1345 _read_invocation_intrinsic(glsl_type::uvec4_type
),
1348 add_function("__intrinsic_read_first_invocation",
1349 _read_first_invocation_intrinsic(glsl_type::float_type
),
1350 _read_first_invocation_intrinsic(glsl_type::vec2_type
),
1351 _read_first_invocation_intrinsic(glsl_type::vec3_type
),
1352 _read_first_invocation_intrinsic(glsl_type::vec4_type
),
1354 _read_first_invocation_intrinsic(glsl_type::int_type
),
1355 _read_first_invocation_intrinsic(glsl_type::ivec2_type
),
1356 _read_first_invocation_intrinsic(glsl_type::ivec3_type
),
1357 _read_first_invocation_intrinsic(glsl_type::ivec4_type
),
1359 _read_first_invocation_intrinsic(glsl_type::uint_type
),
1360 _read_first_invocation_intrinsic(glsl_type::uvec2_type
),
1361 _read_first_invocation_intrinsic(glsl_type::uvec3_type
),
1362 _read_first_invocation_intrinsic(glsl_type::uvec4_type
),
1368 * Create ir_function and ir_function_signature objects for each built-in.
1370 * Contains a list of every available built-in.
1373 builtin_builder::create_builtins()
1376 add_function(#NAME, \
1377 _##NAME(glsl_type::float_type), \
1378 _##NAME(glsl_type::vec2_type), \
1379 _##NAME(glsl_type::vec3_type), \
1380 _##NAME(glsl_type::vec4_type), \
1384 add_function(#NAME, \
1385 _##NAME(always_available, glsl_type::float_type), \
1386 _##NAME(always_available, glsl_type::vec2_type), \
1387 _##NAME(always_available, glsl_type::vec3_type), \
1388 _##NAME(always_available, glsl_type::vec4_type), \
1389 _##NAME(fp64, glsl_type::double_type), \
1390 _##NAME(fp64, glsl_type::dvec2_type), \
1391 _##NAME(fp64, glsl_type::dvec3_type), \
1392 _##NAME(fp64, glsl_type::dvec4_type), \
1395 #define FD130(NAME) \
1396 add_function(#NAME, \
1397 _##NAME(v130, glsl_type::float_type), \
1398 _##NAME(v130, glsl_type::vec2_type), \
1399 _##NAME(v130, glsl_type::vec3_type), \
1400 _##NAME(v130, glsl_type::vec4_type), \
1401 _##NAME(fp64, glsl_type::double_type), \
1402 _##NAME(fp64, glsl_type::dvec2_type), \
1403 _##NAME(fp64, glsl_type::dvec3_type), \
1404 _##NAME(fp64, glsl_type::dvec4_type), \
1407 #define FDGS5(NAME) \
1408 add_function(#NAME, \
1409 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1410 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1411 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1412 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1413 _##NAME(fp64, glsl_type::double_type), \
1414 _##NAME(fp64, glsl_type::dvec2_type), \
1415 _##NAME(fp64, glsl_type::dvec3_type), \
1416 _##NAME(fp64, glsl_type::dvec4_type), \
1420 add_function(#NAME, \
1421 _##NAME(glsl_type::float_type), \
1422 _##NAME(glsl_type::vec2_type), \
1423 _##NAME(glsl_type::vec3_type), \
1424 _##NAME(glsl_type::vec4_type), \
1425 _##NAME(glsl_type::int_type), \
1426 _##NAME(glsl_type::ivec2_type), \
1427 _##NAME(glsl_type::ivec3_type), \
1428 _##NAME(glsl_type::ivec4_type), \
1431 #define FI64(NAME) \
1432 add_function(#NAME, \
1433 _##NAME(always_available, glsl_type::float_type), \
1434 _##NAME(always_available, glsl_type::vec2_type), \
1435 _##NAME(always_available, glsl_type::vec3_type), \
1436 _##NAME(always_available, glsl_type::vec4_type), \
1437 _##NAME(always_available, glsl_type::int_type), \
1438 _##NAME(always_available, glsl_type::ivec2_type), \
1439 _##NAME(always_available, glsl_type::ivec3_type), \
1440 _##NAME(always_available, glsl_type::ivec4_type), \
1441 _##NAME(fp64, glsl_type::double_type), \
1442 _##NAME(fp64, glsl_type::dvec2_type), \
1443 _##NAME(fp64, glsl_type::dvec3_type), \
1444 _##NAME(fp64, glsl_type::dvec4_type), \
1445 _##NAME(int64, glsl_type::int64_t_type), \
1446 _##NAME(int64, glsl_type::i64vec2_type), \
1447 _##NAME(int64, glsl_type::i64vec3_type), \
1448 _##NAME(int64, glsl_type::i64vec4_type), \
1451 #define FIUD_VEC(NAME) \
1452 add_function(#NAME, \
1453 _##NAME(always_available, glsl_type::vec2_type), \
1454 _##NAME(always_available, glsl_type::vec3_type), \
1455 _##NAME(always_available, glsl_type::vec4_type), \
1457 _##NAME(always_available, glsl_type::ivec2_type), \
1458 _##NAME(always_available, glsl_type::ivec3_type), \
1459 _##NAME(always_available, glsl_type::ivec4_type), \
1461 _##NAME(v130, glsl_type::uvec2_type), \
1462 _##NAME(v130, glsl_type::uvec3_type), \
1463 _##NAME(v130, glsl_type::uvec4_type), \
1464 _##NAME(fp64, glsl_type::dvec2_type), \
1465 _##NAME(fp64, glsl_type::dvec3_type), \
1466 _##NAME(fp64, glsl_type::dvec4_type), \
1467 _##NAME(int64, glsl_type::int64_t_type), \
1468 _##NAME(int64, glsl_type::i64vec2_type), \
1469 _##NAME(int64, glsl_type::i64vec3_type), \
1470 _##NAME(int64, glsl_type::i64vec4_type), \
1471 _##NAME(int64, glsl_type::uint64_t_type), \
1472 _##NAME(int64, glsl_type::u64vec2_type), \
1473 _##NAME(int64, glsl_type::u64vec3_type), \
1474 _##NAME(int64, glsl_type::u64vec4_type), \
1478 add_function(#NAME, \
1479 _##NAME(glsl_type::int_type), \
1480 _##NAME(glsl_type::ivec2_type), \
1481 _##NAME(glsl_type::ivec3_type), \
1482 _##NAME(glsl_type::ivec4_type), \
1484 _##NAME(glsl_type::uint_type), \
1485 _##NAME(glsl_type::uvec2_type), \
1486 _##NAME(glsl_type::uvec3_type), \
1487 _##NAME(glsl_type::uvec4_type), \
1490 #define FIUBD_VEC(NAME) \
1491 add_function(#NAME, \
1492 _##NAME(always_available, glsl_type::vec2_type), \
1493 _##NAME(always_available, glsl_type::vec3_type), \
1494 _##NAME(always_available, glsl_type::vec4_type), \
1496 _##NAME(always_available, glsl_type::ivec2_type), \
1497 _##NAME(always_available, glsl_type::ivec3_type), \
1498 _##NAME(always_available, glsl_type::ivec4_type), \
1500 _##NAME(v130, glsl_type::uvec2_type), \
1501 _##NAME(v130, glsl_type::uvec3_type), \
1502 _##NAME(v130, glsl_type::uvec4_type), \
1504 _##NAME(always_available, glsl_type::bvec2_type), \
1505 _##NAME(always_available, glsl_type::bvec3_type), \
1506 _##NAME(always_available, glsl_type::bvec4_type), \
1508 _##NAME(fp64, glsl_type::dvec2_type), \
1509 _##NAME(fp64, glsl_type::dvec3_type), \
1510 _##NAME(fp64, glsl_type::dvec4_type), \
1511 _##NAME(int64, glsl_type::int64_t_type), \
1512 _##NAME(int64, glsl_type::i64vec2_type), \
1513 _##NAME(int64, glsl_type::i64vec3_type), \
1514 _##NAME(int64, glsl_type::i64vec4_type), \
1515 _##NAME(int64, glsl_type::uint64_t_type), \
1516 _##NAME(int64, glsl_type::u64vec2_type), \
1517 _##NAME(int64, glsl_type::u64vec3_type), \
1518 _##NAME(int64, glsl_type::u64vec4_type), \
1521 #define FIUD2_MIXED(NAME) \
1522 add_function(#NAME, \
1523 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1524 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1525 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1526 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1528 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1529 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1530 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1532 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1533 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1534 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1535 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1537 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1538 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1539 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1541 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1542 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1543 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1544 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1546 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1547 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1548 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1550 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1551 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1552 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1553 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1554 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1555 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1556 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1558 _##NAME(int64, glsl_type::int64_t_type, glsl_type::int64_t_type), \
1559 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::int64_t_type), \
1560 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::int64_t_type), \
1561 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::int64_t_type), \
1562 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::i64vec2_type), \
1563 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::i64vec3_type), \
1564 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::i64vec4_type), \
1565 _##NAME(int64, glsl_type::uint64_t_type, glsl_type::uint64_t_type), \
1566 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::uint64_t_type), \
1567 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::uint64_t_type), \
1568 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::uint64_t_type), \
1569 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::u64vec2_type), \
1570 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::u64vec3_type), \
1571 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::u64vec4_type), \
1582 add_function("atan",
1583 _atan(glsl_type::float_type
),
1584 _atan(glsl_type::vec2_type
),
1585 _atan(glsl_type::vec3_type
),
1586 _atan(glsl_type::vec4_type
),
1587 _atan2(glsl_type::float_type
),
1588 _atan2(glsl_type::vec2_type
),
1589 _atan2(glsl_type::vec3_type
),
1590 _atan2(glsl_type::vec4_type
),
1616 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1617 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1618 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1619 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1621 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1622 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1623 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1625 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1626 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1627 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1628 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1630 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1631 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1632 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1642 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1643 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1644 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1645 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1647 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1648 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1649 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1651 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1652 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1653 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1654 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1656 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1657 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1658 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1660 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1661 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1662 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1663 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1665 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1666 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1667 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1668 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1670 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1671 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1672 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1673 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1675 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1676 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1677 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1678 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1680 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1681 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1682 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1683 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1685 _mix_sel(int64
, glsl_type::int64_t_type
, glsl_type::bool_type
),
1686 _mix_sel(int64
, glsl_type::i64vec2_type
, glsl_type::bvec2_type
),
1687 _mix_sel(int64
, glsl_type::i64vec3_type
, glsl_type::bvec3_type
),
1688 _mix_sel(int64
, glsl_type::i64vec4_type
, glsl_type::bvec4_type
),
1690 _mix_sel(int64
, glsl_type::uint64_t_type
, glsl_type::bool_type
),
1691 _mix_sel(int64
, glsl_type::u64vec2_type
, glsl_type::bvec2_type
),
1692 _mix_sel(int64
, glsl_type::u64vec3_type
, glsl_type::bvec3_type
),
1693 _mix_sel(int64
, glsl_type::u64vec4_type
, glsl_type::bvec4_type
),
1696 add_function("step",
1697 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1698 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1699 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1700 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1702 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1703 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1704 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1705 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1706 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1707 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1708 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1710 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1711 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1712 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1715 add_function("smoothstep",
1716 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1717 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1718 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1719 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1721 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1722 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1723 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1724 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1725 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1726 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1727 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1729 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1730 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1731 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1739 add_function("intBitsToFloat",
1740 _intBitsToFloat(glsl_type::int_type
),
1741 _intBitsToFloat(glsl_type::ivec2_type
),
1742 _intBitsToFloat(glsl_type::ivec3_type
),
1743 _intBitsToFloat(glsl_type::ivec4_type
),
1745 add_function("uintBitsToFloat",
1746 _uintBitsToFloat(glsl_type::uint_type
),
1747 _uintBitsToFloat(glsl_type::uvec2_type
),
1748 _uintBitsToFloat(glsl_type::uvec3_type
),
1749 _uintBitsToFloat(glsl_type::uvec4_type
),
1752 add_function("doubleBitsToInt64",
1753 _doubleBitsToInt64(int64_fp64
, glsl_type::double_type
),
1754 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec2_type
),
1755 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec3_type
),
1756 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec4_type
),
1759 add_function("doubleBitsToUint64",
1760 _doubleBitsToUint64(int64_fp64
, glsl_type::double_type
),
1761 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec2_type
),
1762 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec3_type
),
1763 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec4_type
),
1766 add_function("int64BitsToDouble",
1767 _int64BitsToDouble(int64_fp64
, glsl_type::int64_t_type
),
1768 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec2_type
),
1769 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec3_type
),
1770 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec4_type
),
1773 add_function("uint64BitsToDouble",
1774 _uint64BitsToDouble(int64_fp64
, glsl_type::uint64_t_type
),
1775 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec2_type
),
1776 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec3_type
),
1777 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec4_type
),
1780 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1781 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1782 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1783 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1784 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1785 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1786 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1787 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1788 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1789 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1790 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1791 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1793 add_function("packInt2x32", _packInt2x32(int64
), NULL
);
1794 add_function("unpackInt2x32", _unpackInt2x32(int64
), NULL
);
1795 add_function("packUint2x32", _packUint2x32(int64
), NULL
);
1796 add_function("unpackUint2x32", _unpackUint2x32(int64
), NULL
);
1802 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1803 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1806 add_function("ftransform", _ftransform(), NULL
);
1811 add_function("matrixCompMult",
1812 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1813 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1814 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1815 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1816 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1817 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1818 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1819 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1820 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1821 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1822 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1823 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1824 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1825 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1826 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1827 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1828 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1829 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1831 add_function("outerProduct",
1832 _outerProduct(v120
, glsl_type::mat2_type
),
1833 _outerProduct(v120
, glsl_type::mat3_type
),
1834 _outerProduct(v120
, glsl_type::mat4_type
),
1835 _outerProduct(v120
, glsl_type::mat2x3_type
),
1836 _outerProduct(v120
, glsl_type::mat2x4_type
),
1837 _outerProduct(v120
, glsl_type::mat3x2_type
),
1838 _outerProduct(v120
, glsl_type::mat3x4_type
),
1839 _outerProduct(v120
, glsl_type::mat4x2_type
),
1840 _outerProduct(v120
, glsl_type::mat4x3_type
),
1841 _outerProduct(fp64
, glsl_type::dmat2_type
),
1842 _outerProduct(fp64
, glsl_type::dmat3_type
),
1843 _outerProduct(fp64
, glsl_type::dmat4_type
),
1844 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1845 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1846 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1847 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1848 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1849 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1851 add_function("determinant",
1852 _determinant_mat2(v120
, glsl_type::mat2_type
),
1853 _determinant_mat3(v120
, glsl_type::mat3_type
),
1854 _determinant_mat4(v120
, glsl_type::mat4_type
),
1855 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1856 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1857 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1860 add_function("inverse",
1861 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1862 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1863 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1864 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1865 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1866 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1868 add_function("transpose",
1869 _transpose(v120
, glsl_type::mat2_type
),
1870 _transpose(v120
, glsl_type::mat3_type
),
1871 _transpose(v120
, glsl_type::mat4_type
),
1872 _transpose(v120
, glsl_type::mat2x3_type
),
1873 _transpose(v120
, glsl_type::mat2x4_type
),
1874 _transpose(v120
, glsl_type::mat3x2_type
),
1875 _transpose(v120
, glsl_type::mat3x4_type
),
1876 _transpose(v120
, glsl_type::mat4x2_type
),
1877 _transpose(v120
, glsl_type::mat4x3_type
),
1878 _transpose(fp64
, glsl_type::dmat2_type
),
1879 _transpose(fp64
, glsl_type::dmat3_type
),
1880 _transpose(fp64
, glsl_type::dmat4_type
),
1881 _transpose(fp64
, glsl_type::dmat2x3_type
),
1882 _transpose(fp64
, glsl_type::dmat2x4_type
),
1883 _transpose(fp64
, glsl_type::dmat3x2_type
),
1884 _transpose(fp64
, glsl_type::dmat3x4_type
),
1885 _transpose(fp64
, glsl_type::dmat4x2_type
),
1886 _transpose(fp64
, glsl_type::dmat4x3_type
),
1889 FIUD_VEC(lessThanEqual
)
1890 FIUD_VEC(greaterThan
)
1891 FIUD_VEC(greaterThanEqual
)
1896 _any(glsl_type::bvec2_type
),
1897 _any(glsl_type::bvec3_type
),
1898 _any(glsl_type::bvec4_type
),
1902 _all(glsl_type::bvec2_type
),
1903 _all(glsl_type::bvec3_type
),
1904 _all(glsl_type::bvec4_type
),
1908 _not(glsl_type::bvec2_type
),
1909 _not(glsl_type::bvec3_type
),
1910 _not(glsl_type::bvec4_type
),
1913 add_function("textureSize",
1914 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1915 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1916 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1918 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1919 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1920 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1922 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1923 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1924 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1926 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1927 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1928 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1930 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1931 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1932 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1934 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1935 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1936 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1937 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1938 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1939 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1941 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1942 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1944 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1945 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1946 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1947 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1949 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1950 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1951 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1952 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1954 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1955 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1956 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1957 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1958 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1959 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1961 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1962 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1963 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1966 add_function("textureSamples",
1967 _textureSamples(shader_samples
, glsl_type::sampler2DMS_type
),
1968 _textureSamples(shader_samples
, glsl_type::isampler2DMS_type
),
1969 _textureSamples(shader_samples
, glsl_type::usampler2DMS_type
),
1971 _textureSamples(shader_samples
, glsl_type::sampler2DMSArray_type
),
1972 _textureSamples(shader_samples
, glsl_type::isampler2DMSArray_type
),
1973 _textureSamples(shader_samples
, glsl_type::usampler2DMSArray_type
),
1976 add_function("texture",
1977 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1978 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1979 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1981 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1982 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1983 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1985 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1986 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1987 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1989 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1990 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1991 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1993 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1994 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1995 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1997 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1998 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1999 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2001 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2002 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2003 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2005 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2006 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2007 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2009 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2010 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2011 /* samplerCubeArrayShadow is special; it has an extra parameter
2012 * for the shadow comparator since there is no vec5 type.
2014 _textureCubeArrayShadow(texture_cube_map_array
, glsl_type::samplerCubeArrayShadow_type
),
2016 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2017 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2018 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2020 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2022 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2024 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2025 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2026 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2028 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2029 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2030 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2032 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2033 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2034 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2036 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2037 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2038 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2040 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2041 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2042 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2044 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2045 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2046 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2048 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2049 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2050 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2052 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2053 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2054 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2056 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2059 add_function("textureLod",
2060 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2061 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2062 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2064 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2065 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2066 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2068 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2069 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2070 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2072 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2073 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2074 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2076 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2077 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2079 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2080 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2081 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2083 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2084 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2085 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2087 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2088 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2089 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2091 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2094 add_function("textureOffset",
2095 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2096 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2097 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2099 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2100 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2101 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2103 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2104 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2105 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2107 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2108 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2109 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2111 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2113 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2114 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2116 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2117 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2118 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2120 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2121 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2122 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2124 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2125 /* The next one was forgotten in GLSL 1.30 spec. It's from
2126 * EXT_gpu_shader4 originally. It was added in 4.30 with the
2127 * wrong syntax. This was corrected in 4.40. 4.30 indicates
2128 * that it was intended to be included previously, so allow it
2131 _texture(ir_tex
, v130_desktop
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2133 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2134 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2135 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2137 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2138 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2139 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2141 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2142 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2143 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2145 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2146 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2148 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2149 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2150 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2152 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2153 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2154 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2156 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2159 add_function("textureProj",
2160 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2161 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2162 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2163 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2164 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2165 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2167 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2168 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2169 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2170 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2171 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2172 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2174 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2175 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2176 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2178 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2179 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2181 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2182 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2183 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2184 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2186 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2187 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2188 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2189 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2191 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2193 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2194 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2195 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2196 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2197 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2198 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2200 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2201 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2202 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2203 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2204 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2205 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2207 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2208 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2209 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2211 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2212 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2215 add_function("texelFetch",
2216 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
2217 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
2218 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
2220 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
2221 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
2222 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
2224 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
2225 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
2226 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
2228 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
2229 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
2230 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
2232 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
2233 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
2234 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
2236 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
2237 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
2238 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
2240 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
2241 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
2242 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
2244 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2245 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2246 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2248 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2249 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2250 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2252 _texelFetch(texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::ivec2_type
),
2257 add_function("texelFetchOffset",
2258 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2259 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2260 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2262 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2263 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2264 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2266 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2267 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2268 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2270 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2271 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2272 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2274 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2275 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2276 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2278 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2279 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2280 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2284 add_function("textureProjOffset",
2285 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2286 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2287 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2288 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2289 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2290 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2292 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2293 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2294 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2295 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2296 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2297 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2299 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2300 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2301 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2303 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2304 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2306 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2307 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2308 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2309 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2310 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2311 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2313 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2315 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2316 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2317 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2318 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2319 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2320 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2322 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2323 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2324 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2325 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2326 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2327 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2329 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2330 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2331 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2333 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2334 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2337 add_function("textureLodOffset",
2338 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2339 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2340 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2342 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2343 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2344 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2346 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2347 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2348 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2350 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2351 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2353 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2354 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2355 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2357 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2358 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2359 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2361 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2364 add_function("textureProjLod",
2365 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2366 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2367 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2368 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2369 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2370 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2372 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2373 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2374 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2375 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2376 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2377 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2379 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2380 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2381 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2383 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2384 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2387 add_function("textureProjLodOffset",
2388 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2389 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2390 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2391 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2392 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2393 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2395 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2396 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2397 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2398 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2399 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2400 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2402 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2403 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2404 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2406 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2407 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2410 add_function("textureGrad",
2411 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2412 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2413 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2415 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2416 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2417 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2419 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2420 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2421 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2423 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2424 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2425 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2427 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2428 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2429 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2431 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2433 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2434 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2435 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2437 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2438 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2439 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2441 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2442 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2443 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2445 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2446 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2447 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2449 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2450 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2453 add_function("textureGradOffset",
2454 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2455 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2456 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2458 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2459 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2460 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2462 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2463 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2464 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2466 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2467 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2468 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2470 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2472 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2473 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2475 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2476 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2477 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2479 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2480 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2481 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2483 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2484 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2487 add_function("textureProjGrad",
2488 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2489 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2490 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2491 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2492 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2493 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2495 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2496 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2497 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2498 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2499 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2500 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2502 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2503 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2504 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2506 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2507 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2508 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2509 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2510 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2511 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2513 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2515 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2516 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2519 add_function("textureProjGradOffset",
2520 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2521 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2522 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2523 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2524 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2525 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2527 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2528 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2529 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2530 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2531 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2532 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2534 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2535 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2536 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2538 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2539 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2540 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2541 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2542 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2543 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2545 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2547 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2548 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2551 add_function("EmitVertex", _EmitVertex(), NULL
);
2552 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2553 add_function("EmitStreamVertex",
2554 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2555 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2557 add_function("EndStreamPrimitive",
2558 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2559 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2561 add_function("barrier", _barrier(), NULL
);
2563 add_function("textureQueryLOD",
2564 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2565 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2566 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2568 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2569 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2570 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2572 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2573 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2574 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2576 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2577 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2578 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2580 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2581 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2582 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2584 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2585 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2586 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2588 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2589 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2590 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2592 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2593 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2594 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2595 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2596 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2597 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2600 add_function("textureQueryLod",
2601 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2602 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2603 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2605 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2606 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2607 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2609 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2610 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2611 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2613 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2614 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2615 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2617 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2618 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2619 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2621 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2622 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2623 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2625 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2626 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2627 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2629 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2630 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2631 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2632 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2633 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2634 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2637 add_function("textureQueryLevels",
2638 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1D_type
),
2639 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2D_type
),
2640 _textureQueryLevels(texture_query_levels
, glsl_type::sampler3D_type
),
2641 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCube_type
),
2642 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArray_type
),
2643 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArray_type
),
2644 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArray_type
),
2645 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DShadow_type
),
2646 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DShadow_type
),
2647 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeShadow_type
),
2648 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArrayShadow_type
),
2649 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArrayShadow_type
),
2650 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArrayShadow_type
),
2652 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1D_type
),
2653 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2D_type
),
2654 _textureQueryLevels(texture_query_levels
, glsl_type::isampler3D_type
),
2655 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCube_type
),
2656 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1DArray_type
),
2657 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2DArray_type
),
2658 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCubeArray_type
),
2660 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1D_type
),
2661 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2D_type
),
2662 _textureQueryLevels(texture_query_levels
, glsl_type::usampler3D_type
),
2663 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCube_type
),
2664 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1DArray_type
),
2665 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2DArray_type
),
2666 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCubeArray_type
),
2670 add_function("textureSamplesIdenticalEXT",
2671 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2672 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2673 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2675 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2676 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2677 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2680 add_function("texture1D",
2681 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2682 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2685 add_function("texture1DArray",
2686 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2687 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2690 add_function("texture1DProj",
2691 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2692 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2693 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2694 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2697 add_function("texture1DLod",
2698 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2701 add_function("texture1DArrayLod",
2702 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2705 add_function("texture1DProjLod",
2706 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2707 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2710 add_function("texture2D",
2711 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2712 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2713 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2716 add_function("texture2DArray",
2717 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2718 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2721 add_function("texture2DProj",
2722 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2723 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2724 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2725 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2726 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2727 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2730 add_function("texture2DLod",
2731 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2734 add_function("texture2DArrayLod",
2735 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2738 add_function("texture2DProjLod",
2739 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2740 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2743 add_function("texture3D",
2744 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2745 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2748 add_function("texture3DProj",
2749 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2750 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2753 add_function("texture3DLod",
2754 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2757 add_function("texture3DProjLod",
2758 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2761 add_function("textureCube",
2762 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2763 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2766 add_function("textureCubeLod",
2767 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2770 add_function("texture2DRect",
2771 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2774 add_function("texture2DRectProj",
2775 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2776 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2779 add_function("shadow1D",
2780 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2781 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2784 add_function("shadow1DArray",
2785 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2786 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2789 add_function("shadow2D",
2790 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2791 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2794 add_function("shadow2DArray",
2795 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2796 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2799 add_function("shadow1DProj",
2800 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2801 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2804 add_function("shadow2DProj",
2805 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2806 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2809 add_function("shadow1DLod",
2810 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2813 add_function("shadow2DLod",
2814 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2817 add_function("shadow1DArrayLod",
2818 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2821 add_function("shadow1DProjLod",
2822 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2825 add_function("shadow2DProjLod",
2826 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2829 add_function("shadow2DRect",
2830 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2833 add_function("shadow2DRectProj",
2834 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2837 add_function("texture1DGradARB",
2838 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2841 add_function("texture1DProjGradARB",
2842 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2843 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2846 add_function("texture2DGradARB",
2847 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2850 add_function("texture2DProjGradARB",
2851 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2852 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2855 add_function("texture3DGradARB",
2856 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2859 add_function("texture3DProjGradARB",
2860 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2863 add_function("textureCubeGradARB",
2864 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2867 add_function("shadow1DGradARB",
2868 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2871 add_function("shadow1DProjGradARB",
2872 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2875 add_function("shadow2DGradARB",
2876 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2879 add_function("shadow2DProjGradARB",
2880 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2883 add_function("texture2DRectGradARB",
2884 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2887 add_function("texture2DRectProjGradARB",
2888 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2889 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2892 add_function("shadow2DRectGradARB",
2893 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2896 add_function("shadow2DRectProjGradARB",
2897 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2900 add_function("texture4",
2901 _texture(ir_tg4
, texture_texture4
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2904 add_function("textureGather",
2905 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2906 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2907 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2909 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2910 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2911 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2913 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2914 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2915 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2917 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2918 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2919 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2921 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2922 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2923 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2925 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2926 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2927 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2929 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2930 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2931 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2933 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2934 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2935 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2937 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2938 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2939 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2941 _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
),
2942 _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
),
2943 _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
),
2945 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2946 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2947 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2948 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2949 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2952 add_function("textureGatherOffset",
2953 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2954 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2955 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2957 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2958 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2959 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2961 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2962 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2963 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2965 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2966 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2967 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2969 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2970 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2971 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2973 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2974 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2975 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2977 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2978 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2979 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2981 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2982 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2983 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2985 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2986 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2987 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2989 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2990 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2991 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2993 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2994 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2995 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2997 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2998 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
3001 add_function("textureGatherOffsets",
3002 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3003 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3004 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3006 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3007 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3008 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3010 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3011 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3012 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3014 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3015 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3016 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3018 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3019 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3020 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3022 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3023 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3024 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3026 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3027 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3028 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3053 add_function("ldexp",
3054 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
3055 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
3056 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
3057 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
3058 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
3059 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
3060 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
3061 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
3064 add_function("frexp",
3065 _frexp(glsl_type::float_type
, glsl_type::int_type
),
3066 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
3067 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
3068 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
3069 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
3070 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
3071 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
3072 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
3074 add_function("uaddCarry",
3075 _uaddCarry(glsl_type::uint_type
),
3076 _uaddCarry(glsl_type::uvec2_type
),
3077 _uaddCarry(glsl_type::uvec3_type
),
3078 _uaddCarry(glsl_type::uvec4_type
),
3080 add_function("usubBorrow",
3081 _usubBorrow(glsl_type::uint_type
),
3082 _usubBorrow(glsl_type::uvec2_type
),
3083 _usubBorrow(glsl_type::uvec3_type
),
3084 _usubBorrow(glsl_type::uvec4_type
),
3086 add_function("imulExtended",
3087 _mulExtended(glsl_type::int_type
),
3088 _mulExtended(glsl_type::ivec2_type
),
3089 _mulExtended(glsl_type::ivec3_type
),
3090 _mulExtended(glsl_type::ivec4_type
),
3092 add_function("umulExtended",
3093 _mulExtended(glsl_type::uint_type
),
3094 _mulExtended(glsl_type::uvec2_type
),
3095 _mulExtended(glsl_type::uvec3_type
),
3096 _mulExtended(glsl_type::uvec4_type
),
3098 add_function("interpolateAtCentroid",
3099 _interpolateAtCentroid(glsl_type::float_type
),
3100 _interpolateAtCentroid(glsl_type::vec2_type
),
3101 _interpolateAtCentroid(glsl_type::vec3_type
),
3102 _interpolateAtCentroid(glsl_type::vec4_type
),
3104 add_function("interpolateAtOffset",
3105 _interpolateAtOffset(glsl_type::float_type
),
3106 _interpolateAtOffset(glsl_type::vec2_type
),
3107 _interpolateAtOffset(glsl_type::vec3_type
),
3108 _interpolateAtOffset(glsl_type::vec4_type
),
3110 add_function("interpolateAtSample",
3111 _interpolateAtSample(glsl_type::float_type
),
3112 _interpolateAtSample(glsl_type::vec2_type
),
3113 _interpolateAtSample(glsl_type::vec3_type
),
3114 _interpolateAtSample(glsl_type::vec4_type
),
3117 add_function("atomicCounter",
3118 _atomic_counter_op("__intrinsic_atomic_read",
3119 shader_atomic_counters
),
3121 add_function("atomicCounterIncrement",
3122 _atomic_counter_op("__intrinsic_atomic_increment",
3123 shader_atomic_counters
),
3125 add_function("atomicCounterDecrement",
3126 _atomic_counter_op("__intrinsic_atomic_predecrement",
3127 shader_atomic_counters
),
3130 add_function("atomicCounterAddARB",
3131 _atomic_counter_op1("__intrinsic_atomic_add",
3132 shader_atomic_counter_ops
),
3134 add_function("atomicCounterSubtractARB",
3135 _atomic_counter_op1("__intrinsic_atomic_sub",
3136 shader_atomic_counter_ops
),
3138 add_function("atomicCounterMinARB",
3139 _atomic_counter_op1("__intrinsic_atomic_min",
3140 shader_atomic_counter_ops
),
3142 add_function("atomicCounterMaxARB",
3143 _atomic_counter_op1("__intrinsic_atomic_max",
3144 shader_atomic_counter_ops
),
3146 add_function("atomicCounterAndARB",
3147 _atomic_counter_op1("__intrinsic_atomic_and",
3148 shader_atomic_counter_ops
),
3150 add_function("atomicCounterOrARB",
3151 _atomic_counter_op1("__intrinsic_atomic_or",
3152 shader_atomic_counter_ops
),
3154 add_function("atomicCounterXorARB",
3155 _atomic_counter_op1("__intrinsic_atomic_xor",
3156 shader_atomic_counter_ops
),
3158 add_function("atomicCounterExchangeARB",
3159 _atomic_counter_op1("__intrinsic_atomic_exchange",
3160 shader_atomic_counter_ops
),
3162 add_function("atomicCounterCompSwapARB",
3163 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3164 shader_atomic_counter_ops
),
3167 add_function("atomicCounterAdd",
3168 _atomic_counter_op1("__intrinsic_atomic_add",
3171 add_function("atomicCounterSubtract",
3172 _atomic_counter_op1("__intrinsic_atomic_sub",
3175 add_function("atomicCounterMin",
3176 _atomic_counter_op1("__intrinsic_atomic_min",
3179 add_function("atomicCounterMax",
3180 _atomic_counter_op1("__intrinsic_atomic_max",
3183 add_function("atomicCounterAnd",
3184 _atomic_counter_op1("__intrinsic_atomic_and",
3187 add_function("atomicCounterOr",
3188 _atomic_counter_op1("__intrinsic_atomic_or",
3191 add_function("atomicCounterXor",
3192 _atomic_counter_op1("__intrinsic_atomic_xor",
3195 add_function("atomicCounterExchange",
3196 _atomic_counter_op1("__intrinsic_atomic_exchange",
3199 add_function("atomicCounterCompSwap",
3200 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3204 add_function("atomicAdd",
3205 _atomic_op2("__intrinsic_atomic_add",
3206 buffer_atomics_supported
,
3207 glsl_type::uint_type
),
3208 _atomic_op2("__intrinsic_atomic_add",
3209 buffer_atomics_supported
,
3210 glsl_type::int_type
),
3211 _atomic_op2("__intrinsic_atomic_add",
3212 shader_atomic_float_add
,
3213 glsl_type::float_type
),
3215 add_function("atomicMin",
3216 _atomic_op2("__intrinsic_atomic_min",
3217 buffer_atomics_supported
,
3218 glsl_type::uint_type
),
3219 _atomic_op2("__intrinsic_atomic_min",
3220 buffer_atomics_supported
,
3221 glsl_type::int_type
),
3222 _atomic_op2("__intrinsic_atomic_min",
3223 shader_atomic_float_minmax
,
3224 glsl_type::float_type
),
3226 add_function("atomicMax",
3227 _atomic_op2("__intrinsic_atomic_max",
3228 buffer_atomics_supported
,
3229 glsl_type::uint_type
),
3230 _atomic_op2("__intrinsic_atomic_max",
3231 buffer_atomics_supported
,
3232 glsl_type::int_type
),
3233 _atomic_op2("__intrinsic_atomic_max",
3234 shader_atomic_float_minmax
,
3235 glsl_type::float_type
),
3237 add_function("atomicAnd",
3238 _atomic_op2("__intrinsic_atomic_and",
3239 buffer_atomics_supported
,
3240 glsl_type::uint_type
),
3241 _atomic_op2("__intrinsic_atomic_and",
3242 buffer_atomics_supported
,
3243 glsl_type::int_type
),
3245 add_function("atomicOr",
3246 _atomic_op2("__intrinsic_atomic_or",
3247 buffer_atomics_supported
,
3248 glsl_type::uint_type
),
3249 _atomic_op2("__intrinsic_atomic_or",
3250 buffer_atomics_supported
,
3251 glsl_type::int_type
),
3253 add_function("atomicXor",
3254 _atomic_op2("__intrinsic_atomic_xor",
3255 buffer_atomics_supported
,
3256 glsl_type::uint_type
),
3257 _atomic_op2("__intrinsic_atomic_xor",
3258 buffer_atomics_supported
,
3259 glsl_type::int_type
),
3261 add_function("atomicExchange",
3262 _atomic_op2("__intrinsic_atomic_exchange",
3263 buffer_atomics_supported
,
3264 glsl_type::uint_type
),
3265 _atomic_op2("__intrinsic_atomic_exchange",
3266 buffer_atomics_supported
,
3267 glsl_type::int_type
),
3268 _atomic_op2("__intrinsic_atomic_exchange",
3269 shader_atomic_float_exchange
,
3270 glsl_type::float_type
),
3272 add_function("atomicCompSwap",
3273 _atomic_op3("__intrinsic_atomic_comp_swap",
3274 buffer_atomics_supported
,
3275 glsl_type::uint_type
),
3276 _atomic_op3("__intrinsic_atomic_comp_swap",
3277 buffer_atomics_supported
,
3278 glsl_type::int_type
),
3279 _atomic_op3("__intrinsic_atomic_comp_swap",
3280 shader_atomic_float_minmax
,
3281 glsl_type::float_type
),
3284 add_function("min3",
3285 _min3(glsl_type::float_type
),
3286 _min3(glsl_type::vec2_type
),
3287 _min3(glsl_type::vec3_type
),
3288 _min3(glsl_type::vec4_type
),
3290 _min3(glsl_type::int_type
),
3291 _min3(glsl_type::ivec2_type
),
3292 _min3(glsl_type::ivec3_type
),
3293 _min3(glsl_type::ivec4_type
),
3295 _min3(glsl_type::uint_type
),
3296 _min3(glsl_type::uvec2_type
),
3297 _min3(glsl_type::uvec3_type
),
3298 _min3(glsl_type::uvec4_type
),
3301 add_function("max3",
3302 _max3(glsl_type::float_type
),
3303 _max3(glsl_type::vec2_type
),
3304 _max3(glsl_type::vec3_type
),
3305 _max3(glsl_type::vec4_type
),
3307 _max3(glsl_type::int_type
),
3308 _max3(glsl_type::ivec2_type
),
3309 _max3(glsl_type::ivec3_type
),
3310 _max3(glsl_type::ivec4_type
),
3312 _max3(glsl_type::uint_type
),
3313 _max3(glsl_type::uvec2_type
),
3314 _max3(glsl_type::uvec3_type
),
3315 _max3(glsl_type::uvec4_type
),
3318 add_function("mid3",
3319 _mid3(glsl_type::float_type
),
3320 _mid3(glsl_type::vec2_type
),
3321 _mid3(glsl_type::vec3_type
),
3322 _mid3(glsl_type::vec4_type
),
3324 _mid3(glsl_type::int_type
),
3325 _mid3(glsl_type::ivec2_type
),
3326 _mid3(glsl_type::ivec3_type
),
3327 _mid3(glsl_type::ivec4_type
),
3329 _mid3(glsl_type::uint_type
),
3330 _mid3(glsl_type::uvec2_type
),
3331 _mid3(glsl_type::uvec3_type
),
3332 _mid3(glsl_type::uvec4_type
),
3335 add_image_functions(true);
3337 add_function("memoryBarrier",
3338 _memory_barrier("__intrinsic_memory_barrier",
3339 shader_image_load_store
),
3341 add_function("groupMemoryBarrier",
3342 _memory_barrier("__intrinsic_group_memory_barrier",
3345 add_function("memoryBarrierAtomicCounter",
3346 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
3347 compute_shader_supported
),
3349 add_function("memoryBarrierBuffer",
3350 _memory_barrier("__intrinsic_memory_barrier_buffer",
3351 compute_shader_supported
),
3353 add_function("memoryBarrierImage",
3354 _memory_barrier("__intrinsic_memory_barrier_image",
3355 compute_shader_supported
),
3357 add_function("memoryBarrierShared",
3358 _memory_barrier("__intrinsic_memory_barrier_shared",
3362 add_function("ballotARB", _ballot(), NULL
);
3364 add_function("readInvocationARB",
3365 _read_invocation(glsl_type::float_type
),
3366 _read_invocation(glsl_type::vec2_type
),
3367 _read_invocation(glsl_type::vec3_type
),
3368 _read_invocation(glsl_type::vec4_type
),
3370 _read_invocation(glsl_type::int_type
),
3371 _read_invocation(glsl_type::ivec2_type
),
3372 _read_invocation(glsl_type::ivec3_type
),
3373 _read_invocation(glsl_type::ivec4_type
),
3375 _read_invocation(glsl_type::uint_type
),
3376 _read_invocation(glsl_type::uvec2_type
),
3377 _read_invocation(glsl_type::uvec3_type
),
3378 _read_invocation(glsl_type::uvec4_type
),
3381 add_function("readFirstInvocationARB",
3382 _read_first_invocation(glsl_type::float_type
),
3383 _read_first_invocation(glsl_type::vec2_type
),
3384 _read_first_invocation(glsl_type::vec3_type
),
3385 _read_first_invocation(glsl_type::vec4_type
),
3387 _read_first_invocation(glsl_type::int_type
),
3388 _read_first_invocation(glsl_type::ivec2_type
),
3389 _read_first_invocation(glsl_type::ivec3_type
),
3390 _read_first_invocation(glsl_type::ivec4_type
),
3392 _read_first_invocation(glsl_type::uint_type
),
3393 _read_first_invocation(glsl_type::uvec2_type
),
3394 _read_first_invocation(glsl_type::uvec3_type
),
3395 _read_first_invocation(glsl_type::uvec4_type
),
3398 add_function("clock2x32ARB",
3399 _shader_clock(shader_clock
,
3400 glsl_type::uvec2_type
),
3403 add_function("clockARB",
3404 _shader_clock(shader_clock_int64
,
3405 glsl_type::uint64_t_type
),
3408 add_function("beginInvocationInterlockARB",
3409 _invocation_interlock(
3410 "__intrinsic_begin_invocation_interlock",
3411 supports_arb_fragment_shader_interlock
),
3414 add_function("endInvocationInterlockARB",
3415 _invocation_interlock(
3416 "__intrinsic_end_invocation_interlock",
3417 supports_arb_fragment_shader_interlock
),
3420 add_function("beginInvocationInterlockNV",
3421 _invocation_interlock(
3422 "__intrinsic_begin_invocation_interlock",
3423 supports_nv_fragment_shader_interlock
),
3426 add_function("endInvocationInterlockNV",
3427 _invocation_interlock(
3428 "__intrinsic_end_invocation_interlock",
3429 supports_nv_fragment_shader_interlock
),
3432 add_function("anyInvocationARB",
3433 _vote("__intrinsic_vote_any", vote
),
3436 add_function("allInvocationsARB",
3437 _vote("__intrinsic_vote_all", vote
),
3440 add_function("allInvocationsEqualARB",
3441 _vote("__intrinsic_vote_eq", vote
),
3444 add_function("anyInvocation",
3445 _vote("__intrinsic_vote_any", v460_desktop
),
3448 add_function("allInvocations",
3449 _vote("__intrinsic_vote_all", v460_desktop
),
3452 add_function("allInvocationsEqual",
3453 _vote("__intrinsic_vote_eq", v460_desktop
),
3456 add_function("__builtin_idiv64",
3457 generate_ir::idiv64(mem_ctx
, integer_functions_supported
),
3460 add_function("__builtin_imod64",
3461 generate_ir::imod64(mem_ctx
, integer_functions_supported
),
3464 add_function("__builtin_sign64",
3465 generate_ir::sign64(mem_ctx
, integer_functions_supported
),
3468 add_function("__builtin_udiv64",
3469 generate_ir::udiv64(mem_ctx
, integer_functions_supported
),
3472 add_function("__builtin_umod64",
3473 generate_ir::umod64(mem_ctx
, integer_functions_supported
),
3476 add_function("__builtin_umul64",
3477 generate_ir::umul64(mem_ctx
, integer_functions_supported
),
3488 builtin_builder::add_function(const char *name
, ...)
3492 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3496 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
3502 stuff
.push_tail(sig
);
3503 validate_ir_tree(&stuff
);
3506 f
->add_signature(sig
);
3510 shader
->symbols
->add_function(f
);
3514 builtin_builder::add_image_function(const char *name
,
3515 const char *intrinsic_name
,
3516 image_prototype_ctr prototype
,
3517 unsigned num_arguments
,
3519 enum ir_intrinsic_id intrinsic_id
)
3521 static const glsl_type
*const types
[] = {
3522 glsl_type::image1D_type
,
3523 glsl_type::image2D_type
,
3524 glsl_type::image3D_type
,
3525 glsl_type::image2DRect_type
,
3526 glsl_type::imageCube_type
,
3527 glsl_type::imageBuffer_type
,
3528 glsl_type::image1DArray_type
,
3529 glsl_type::image2DArray_type
,
3530 glsl_type::imageCubeArray_type
,
3531 glsl_type::image2DMS_type
,
3532 glsl_type::image2DMSArray_type
,
3533 glsl_type::iimage1D_type
,
3534 glsl_type::iimage2D_type
,
3535 glsl_type::iimage3D_type
,
3536 glsl_type::iimage2DRect_type
,
3537 glsl_type::iimageCube_type
,
3538 glsl_type::iimageBuffer_type
,
3539 glsl_type::iimage1DArray_type
,
3540 glsl_type::iimage2DArray_type
,
3541 glsl_type::iimageCubeArray_type
,
3542 glsl_type::iimage2DMS_type
,
3543 glsl_type::iimage2DMSArray_type
,
3544 glsl_type::uimage1D_type
,
3545 glsl_type::uimage2D_type
,
3546 glsl_type::uimage3D_type
,
3547 glsl_type::uimage2DRect_type
,
3548 glsl_type::uimageCube_type
,
3549 glsl_type::uimageBuffer_type
,
3550 glsl_type::uimage1DArray_type
,
3551 glsl_type::uimage2DArray_type
,
3552 glsl_type::uimageCubeArray_type
,
3553 glsl_type::uimage2DMS_type
,
3554 glsl_type::uimage2DMSArray_type
3557 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3559 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3560 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3561 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3562 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3563 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3564 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3565 num_arguments
, flags
, intrinsic_id
));
3568 shader
->symbols
->add_function(f
);
3572 builtin_builder::add_image_functions(bool glsl
)
3574 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3576 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3577 "__intrinsic_image_load",
3578 &builtin_builder::_image_prototype
, 0,
3579 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3580 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3581 IMAGE_FUNCTION_READ_ONLY
),
3582 ir_intrinsic_image_load
);
3584 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3585 "__intrinsic_image_store",
3586 &builtin_builder::_image_prototype
, 1,
3587 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3588 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3589 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3590 IMAGE_FUNCTION_WRITE_ONLY
),
3591 ir_intrinsic_image_store
);
3593 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3595 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3596 "__intrinsic_image_atomic_add",
3597 &builtin_builder::_image_prototype
, 1,
3598 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
|
3599 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3600 ir_intrinsic_image_atomic_add
);
3602 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3603 "__intrinsic_image_atomic_min",
3604 &builtin_builder::_image_prototype
, 1, atom_flags
,
3605 ir_intrinsic_image_atomic_min
);
3607 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3608 "__intrinsic_image_atomic_max",
3609 &builtin_builder::_image_prototype
, 1, atom_flags
,
3610 ir_intrinsic_image_atomic_max
);
3612 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3613 "__intrinsic_image_atomic_and",
3614 &builtin_builder::_image_prototype
, 1, atom_flags
,
3615 ir_intrinsic_image_atomic_and
);
3617 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3618 "__intrinsic_image_atomic_or",
3619 &builtin_builder::_image_prototype
, 1, atom_flags
,
3620 ir_intrinsic_image_atomic_or
);
3622 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3623 "__intrinsic_image_atomic_xor",
3624 &builtin_builder::_image_prototype
, 1, atom_flags
,
3625 ir_intrinsic_image_atomic_xor
);
3627 add_image_function((glsl
? "imageAtomicExchange" :
3628 "__intrinsic_image_atomic_exchange"),
3629 "__intrinsic_image_atomic_exchange",
3630 &builtin_builder::_image_prototype
, 1,
3631 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3632 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3633 ir_intrinsic_image_atomic_exchange
);
3635 add_image_function((glsl
? "imageAtomicCompSwap" :
3636 "__intrinsic_image_atomic_comp_swap"),
3637 "__intrinsic_image_atomic_comp_swap",
3638 &builtin_builder::_image_prototype
, 2, atom_flags
,
3639 ir_intrinsic_image_atomic_comp_swap
);
3641 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3642 "__intrinsic_image_size",
3643 &builtin_builder::_image_size_prototype
, 1,
3644 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
,
3645 ir_intrinsic_image_size
);
3647 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3648 "__intrinsic_image_samples",
3649 &builtin_builder::_image_samples_prototype
, 1,
3650 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3651 IMAGE_FUNCTION_MS_ONLY
,
3652 ir_intrinsic_image_samples
);
3656 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3658 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3662 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3664 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3668 builtin_builder::imm(bool b
, unsigned vector_elements
)
3670 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3674 builtin_builder::imm(float f
, unsigned vector_elements
)
3676 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3680 builtin_builder::imm(int i
, unsigned vector_elements
)
3682 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3686 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3688 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3692 builtin_builder::imm(double d
, unsigned vector_elements
)
3694 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3698 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3700 return new(mem_ctx
) ir_constant(type
, &data
);
3703 #define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)
3705 ir_dereference_variable
*
3706 builtin_builder::var_ref(ir_variable
*var
)
3708 return new(mem_ctx
) ir_dereference_variable(var
);
3711 ir_dereference_array
*
3712 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3714 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3717 /** Return an element of a matrix */
3719 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3721 return swizzle(array_ref(var
, column
), row
, 1);
3725 * Implementations of built-in functions:
3728 ir_function_signature
*
3729 builtin_builder::new_sig(const glsl_type
*return_type
,
3730 builtin_available_predicate avail
,
3736 ir_function_signature
*sig
=
3737 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3740 va_start(ap
, num_params
);
3741 for (int i
= 0; i
< num_params
; i
++) {
3742 plist
.push_tail(va_arg(ap
, ir_variable
*));
3746 sig
->replace_parameters(&plist
);
3750 #define MAKE_SIG(return_type, avail, ...) \
3751 ir_function_signature *sig = \
3752 new_sig(return_type, avail, __VA_ARGS__); \
3753 ir_factory body(&sig->body, mem_ctx); \
3754 sig->is_defined = true;
3756 #define MAKE_INTRINSIC(return_type, id, avail, ...) \
3757 ir_function_signature *sig = \
3758 new_sig(return_type, avail, __VA_ARGS__); \
3759 sig->intrinsic_id = id;
3761 ir_function_signature
*
3762 builtin_builder::unop(builtin_available_predicate avail
,
3763 ir_expression_operation opcode
,
3764 const glsl_type
*return_type
,
3765 const glsl_type
*param_type
)
3767 ir_variable
*x
= in_var(param_type
, "x");
3768 MAKE_SIG(return_type
, avail
, 1, x
);
3769 body
.emit(ret(expr(opcode
, x
)));
3773 #define UNOP(NAME, OPCODE, AVAIL) \
3774 ir_function_signature * \
3775 builtin_builder::_##NAME(const glsl_type *type) \
3777 return unop(&AVAIL, OPCODE, type, type); \
3780 #define UNOPA(NAME, OPCODE) \
3781 ir_function_signature * \
3782 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3784 return unop(avail, OPCODE, type, type); \
3787 ir_function_signature
*
3788 builtin_builder::binop(builtin_available_predicate avail
,
3789 ir_expression_operation opcode
,
3790 const glsl_type
*return_type
,
3791 const glsl_type
*param0_type
,
3792 const glsl_type
*param1_type
,
3795 ir_variable
*x
= in_var(param0_type
, "x");
3796 ir_variable
*y
= in_var(param1_type
, "y");
3797 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3800 body
.emit(ret(expr(opcode
, y
, x
)));
3802 body
.emit(ret(expr(opcode
, x
, y
)));
3807 #define BINOP(NAME, OPCODE, AVAIL) \
3808 ir_function_signature * \
3809 builtin_builder::_##NAME(const glsl_type *return_type, \
3810 const glsl_type *param0_type, \
3811 const glsl_type *param1_type) \
3813 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3817 * Angle and Trigonometry Functions @{
3820 ir_function_signature
*
3821 builtin_builder::_radians(const glsl_type
*type
)
3823 ir_variable
*degrees
= in_var(type
, "degrees");
3824 MAKE_SIG(type
, always_available
, 1, degrees
);
3825 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3829 ir_function_signature
*
3830 builtin_builder::_degrees(const glsl_type
*type
)
3832 ir_variable
*radians
= in_var(type
, "radians");
3833 MAKE_SIG(type
, always_available
, 1, radians
);
3834 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3838 UNOP(sin
, ir_unop_sin
, always_available
)
3839 UNOP(cos
, ir_unop_cos
, always_available
)
3841 ir_function_signature
*
3842 builtin_builder::_tan(const glsl_type
*type
)
3844 ir_variable
*theta
= in_var(type
, "theta");
3845 MAKE_SIG(type
, always_available
, 1, theta
);
3846 body
.emit(ret(div(sin(theta
), cos(theta
))));
3851 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3855 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3858 add(imm(M_PI_4f
- 1.0f
),
3861 mul(abs(x
), imm(p1
))))))))));
3865 * Generate a ir_call to a function with a set of parameters
3867 * The input \c params can either be a list of \c ir_variable or a list of
3868 * \c ir_dereference_variable. In the latter case, all nodes will be removed
3869 * from \c params and used directly as the parameters to the generated
3873 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3875 exec_list actual_params
;
3877 foreach_in_list_safe(ir_instruction
, ir
, ¶ms
) {
3878 ir_dereference_variable
*d
= ir
->as_dereference_variable();
3881 actual_params
.push_tail(d
);
3883 ir_variable
*var
= ir
->as_variable();
3884 assert(var
!= NULL
);
3885 actual_params
.push_tail(var_ref(var
));
3889 ir_function_signature
*sig
=
3890 f
->exact_matching_signature(NULL
, &actual_params
);
3894 ir_dereference_variable
*deref
=
3895 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3897 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3900 ir_function_signature
*
3901 builtin_builder::_asin(const glsl_type
*type
)
3903 ir_variable
*x
= in_var(type
, "x");
3904 MAKE_SIG(type
, always_available
, 1, x
);
3906 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3911 ir_function_signature
*
3912 builtin_builder::_acos(const glsl_type
*type
)
3914 ir_variable
*x
= in_var(type
, "x");
3915 MAKE_SIG(type
, always_available
, 1, x
);
3917 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3922 ir_function_signature
*
3923 builtin_builder::_atan2(const glsl_type
*type
)
3925 const unsigned n
= type
->vector_elements
;
3926 ir_variable
*y
= in_var(type
, "y");
3927 ir_variable
*x
= in_var(type
, "x");
3928 MAKE_SIG(type
, always_available
, 2, y
, x
);
3930 /* If we're on the left half-plane rotate the coordinates π/2 clock-wise
3931 * for the y=0 discontinuity to end up aligned with the vertical
3932 * discontinuity of atan(s/t) along t=0. This also makes sure that we
3933 * don't attempt to divide by zero along the vertical line, which may give
3934 * unspecified results on non-GLSL 4.1-capable hardware.
3936 ir_variable
*flip
= body
.make_temp(glsl_type::bvec(n
), "flip");
3937 body
.emit(assign(flip
, gequal(imm(0.0f
, n
), x
)));
3938 ir_variable
*s
= body
.make_temp(type
, "s");
3939 body
.emit(assign(s
, csel(flip
, abs(x
), y
)));
3940 ir_variable
*t
= body
.make_temp(type
, "t");
3941 body
.emit(assign(t
, csel(flip
, y
, abs(x
))));
3943 /* If the magnitude of the denominator exceeds some huge value, scale down
3944 * the arguments in order to prevent the reciprocal operation from flushing
3945 * its result to zero, which would cause precision problems, and for s
3946 * infinite would cause us to return a NaN instead of the correct finite
3949 * If fmin and fmax are respectively the smallest and largest positive
3950 * normalized floating point values representable by the implementation,
3951 * the constants below should be in agreement with:
3954 * scale <= 1 / fmin / fmax (for |t| >= huge)
3956 * In addition scale should be a negative power of two in order to avoid
3957 * loss of precision. The values chosen below should work for most usual
3958 * floating point representations with at least the dynamic range of ATI's
3959 * 24-bit representation.
3961 ir_constant
*huge
= imm(1e18f
, n
);
3962 ir_variable
*scale
= body
.make_temp(type
, "scale");
3963 body
.emit(assign(scale
, csel(gequal(abs(t
), huge
),
3964 imm(0.25f
, n
), imm(1.0f
, n
))));
3965 ir_variable
*rcp_scaled_t
= body
.make_temp(type
, "rcp_scaled_t");
3966 body
.emit(assign(rcp_scaled_t
, rcp(mul(t
, scale
))));
3967 ir_expression
*s_over_t
= mul(mul(s
, scale
), rcp_scaled_t
);
3969 /* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily
3970 * that ∞/∞ = 1) in order to comply with the rather artificial rules
3971 * inherited from IEEE 754-2008, namely:
3973 * "atan2(±∞, −∞) is ±3π/4
3974 * atan2(±∞, +∞) is ±π/4"
3976 * Note that this is inconsistent with the rules for the neighborhood of
3977 * zero that are based on iterated limits:
3979 * "atan2(±0, −0) is ±π
3980 * atan2(±0, +0) is ±0"
3982 * but GLSL specifically allows implementations to deviate from IEEE rules
3983 * at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as
3986 ir_expression
*tan
= csel(equal(abs(x
), abs(y
)),
3987 imm(1.0f
, n
), abs(s_over_t
));
3989 /* Calculate the arctangent and fix up the result if we had flipped the
3990 * coordinate system.
3992 ir_variable
*arc
= body
.make_temp(type
, "arc");
3993 do_atan(body
, type
, arc
, tan
);
3994 body
.emit(assign(arc
, add(arc
, mul(b2f(flip
), imm(M_PI_2f
)))));
3996 /* Rather convoluted calculation of the sign of the result. When x < 0 we
3997 * cannot use fsign because we need to be able to distinguish between
3998 * negative and positive zero. Unfortunately we cannot use bitwise
3999 * arithmetic tricks either because of back-ends without integer support.
4000 * When x >= 0 rcp_scaled_t will always be non-negative so this won't be
4001 * able to distinguish between negative and positive zero, but we don't
4002 * care because atan2 is continuous along the whole positive y = 0
4003 * half-line, so it won't affect the result significantly.
4005 body
.emit(ret(csel(less(min2(y
, rcp_scaled_t
), imm(0.0f
, n
)),
4012 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
4015 * range-reduction, first step:
4017 * / y_over_x if |y_over_x| <= 1.0;
4019 * \ 1.0 / y_over_x otherwise
4021 ir_variable
*x
= body
.make_temp(type
, "atan_x");
4022 body
.emit(assign(x
, div(min2(abs(y_over_x
),
4028 * approximate atan by evaluating polynomial:
4030 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
4031 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
4032 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
4034 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
4035 body
.emit(assign(tmp
, mul(x
, x
)));
4036 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
4038 imm(0.0536813784310406f
)),
4040 imm(0.1173503194786851f
)),
4042 imm(0.1938924977115610f
)),
4044 imm(0.3326756418091246f
)),
4046 imm(0.9999793128310355f
)),
4049 /* range-reduction fixup */
4050 body
.emit(assign(tmp
, add(tmp
,
4051 mul(b2f(greater(abs(y_over_x
),
4052 imm(1.0f
, type
->components()))),
4058 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
4061 ir_function_signature
*
4062 builtin_builder::_atan(const glsl_type
*type
)
4064 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
4065 MAKE_SIG(type
, always_available
, 1, y_over_x
);
4067 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
4068 do_atan(body
, type
, tmp
, y_over_x
);
4069 body
.emit(ret(tmp
));
4074 ir_function_signature
*
4075 builtin_builder::_sinh(const glsl_type
*type
)
4077 ir_variable
*x
= in_var(type
, "x");
4078 MAKE_SIG(type
, v130
, 1, x
);
4080 /* 0.5 * (e^x - e^(-x)) */
4081 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
4086 ir_function_signature
*
4087 builtin_builder::_cosh(const glsl_type
*type
)
4089 ir_variable
*x
= in_var(type
, "x");
4090 MAKE_SIG(type
, v130
, 1, x
);
4092 /* 0.5 * (e^x + e^(-x)) */
4093 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
4098 ir_function_signature
*
4099 builtin_builder::_tanh(const glsl_type
*type
)
4101 ir_variable
*x
= in_var(type
, "x");
4102 MAKE_SIG(type
, v130
, 1, x
);
4104 /* tanh(x) := (0.5 * (e^x - e^(-x))) / (0.5 * (e^x + e^(-x)))
4106 * With a little algebra this reduces to (e^2x - 1) / (e^2x + 1)
4108 * Clamp x to (-inf, +10] to avoid precision problems. When x > 10, e^2x
4109 * is so much larger than 1.0 that 1.0 gets flushed to zero in the
4110 * computation e^2x +/- 1 so it can be ignored.
4112 ir_variable
*t
= body
.make_temp(type
, "tmp");
4113 body
.emit(assign(t
, min2(x
, imm(10.0f
))));
4115 body
.emit(ret(div(sub(exp(mul(t
, imm(2.0f
))), imm(1.0f
)),
4116 add(exp(mul(t
, imm(2.0f
))), imm(1.0f
)))));
4121 ir_function_signature
*
4122 builtin_builder::_asinh(const glsl_type
*type
)
4124 ir_variable
*x
= in_var(type
, "x");
4125 MAKE_SIG(type
, v130
, 1, x
);
4127 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
4132 ir_function_signature
*
4133 builtin_builder::_acosh(const glsl_type
*type
)
4135 ir_variable
*x
= in_var(type
, "x");
4136 MAKE_SIG(type
, v130
, 1, x
);
4138 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
4142 ir_function_signature
*
4143 builtin_builder::_atanh(const glsl_type
*type
)
4145 ir_variable
*x
= in_var(type
, "x");
4146 MAKE_SIG(type
, v130
, 1, x
);
4148 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
4149 sub(imm(1.0f
), x
))))));
4155 * Exponential Functions @{
4158 ir_function_signature
*
4159 builtin_builder::_pow(const glsl_type
*type
)
4161 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
4164 UNOP(exp
, ir_unop_exp
, always_available
)
4165 UNOP(log
, ir_unop_log
, always_available
)
4166 UNOP(exp2
, ir_unop_exp2
, always_available
)
4167 UNOP(log2
, ir_unop_log2
, always_available
)
4168 UNOPA(sqrt
, ir_unop_sqrt
)
4169 UNOPA(inversesqrt
, ir_unop_rsq
)
4173 UNOPA(abs
, ir_unop_abs
)
4174 UNOPA(sign
, ir_unop_sign
)
4175 UNOPA(floor
, ir_unop_floor
)
4176 UNOPA(trunc
, ir_unop_trunc
)
4177 UNOPA(round
, ir_unop_round_even
)
4178 UNOPA(roundEven
, ir_unop_round_even
)
4179 UNOPA(ceil
, ir_unop_ceil
)
4180 UNOPA(fract
, ir_unop_fract
)
4182 ir_function_signature
*
4183 builtin_builder::_mod(builtin_available_predicate avail
,
4184 const glsl_type
*x_type
, const glsl_type
*y_type
)
4186 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
4189 ir_function_signature
*
4190 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
4192 ir_variable
*x
= in_var(type
, "x");
4193 ir_variable
*i
= out_var(type
, "i");
4194 MAKE_SIG(type
, avail
, 2, x
, i
);
4196 ir_variable
*t
= body
.make_temp(type
, "t");
4197 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
4198 body
.emit(assign(i
, t
));
4199 body
.emit(ret(sub(x
, t
)));
4204 ir_function_signature
*
4205 builtin_builder::_min(builtin_available_predicate avail
,
4206 const glsl_type
*x_type
, const glsl_type
*y_type
)
4208 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
4211 ir_function_signature
*
4212 builtin_builder::_max(builtin_available_predicate avail
,
4213 const glsl_type
*x_type
, const glsl_type
*y_type
)
4215 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
4218 ir_function_signature
*
4219 builtin_builder::_clamp(builtin_available_predicate avail
,
4220 const glsl_type
*val_type
, const glsl_type
*bound_type
)
4222 ir_variable
*x
= in_var(val_type
, "x");
4223 ir_variable
*minVal
= in_var(bound_type
, "minVal");
4224 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
4225 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
4227 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
4232 ir_function_signature
*
4233 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
4235 ir_variable
*x
= in_var(val_type
, "x");
4236 ir_variable
*y
= in_var(val_type
, "y");
4237 ir_variable
*a
= in_var(blend_type
, "a");
4238 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4240 body
.emit(ret(lrp(x
, y
, a
)));
4245 ir_function_signature
*
4246 builtin_builder::_mix_sel(builtin_available_predicate avail
,
4247 const glsl_type
*val_type
,
4248 const glsl_type
*blend_type
)
4250 ir_variable
*x
= in_var(val_type
, "x");
4251 ir_variable
*y
= in_var(val_type
, "y");
4252 ir_variable
*a
= in_var(blend_type
, "a");
4253 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4255 /* csel matches the ternary operator in that a selector of true choses the
4256 * first argument. This differs from mix(x, y, false) which choses the
4257 * second argument (to remain consistent with the interpolating version of
4258 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
4260 * To handle the behavior mismatch, reverse the x and y arguments.
4262 body
.emit(ret(csel(a
, y
, x
)));
4267 ir_function_signature
*
4268 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4270 ir_variable
*edge
= in_var(edge_type
, "edge");
4271 ir_variable
*x
= in_var(x_type
, "x");
4272 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
4274 ir_variable
*t
= body
.make_temp(x_type
, "t");
4275 if (x_type
->vector_elements
== 1) {
4276 /* Both are floats */
4277 if (edge_type
->is_double())
4278 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
4280 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
4281 } else if (edge_type
->vector_elements
== 1) {
4282 /* x is a vector but edge is a float */
4283 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4284 if (edge_type
->is_double())
4285 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
4287 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
4290 /* Both are vectors */
4291 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4292 if (edge_type
->is_double())
4293 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
4296 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
4306 ir_function_signature
*
4307 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4309 ir_variable
*edge0
= in_var(edge_type
, "edge0");
4310 ir_variable
*edge1
= in_var(edge_type
, "edge1");
4311 ir_variable
*x
= in_var(x_type
, "x");
4312 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
4314 /* From the GLSL 1.10 specification:
4317 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
4318 * return t * t * (3 - 2 * t);
4321 ir_variable
*t
= body
.make_temp(x_type
, "t");
4322 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
4323 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
4325 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
4330 ir_function_signature
*
4331 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
4333 ir_variable
*x
= in_var(type
, "x");
4334 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4336 body
.emit(ret(nequal(x
, x
)));
4341 ir_function_signature
*
4342 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
4344 ir_variable
*x
= in_var(type
, "x");
4345 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4347 ir_constant_data infinities
;
4348 for (int i
= 0; i
< type
->vector_elements
; i
++) {
4349 switch (type
->base_type
) {
4350 case GLSL_TYPE_FLOAT
:
4351 infinities
.f
[i
] = INFINITY
;
4353 case GLSL_TYPE_DOUBLE
:
4354 infinities
.d
[i
] = INFINITY
;
4357 unreachable("unknown type");
4361 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
4366 ir_function_signature
*
4367 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
4369 ir_variable
*x
= in_var(type
, "x");
4370 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4371 body
.emit(ret(bitcast_f2i(x
)));
4375 ir_function_signature
*
4376 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
4378 ir_variable
*x
= in_var(type
, "x");
4379 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4380 body
.emit(ret(bitcast_f2u(x
)));
4384 ir_function_signature
*
4385 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
4387 ir_variable
*x
= in_var(type
, "x");
4388 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4389 body
.emit(ret(bitcast_i2f(x
)));
4393 ir_function_signature
*
4394 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
4396 ir_variable
*x
= in_var(type
, "x");
4397 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4398 body
.emit(ret(bitcast_u2f(x
)));
4402 ir_function_signature
*
4403 builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail
, const glsl_type
*type
)
4405 ir_variable
*x
= in_var(type
, "x");
4406 MAKE_SIG(glsl_type::i64vec(type
->vector_elements
), avail
, 1, x
);
4407 body
.emit(ret(bitcast_d2i64(x
)));
4411 ir_function_signature
*
4412 builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail
, const glsl_type
*type
)
4414 ir_variable
*x
= in_var(type
, "x");
4415 MAKE_SIG(glsl_type::u64vec(type
->vector_elements
), avail
, 1, x
);
4416 body
.emit(ret(bitcast_d2u64(x
)));
4420 ir_function_signature
*
4421 builtin_builder::_int64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4423 ir_variable
*x
= in_var(type
, "x");
4424 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4425 body
.emit(ret(bitcast_i642d(x
)));
4429 ir_function_signature
*
4430 builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4432 ir_variable
*x
= in_var(type
, "x");
4433 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4434 body
.emit(ret(bitcast_u642d(x
)));
4438 ir_function_signature
*
4439 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
4441 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4442 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4443 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
4447 ir_function_signature
*
4448 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
4450 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4451 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4452 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
4456 ir_function_signature
*
4457 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
4459 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4460 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4461 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
4465 ir_function_signature
*
4466 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
4468 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4469 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4470 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
4474 ir_function_signature
*
4475 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
4477 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4478 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4479 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
4483 ir_function_signature
*
4484 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
4486 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4487 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4488 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
4493 ir_function_signature
*
4494 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
4496 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4497 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4498 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
4502 ir_function_signature
*
4503 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
4505 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4506 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4507 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
4511 ir_function_signature
*
4512 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
4514 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4515 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4516 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
4520 ir_function_signature
*
4521 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
4523 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4524 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4525 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
4529 ir_function_signature
*
4530 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
4532 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4533 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
4534 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
4538 ir_function_signature
*
4539 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
4541 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
4542 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4543 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
4547 ir_function_signature
*
4548 builtin_builder::_packInt2x32(builtin_available_predicate avail
)
4550 ir_variable
*v
= in_var(glsl_type::ivec2_type
, "v");
4551 MAKE_SIG(glsl_type::int64_t_type
, avail
, 1, v
);
4552 body
.emit(ret(expr(ir_unop_pack_int_2x32
, v
)));
4556 ir_function_signature
*
4557 builtin_builder::_unpackInt2x32(builtin_available_predicate avail
)
4559 ir_variable
*p
= in_var(glsl_type::int64_t_type
, "p");
4560 MAKE_SIG(glsl_type::ivec2_type
, avail
, 1, p
);
4561 body
.emit(ret(expr(ir_unop_unpack_int_2x32
, p
)));
4565 ir_function_signature
*
4566 builtin_builder::_packUint2x32(builtin_available_predicate avail
)
4568 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4569 MAKE_SIG(glsl_type::uint64_t_type
, avail
, 1, v
);
4570 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, v
)));
4574 ir_function_signature
*
4575 builtin_builder::_unpackUint2x32(builtin_available_predicate avail
)
4577 ir_variable
*p
= in_var(glsl_type::uint64_t_type
, "p");
4578 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4579 body
.emit(ret(expr(ir_unop_unpack_uint_2x32
, p
)));
4583 ir_function_signature
*
4584 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
4586 ir_variable
*x
= in_var(type
, "x");
4587 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
4589 body
.emit(ret(sqrt(dot(x
, x
))));
4594 ir_function_signature
*
4595 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
4597 ir_variable
*p0
= in_var(type
, "p0");
4598 ir_variable
*p1
= in_var(type
, "p1");
4599 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
4601 if (type
->vector_elements
== 1) {
4602 body
.emit(ret(abs(sub(p0
, p1
))));
4604 ir_variable
*p
= body
.make_temp(type
, "p");
4605 body
.emit(assign(p
, sub(p0
, p1
)));
4606 body
.emit(ret(sqrt(dot(p
, p
))));
4612 ir_function_signature
*
4613 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
4615 if (type
->vector_elements
== 1)
4616 return binop(avail
, ir_binop_mul
, type
, type
, type
);
4618 return binop(avail
, ir_binop_dot
,
4619 type
->get_base_type(), type
, type
);
4622 ir_function_signature
*
4623 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
4625 ir_variable
*a
= in_var(type
, "a");
4626 ir_variable
*b
= in_var(type
, "b");
4627 MAKE_SIG(type
, avail
, 2, a
, b
);
4629 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
4630 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
4632 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
4633 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
4638 ir_function_signature
*
4639 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
4641 ir_variable
*x
= in_var(type
, "x");
4642 MAKE_SIG(type
, avail
, 1, x
);
4644 if (type
->vector_elements
== 1) {
4645 body
.emit(ret(sign(x
)));
4647 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
4653 ir_function_signature
*
4654 builtin_builder::_ftransform()
4656 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
4658 /* ftransform() refers to global variables, and is always emitted
4659 * directly by ast_function.cpp. Just emit a prototype here so we
4660 * can recognize calls to it.
4665 ir_function_signature
*
4666 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
4668 ir_variable
*N
= in_var(type
, "N");
4669 ir_variable
*I
= in_var(type
, "I");
4670 ir_variable
*Nref
= in_var(type
, "Nref");
4671 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
4673 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
4674 ret(N
), ret(neg(N
))));
4679 ir_function_signature
*
4680 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
4682 ir_variable
*I
= in_var(type
, "I");
4683 ir_variable
*N
= in_var(type
, "N");
4684 MAKE_SIG(type
, avail
, 2, I
, N
);
4686 /* I - 2 * dot(N, I) * N */
4687 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
4692 ir_function_signature
*
4693 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
4695 ir_variable
*I
= in_var(type
, "I");
4696 ir_variable
*N
= in_var(type
, "N");
4697 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
4698 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4700 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4701 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4703 /* From the GLSL 1.10 specification:
4704 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4706 * return genType(0.0)
4708 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4710 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4711 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4712 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4713 mul(n_dot_i
, n_dot_i
)))))));
4714 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4715 ret(ir_constant::zero(mem_ctx
, type
)),
4716 ret(sub(mul(eta
, I
),
4717 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4722 ir_function_signature
*
4723 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4725 ir_variable
*x
= in_var(type
, "x");
4726 ir_variable
*y
= in_var(type
, "y");
4727 MAKE_SIG(type
, avail
, 2, x
, y
);
4729 ir_variable
*z
= body
.make_temp(type
, "z");
4730 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4731 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4738 ir_function_signature
*
4739 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4744 if (type
->is_double()) {
4745 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4746 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4748 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4749 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4751 MAKE_SIG(type
, avail
, 2, c
, r
);
4753 ir_variable
*m
= body
.make_temp(type
, "m");
4754 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4755 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4762 ir_function_signature
*
4763 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4765 const glsl_type
*transpose_type
=
4766 glsl_type::get_instance(orig_type
->base_type
,
4767 orig_type
->matrix_columns
,
4768 orig_type
->vector_elements
);
4770 ir_variable
*m
= in_var(orig_type
, "m");
4771 MAKE_SIG(transpose_type
, avail
, 1, m
);
4773 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4774 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4775 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4776 body
.emit(assign(array_ref(t
, j
),
4777 matrix_elt(m
, i
, j
),
4786 ir_function_signature
*
4787 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4789 ir_variable
*m
= in_var(type
, "m");
4790 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4792 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4793 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4798 ir_function_signature
*
4799 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4801 ir_variable
*m
= in_var(type
, "m");
4802 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4805 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4806 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4809 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4810 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4813 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4814 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4816 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4817 mul(matrix_elt(m
, 0, 1), f2
)),
4818 mul(matrix_elt(m
, 0, 2), f3
))));
4823 ir_function_signature
*
4824 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4826 ir_variable
*m
= in_var(type
, "m");
4827 const glsl_type
*btype
= type
->get_base_type();
4828 MAKE_SIG(btype
, avail
, 1, m
);
4830 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4831 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4832 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4833 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4834 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4835 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4836 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4837 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4838 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4839 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4840 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4841 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4842 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4843 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4844 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4845 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4846 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4847 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4848 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4850 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)))));
4851 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)))));
4852 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)))));
4853 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)))));
4854 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)))));
4855 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)))));
4856 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)))));
4857 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)))));
4858 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)))));
4859 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)))));
4860 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)))));
4861 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)))));
4862 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)))));
4863 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)))));
4864 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)))));
4865 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)))));
4866 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)))));
4867 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)))));
4868 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)))));
4870 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4872 body
.emit(assign(adj_0
,
4873 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4874 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4875 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4877 body
.emit(assign(adj_0
, neg(
4878 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4879 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4880 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4882 body
.emit(assign(adj_0
,
4883 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4884 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4885 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4887 body
.emit(assign(adj_0
, neg(
4888 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4889 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4890 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4893 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4898 ir_function_signature
*
4899 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4901 ir_variable
*m
= in_var(type
, "m");
4902 MAKE_SIG(type
, avail
, 1, m
);
4904 ir_variable
*adj
= body
.make_temp(type
, "adj");
4905 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4906 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4907 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4908 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4910 ir_expression
*det
=
4911 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4912 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4914 body
.emit(ret(div(adj
, det
)));
4918 ir_function_signature
*
4919 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4921 ir_variable
*m
= in_var(type
, "m");
4922 const glsl_type
*btype
= type
->get_base_type();
4923 MAKE_SIG(type
, avail
, 1, m
);
4925 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4926 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4927 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4929 body
.emit(assign(f11_22_21_12
,
4930 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4931 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4932 body
.emit(assign(f10_22_20_12
,
4933 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4934 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4935 body
.emit(assign(f10_21_20_11
,
4936 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4937 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4939 ir_variable
*adj
= body
.make_temp(type
, "adj");
4940 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4941 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4942 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4944 body
.emit(assign(array_ref(adj
, 0), neg(
4945 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4946 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4948 body
.emit(assign(array_ref(adj
, 1),
4949 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4950 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4952 body
.emit(assign(array_ref(adj
, 2), neg(
4953 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4954 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4957 body
.emit(assign(array_ref(adj
, 0),
4958 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4959 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4961 body
.emit(assign(array_ref(adj
, 1), neg(
4962 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4963 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4965 body
.emit(assign(array_ref(adj
, 2),
4966 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4967 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4970 ir_expression
*det
=
4971 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4972 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4973 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4975 body
.emit(ret(div(adj
, det
)));
4980 ir_function_signature
*
4981 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4983 ir_variable
*m
= in_var(type
, "m");
4984 const glsl_type
*btype
= type
->get_base_type();
4985 MAKE_SIG(type
, avail
, 1, m
);
4987 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4988 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4989 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4990 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4991 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4992 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4993 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4994 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4995 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4996 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4997 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4998 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4999 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
5000 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
5001 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
5002 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
5003 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
5004 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
5005 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
5007 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)))));
5008 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)))));
5009 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)))));
5010 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)))));
5011 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)))));
5012 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)))));
5013 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)))));
5014 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)))));
5015 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)))));
5016 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)))));
5017 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)))));
5018 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)))));
5019 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)))));
5020 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)))));
5021 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)))));
5022 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)))));
5023 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)))));
5024 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)))));
5025 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)))));
5027 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
5028 body
.emit(assign(array_ref(adj
, 0),
5029 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
5030 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
5031 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
5033 body
.emit(assign(array_ref(adj
, 1), neg(
5034 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
5035 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
5036 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
5038 body
.emit(assign(array_ref(adj
, 2),
5039 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
5040 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
5041 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
5043 body
.emit(assign(array_ref(adj
, 3), neg(
5044 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
5045 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
5046 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
5049 body
.emit(assign(array_ref(adj
, 0), neg(
5050 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
5051 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
5052 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
5054 body
.emit(assign(array_ref(adj
, 1),
5055 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
5056 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
5057 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
5059 body
.emit(assign(array_ref(adj
, 2), neg(
5060 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
5061 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
5062 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
5064 body
.emit(assign(array_ref(adj
, 3),
5065 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
5066 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
5067 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
5070 body
.emit(assign(array_ref(adj
, 0),
5071 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
5072 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
5073 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
5075 body
.emit(assign(array_ref(adj
, 1), neg(
5076 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
5077 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
5078 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
5080 body
.emit(assign(array_ref(adj
, 2),
5081 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
5082 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
5083 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
5085 body
.emit(assign(array_ref(adj
, 3), neg(
5086 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
5087 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
5088 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
5091 body
.emit(assign(array_ref(adj
, 0), neg(
5092 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
5093 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
5094 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
5096 body
.emit(assign(array_ref(adj
, 1),
5097 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
5098 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
5099 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
5101 body
.emit(assign(array_ref(adj
, 2), neg(
5102 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
5103 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
5104 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
5106 body
.emit(assign(array_ref(adj
, 3),
5107 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
5108 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
5109 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
5112 ir_expression
*det
=
5113 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
5114 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
5115 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
5116 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
5118 body
.emit(ret(div(adj
, det
)));
5124 ir_function_signature
*
5125 builtin_builder::_lessThan(builtin_available_predicate avail
,
5126 const glsl_type
*type
)
5128 return binop(avail
, ir_binop_less
,
5129 glsl_type::bvec(type
->vector_elements
), type
, type
);
5132 ir_function_signature
*
5133 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
5134 const glsl_type
*type
)
5136 return binop(avail
, ir_binop_gequal
,
5137 glsl_type::bvec(type
->vector_elements
), type
, type
,
5141 ir_function_signature
*
5142 builtin_builder::_greaterThan(builtin_available_predicate avail
,
5143 const glsl_type
*type
)
5145 return binop(avail
, ir_binop_less
,
5146 glsl_type::bvec(type
->vector_elements
), type
, type
,
5150 ir_function_signature
*
5151 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
5152 const glsl_type
*type
)
5154 return binop(avail
, ir_binop_gequal
,
5155 glsl_type::bvec(type
->vector_elements
), type
, type
);
5158 ir_function_signature
*
5159 builtin_builder::_equal(builtin_available_predicate avail
,
5160 const glsl_type
*type
)
5162 return binop(avail
, ir_binop_equal
,
5163 glsl_type::bvec(type
->vector_elements
), type
, type
);
5166 ir_function_signature
*
5167 builtin_builder::_notEqual(builtin_available_predicate avail
,
5168 const glsl_type
*type
)
5170 return binop(avail
, ir_binop_nequal
,
5171 glsl_type::bvec(type
->vector_elements
), type
, type
);
5174 ir_function_signature
*
5175 builtin_builder::_any(const glsl_type
*type
)
5177 ir_variable
*v
= in_var(type
, "v");
5178 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5180 const unsigned vec_elem
= v
->type
->vector_elements
;
5181 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
5186 ir_function_signature
*
5187 builtin_builder::_all(const glsl_type
*type
)
5189 ir_variable
*v
= in_var(type
, "v");
5190 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5192 const unsigned vec_elem
= v
->type
->vector_elements
;
5193 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
5198 UNOP(not, ir_unop_logic_not
, always_available
)
5201 has_lod(const glsl_type
*sampler_type
)
5203 assert(sampler_type
->is_sampler());
5205 switch (sampler_type
->sampler_dimensionality
) {
5206 case GLSL_SAMPLER_DIM_RECT
:
5207 case GLSL_SAMPLER_DIM_BUF
:
5208 case GLSL_SAMPLER_DIM_MS
:
5215 ir_function_signature
*
5216 builtin_builder::_textureSize(builtin_available_predicate avail
,
5217 const glsl_type
*return_type
,
5218 const glsl_type
*sampler_type
)
5220 ir_variable
*s
= in_var(sampler_type
, "sampler");
5221 /* The sampler always exists; add optional lod later. */
5222 MAKE_SIG(return_type
, avail
, 1, s
);
5224 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
5225 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
5227 if (has_lod(sampler_type
)) {
5228 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5229 sig
->parameters
.push_tail(lod
);
5230 tex
->lod_info
.lod
= var_ref(lod
);
5232 tex
->lod_info
.lod
= imm(0u);
5235 body
.emit(ret(tex
));
5240 ir_function_signature
*
5241 builtin_builder::_textureSamples(builtin_available_predicate avail
,
5242 const glsl_type
*sampler_type
)
5244 ir_variable
*s
= in_var(sampler_type
, "sampler");
5245 MAKE_SIG(glsl_type::int_type
, avail
, 1, s
);
5247 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
5248 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
5249 body
.emit(ret(tex
));
5254 ir_function_signature
*
5255 builtin_builder::_texture(ir_texture_opcode opcode
,
5256 builtin_available_predicate avail
,
5257 const glsl_type
*return_type
,
5258 const glsl_type
*sampler_type
,
5259 const glsl_type
*coord_type
,
5262 ir_variable
*s
= in_var(sampler_type
, "sampler");
5263 ir_variable
*P
= in_var(coord_type
, "P");
5264 /* The sampler and coordinate always exist; add optional parameters later. */
5265 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5267 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
5268 tex
->set_sampler(var_ref(s
), return_type
);
5270 const int coord_size
= sampler_type
->coordinate_components();
5272 if (coord_size
== coord_type
->vector_elements
) {
5273 tex
->coordinate
= var_ref(P
);
5275 /* The incoming coordinate also has the projector or shadow comparator,
5276 * so we need to swizzle those away.
5278 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
5281 /* The projector is always in the last component. */
5282 if (flags
& TEX_PROJECT
)
5283 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
5285 if (sampler_type
->sampler_shadow
) {
5286 if (opcode
== ir_tg4
) {
5287 /* gather has refz as a separate parameter, immediately after the
5290 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
5291 sig
->parameters
.push_tail(refz
);
5292 tex
->shadow_comparator
= var_ref(refz
);
5294 /* The shadow comparator is normally in the Z component, but a few types
5295 * have sufficiently large coordinates that it's in W.
5297 tex
->shadow_comparator
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
5301 if (opcode
== ir_txl
) {
5302 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
5303 sig
->parameters
.push_tail(lod
);
5304 tex
->lod_info
.lod
= var_ref(lod
);
5305 } else if (opcode
== ir_txd
) {
5306 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5307 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
5308 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
5309 sig
->parameters
.push_tail(dPdx
);
5310 sig
->parameters
.push_tail(dPdy
);
5311 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
5312 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
5315 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
5316 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5317 ir_variable
*offset
=
5318 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
5319 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
5320 sig
->parameters
.push_tail(offset
);
5321 tex
->offset
= var_ref(offset
);
5324 if (flags
& TEX_OFFSET_ARRAY
) {
5325 ir_variable
*offsets
=
5326 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
5327 "offsets", ir_var_const_in
);
5328 sig
->parameters
.push_tail(offsets
);
5329 tex
->offset
= var_ref(offsets
);
5332 if (opcode
== ir_tg4
) {
5333 if (flags
& TEX_COMPONENT
) {
5334 ir_variable
*component
=
5335 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
5336 sig
->parameters
.push_tail(component
);
5337 tex
->lod_info
.component
= var_ref(component
);
5340 tex
->lod_info
.component
= imm(0);
5344 /* The "bias" parameter comes /after/ the "offset" parameter, which is
5345 * inconsistent with both textureLodOffset and textureGradOffset.
5347 if (opcode
== ir_txb
) {
5348 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
5349 sig
->parameters
.push_tail(bias
);
5350 tex
->lod_info
.bias
= var_ref(bias
);
5353 body
.emit(ret(tex
));
5358 ir_function_signature
*
5359 builtin_builder::_textureCubeArrayShadow(builtin_available_predicate avail
,
5360 const glsl_type
*sampler_type
)
5362 ir_variable
*s
= in_var(sampler_type
, "sampler");
5363 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
5364 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
5365 MAKE_SIG(glsl_type::float_type
, avail
, 3, s
, P
, compare
);
5367 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
5368 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
5370 tex
->coordinate
= var_ref(P
);
5371 tex
->shadow_comparator
= var_ref(compare
);
5373 body
.emit(ret(tex
));
5378 ir_function_signature
*
5379 builtin_builder::_texelFetch(builtin_available_predicate avail
,
5380 const glsl_type
*return_type
,
5381 const glsl_type
*sampler_type
,
5382 const glsl_type
*coord_type
,
5383 const glsl_type
*offset_type
)
5385 ir_variable
*s
= in_var(sampler_type
, "sampler");
5386 ir_variable
*P
= in_var(coord_type
, "P");
5387 /* The sampler and coordinate always exist; add optional parameters later. */
5388 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5390 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
5391 tex
->coordinate
= var_ref(P
);
5392 tex
->set_sampler(var_ref(s
), return_type
);
5394 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
5395 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
5396 sig
->parameters
.push_tail(sample
);
5397 tex
->lod_info
.sample_index
= var_ref(sample
);
5398 tex
->op
= ir_txf_ms
;
5399 } else if (has_lod(sampler_type
)) {
5400 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5401 sig
->parameters
.push_tail(lod
);
5402 tex
->lod_info
.lod
= var_ref(lod
);
5404 tex
->lod_info
.lod
= imm(0u);
5407 if (offset_type
!= NULL
) {
5408 ir_variable
*offset
=
5409 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
5410 sig
->parameters
.push_tail(offset
);
5411 tex
->offset
= var_ref(offset
);
5414 body
.emit(ret(tex
));
5419 ir_function_signature
*
5420 builtin_builder::_EmitVertex()
5422 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5424 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5425 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
5430 ir_function_signature
*
5431 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
5432 const glsl_type
*stream_type
)
5434 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5436 * "Emit the current values of output variables to the current output
5437 * primitive on stream stream. The argument to stream must be a constant
5438 * integral expression."
5440 ir_variable
*stream
=
5441 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5443 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5445 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
5450 ir_function_signature
*
5451 builtin_builder::_EndPrimitive()
5453 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5455 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5456 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
5461 ir_function_signature
*
5462 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
5463 const glsl_type
*stream_type
)
5465 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5467 * "Completes the current output primitive on stream stream and starts
5468 * a new one. The argument to stream must be a constant integral
5471 ir_variable
*stream
=
5472 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5474 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5476 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
5481 ir_function_signature
*
5482 builtin_builder::_barrier()
5484 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
5486 body
.emit(new(mem_ctx
) ir_barrier());
5490 ir_function_signature
*
5491 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
5492 const glsl_type
*sampler_type
,
5493 const glsl_type
*coord_type
)
5495 ir_variable
*s
= in_var(sampler_type
, "sampler");
5496 ir_variable
*coord
= in_var(coord_type
, "coord");
5497 /* The sampler and coordinate always exist; add optional parameters later. */
5498 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
5500 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
5501 tex
->coordinate
= var_ref(coord
);
5502 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
5504 body
.emit(ret(tex
));
5509 ir_function_signature
*
5510 builtin_builder::_textureQueryLevels(builtin_available_predicate avail
,
5511 const glsl_type
*sampler_type
)
5513 ir_variable
*s
= in_var(sampler_type
, "sampler");
5514 const glsl_type
*return_type
= glsl_type::int_type
;
5515 MAKE_SIG(return_type
, avail
, 1, s
);
5517 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
5518 tex
->set_sampler(var_ref(s
), return_type
);
5520 body
.emit(ret(tex
));
5525 ir_function_signature
*
5526 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
5527 const glsl_type
*sampler_type
,
5528 const glsl_type
*coord_type
)
5530 ir_variable
*s
= in_var(sampler_type
, "sampler");
5531 ir_variable
*P
= in_var(coord_type
, "P");
5532 const glsl_type
*return_type
= glsl_type::bool_type
;
5533 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5535 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
5536 tex
->coordinate
= var_ref(P
);
5537 tex
->set_sampler(var_ref(s
), return_type
);
5539 body
.emit(ret(tex
));
5544 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
5545 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
5546 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
5547 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
5548 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
5549 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
5551 ir_function_signature
*
5552 builtin_builder::_fwidth(const glsl_type
*type
)
5554 ir_variable
*p
= in_var(type
, "p");
5555 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
5557 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
5562 ir_function_signature
*
5563 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
5565 ir_variable
*p
= in_var(type
, "p");
5566 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5568 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
5569 abs(expr(ir_unop_dFdy_coarse
, p
)))));
5574 ir_function_signature
*
5575 builtin_builder::_fwidthFine(const glsl_type
*type
)
5577 ir_variable
*p
= in_var(type
, "p");
5578 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5580 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
5581 abs(expr(ir_unop_dFdy_fine
, p
)))));
5586 ir_function_signature
*
5587 builtin_builder::_noise1(const glsl_type
*type
)
5589 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
5592 ir_function_signature
*
5593 builtin_builder::_noise2(const glsl_type
*type
)
5595 ir_variable
*p
= in_var(type
, "p");
5596 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
5598 ir_constant_data b_offset
;
5599 b_offset
.f
[0] = 601.0f
;
5600 b_offset
.f
[1] = 313.0f
;
5601 b_offset
.f
[2] = 29.0f
;
5602 b_offset
.f
[3] = 277.0f
;
5604 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5605 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5606 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
5607 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5608 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5609 body
.emit(assign(t
, a
, WRITEMASK_X
));
5610 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5616 ir_function_signature
*
5617 builtin_builder::_noise3(const glsl_type
*type
)
5619 ir_variable
*p
= in_var(type
, "p");
5620 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
5622 ir_constant_data b_offset
;
5623 b_offset
.f
[0] = 601.0f
;
5624 b_offset
.f
[1] = 313.0f
;
5625 b_offset
.f
[2] = 29.0f
;
5626 b_offset
.f
[3] = 277.0f
;
5628 ir_constant_data c_offset
;
5629 c_offset
.f
[0] = 1559.0f
;
5630 c_offset
.f
[1] = 113.0f
;
5631 c_offset
.f
[2] = 1861.0f
;
5632 c_offset
.f
[3] = 797.0f
;
5634 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5635 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5636 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5637 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
5638 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5639 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5640 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
5641 body
.emit(assign(t
, a
, WRITEMASK_X
));
5642 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5643 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5649 ir_function_signature
*
5650 builtin_builder::_noise4(const glsl_type
*type
)
5652 ir_variable
*p
= in_var(type
, "p");
5653 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
5655 ir_variable
*_p
= body
.make_temp(type
, "_p");
5657 ir_constant_data p_offset
;
5658 p_offset
.f
[0] = 1559.0f
;
5659 p_offset
.f
[1] = 113.0f
;
5660 p_offset
.f
[2] = 1861.0f
;
5661 p_offset
.f
[3] = 797.0f
;
5663 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
5665 ir_constant_data offset
;
5666 offset
.f
[0] = 601.0f
;
5667 offset
.f
[1] = 313.0f
;
5668 offset
.f
[2] = 29.0f
;
5669 offset
.f
[3] = 277.0f
;
5671 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5672 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5673 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5674 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
5675 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
5676 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5677 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
5678 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
5679 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
5680 body
.emit(assign(t
, a
, WRITEMASK_X
));
5681 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5682 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5683 body
.emit(assign(t
, d
, WRITEMASK_W
));
5689 ir_function_signature
*
5690 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
5692 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5693 ir_variable
*value
= in_var(type
, "value");
5694 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5695 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5696 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, value
, offset
,
5699 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5700 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5702 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
5703 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5704 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5709 ir_function_signature
*
5710 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5712 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5713 ir_variable
*base
= in_var(type
, "base");
5714 ir_variable
*insert
= in_var(type
, "insert");
5715 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5716 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5717 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 4, base
, insert
,
5720 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5721 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5723 body
.emit(ret(bitfield_insert(base
, insert
,
5724 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5725 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5730 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31_or_integer_functions
)
5732 ir_function_signature
*
5733 builtin_builder::_bitCount(const glsl_type
*type
)
5735 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_bit_count
,
5736 glsl_type::ivec(type
->vector_elements
), type
);
5739 ir_function_signature
*
5740 builtin_builder::_findLSB(const glsl_type
*type
)
5742 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_lsb
,
5743 glsl_type::ivec(type
->vector_elements
), type
);
5746 ir_function_signature
*
5747 builtin_builder::_findMSB(const glsl_type
*type
)
5749 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_msb
,
5750 glsl_type::ivec(type
->vector_elements
), type
);
5753 ir_function_signature
*
5754 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5756 ir_variable
*a
= in_var(type
, "a");
5757 ir_variable
*b
= in_var(type
, "b");
5758 ir_variable
*c
= in_var(type
, "c");
5759 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5761 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5766 ir_function_signature
*
5767 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5769 return binop(x_type
->is_double() ? fp64
: gpu_shader5_or_es31_or_integer_functions
,
5770 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5773 ir_function_signature
*
5774 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5776 ir_variable
*x
= in_var(x_type
, "x");
5777 ir_variable
*exponent
= out_var(exp_type
, "exp");
5778 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5780 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5782 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5786 ir_function_signature
*
5787 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5789 ir_variable
*x
= in_var(x_type
, "x");
5790 ir_variable
*exponent
= out_var(exp_type
, "exp");
5791 MAKE_SIG(x_type
, gpu_shader5_or_es31_or_integer_functions
, 2, x
, exponent
);
5793 const unsigned vec_elem
= x_type
->vector_elements
;
5794 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5795 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5797 /* Single-precision floating-point values are stored as
5802 * An exponent shift of 23 will shift the mantissa out, leaving only the
5803 * exponent and sign bit (which itself may be zero, if the absolute value
5804 * was taken before the bitcast and shift.
5806 ir_constant
*exponent_shift
= imm(23);
5807 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5809 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5811 /* Exponent of floating-point values in the range [0.5, 1.0). */
5812 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5814 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5815 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5817 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5818 * to unsigned integers to ensure that 1 bits aren't shifted in.
5820 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5821 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5822 imm(0, vec_elem
)))));
5824 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5825 body
.emit(assign(bits
, bitcast_f2u(x
)));
5826 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5827 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5828 imm(0u, vec_elem
)))));
5829 body
.emit(ret(bitcast_u2f(bits
)));
5834 ir_function_signature
*
5835 builtin_builder::_uaddCarry(const glsl_type
*type
)
5837 ir_variable
*x
= in_var(type
, "x");
5838 ir_variable
*y
= in_var(type
, "y");
5839 ir_variable
*carry
= out_var(type
, "carry");
5840 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, carry
);
5842 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5843 body
.emit(ret(add(x
, y
)));
5848 ir_function_signature
*
5849 builtin_builder::_usubBorrow(const glsl_type
*type
)
5851 ir_variable
*x
= in_var(type
, "x");
5852 ir_variable
*y
= in_var(type
, "y");
5853 ir_variable
*borrow
= out_var(type
, "borrow");
5854 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, borrow
);
5856 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5857 body
.emit(ret(sub(x
, y
)));
5863 * For both imulExtended() and umulExtended() built-ins.
5865 ir_function_signature
*
5866 builtin_builder::_mulExtended(const glsl_type
*type
)
5868 ir_variable
*x
= in_var(type
, "x");
5869 ir_variable
*y
= in_var(type
, "y");
5870 ir_variable
*msb
= out_var(type
, "msb");
5871 ir_variable
*lsb
= out_var(type
, "lsb");
5872 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31_or_integer_functions
, 4, x
, y
, msb
, lsb
);
5874 body
.emit(assign(msb
, imul_high(x
, y
)));
5875 body
.emit(assign(lsb
, mul(x
, y
)));
5880 ir_function_signature
*
5881 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5883 ir_variable
*interpolant
= in_var(type
, "interpolant");
5884 interpolant
->data
.must_be_shader_input
= 1;
5885 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5887 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5892 ir_function_signature
*
5893 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5895 ir_variable
*interpolant
= in_var(type
, "interpolant");
5896 interpolant
->data
.must_be_shader_input
= 1;
5897 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5898 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5900 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5905 ir_function_signature
*
5906 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5908 ir_variable
*interpolant
= in_var(type
, "interpolant");
5909 interpolant
->data
.must_be_shader_input
= 1;
5910 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5911 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5913 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5918 ir_function_signature
*
5919 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
,
5920 enum ir_intrinsic_id id
)
5922 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5923 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 1, counter
);
5927 ir_function_signature
*
5928 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
,
5929 enum ir_intrinsic_id id
)
5931 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5932 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5933 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 2, counter
, data
);
5937 ir_function_signature
*
5938 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
,
5939 enum ir_intrinsic_id id
)
5941 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5942 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5943 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5944 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 3, counter
, compare
, data
);
5948 ir_function_signature
*
5949 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5950 const glsl_type
*type
,
5951 enum ir_intrinsic_id id
)
5953 ir_variable
*atomic
= in_var(type
, "atomic");
5954 ir_variable
*data
= in_var(type
, "data");
5955 MAKE_INTRINSIC(type
, id
, avail
, 2, atomic
, data
);
5959 ir_function_signature
*
5960 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5961 const glsl_type
*type
,
5962 enum ir_intrinsic_id id
)
5964 ir_variable
*atomic
= in_var(type
, "atomic");
5965 ir_variable
*data1
= in_var(type
, "data1");
5966 ir_variable
*data2
= in_var(type
, "data2");
5967 MAKE_INTRINSIC(type
, id
, avail
, 3, atomic
, data1
, data2
);
5971 ir_function_signature
*
5972 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5973 builtin_available_predicate avail
)
5975 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5976 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5978 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5979 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5981 body
.emit(ret(retval
));
5985 ir_function_signature
*
5986 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5987 builtin_available_predicate avail
)
5989 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5990 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5991 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5993 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5995 /* Instead of generating an __intrinsic_atomic_sub, generate an
5996 * __intrinsic_atomic_add with the data parameter negated.
5998 if (strcmp("__intrinsic_atomic_sub", intrinsic
) == 0) {
5999 ir_variable
*const neg_data
=
6000 body
.make_temp(glsl_type::uint_type
, "neg_data");
6002 body
.emit(assign(neg_data
, neg(data
)));
6004 exec_list parameters
;
6006 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(counter
));
6007 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(neg_data
));
6009 ir_function
*const func
=
6010 shader
->symbols
->get_function("__intrinsic_atomic_add");
6011 ir_instruction
*const c
= call(func
, retval
, parameters
);
6014 assert(parameters
.is_empty());
6018 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6022 body
.emit(ret(retval
));
6026 ir_function_signature
*
6027 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
6028 builtin_available_predicate avail
)
6030 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
6031 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
6032 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
6033 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
6035 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
6036 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6038 body
.emit(ret(retval
));
6042 ir_function_signature
*
6043 builtin_builder::_atomic_op2(const char *intrinsic
,
6044 builtin_available_predicate avail
,
6045 const glsl_type
*type
)
6047 ir_variable
*atomic
= in_var(type
, "atomic_var");
6048 ir_variable
*data
= in_var(type
, "atomic_data");
6049 MAKE_SIG(type
, avail
, 2, atomic
, data
);
6051 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
6052 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6054 body
.emit(ret(retval
));
6058 ir_function_signature
*
6059 builtin_builder::_atomic_op3(const char *intrinsic
,
6060 builtin_available_predicate avail
,
6061 const glsl_type
*type
)
6063 ir_variable
*atomic
= in_var(type
, "atomic_var");
6064 ir_variable
*data1
= in_var(type
, "atomic_data1");
6065 ir_variable
*data2
= in_var(type
, "atomic_data2");
6066 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
6068 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
6069 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6071 body
.emit(ret(retval
));
6075 ir_function_signature
*
6076 builtin_builder::_min3(const glsl_type
*type
)
6078 ir_variable
*x
= in_var(type
, "x");
6079 ir_variable
*y
= in_var(type
, "y");
6080 ir_variable
*z
= in_var(type
, "z");
6081 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6083 ir_expression
*min3
= min2(x
, min2(y
,z
));
6084 body
.emit(ret(min3
));
6089 ir_function_signature
*
6090 builtin_builder::_max3(const glsl_type
*type
)
6092 ir_variable
*x
= in_var(type
, "x");
6093 ir_variable
*y
= in_var(type
, "y");
6094 ir_variable
*z
= in_var(type
, "z");
6095 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6097 ir_expression
*max3
= max2(x
, max2(y
,z
));
6098 body
.emit(ret(max3
));
6103 ir_function_signature
*
6104 builtin_builder::_mid3(const glsl_type
*type
)
6106 ir_variable
*x
= in_var(type
, "x");
6107 ir_variable
*y
= in_var(type
, "y");
6108 ir_variable
*z
= in_var(type
, "z");
6109 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6111 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
6112 body
.emit(ret(mid3
));
6117 static builtin_available_predicate
6118 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
6120 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
6121 type
->sampled_type
== GLSL_TYPE_FLOAT
)
6122 return shader_image_atomic_exchange_float
;
6124 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
) &&
6125 type
->sampled_type
== GLSL_TYPE_FLOAT
)
6126 return shader_image_atomic_add_float
;
6128 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
6129 IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
|
6130 IMAGE_FUNCTION_AVAIL_ATOMIC
))
6131 return shader_image_atomic
;
6134 return shader_image_load_store
;
6137 ir_function_signature
*
6138 builtin_builder::_image_prototype(const glsl_type
*image_type
,
6139 unsigned num_arguments
,
6142 const glsl_type
*data_type
= glsl_type::get_instance(
6143 image_type
->sampled_type
,
6144 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
6146 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
6147 glsl_type::void_type
: data_type
);
6149 /* Addressing arguments that are always present. */
6150 ir_variable
*image
= in_var(image_type
, "image");
6151 ir_variable
*coord
= in_var(
6152 glsl_type::ivec(image_type
->coordinate_components()), "coord");
6154 ir_function_signature
*sig
= new_sig(
6155 ret_type
, get_image_available_predicate(image_type
, flags
),
6158 /* Sample index for multisample images. */
6159 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
6160 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
6162 /* Data arguments. */
6163 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
6164 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
6165 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
6166 ralloc_free(arg_name
);
6169 /* Set the maximal set of qualifiers allowed for this image
6170 * built-in. Function calls with arguments having fewer
6171 * qualifiers than present in the prototype are allowed by the
6172 * spec, but not with more, i.e. this will make the compiler
6173 * accept everything that needs to be accepted, and reject cases
6174 * like loads from write-only or stores to read-only images.
6176 image
->data
.memory_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
6177 image
->data
.memory_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
6178 image
->data
.memory_coherent
= true;
6179 image
->data
.memory_volatile
= true;
6180 image
->data
.memory_restrict
= true;
6185 ir_function_signature
*
6186 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
6187 unsigned /* num_arguments */,
6188 unsigned /* flags */)
6190 const glsl_type
*ret_type
;
6191 unsigned num_components
= image_type
->coordinate_components();
6193 /* From the ARB_shader_image_size extension:
6194 * "Cube images return the dimensions of one face."
6196 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
6197 !image_type
->sampler_array
) {
6201 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
6202 * supported by mesa.
6204 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
6206 ir_variable
*image
= in_var(image_type
, "image");
6207 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
6209 /* Set the maximal set of qualifiers allowed for this image
6210 * built-in. Function calls with arguments having fewer
6211 * qualifiers than present in the prototype are allowed by the
6212 * spec, but not with more, i.e. this will make the compiler
6213 * accept everything that needs to be accepted, and reject cases
6214 * like loads from write-only or stores to read-only images.
6216 image
->data
.memory_read_only
= true;
6217 image
->data
.memory_write_only
= true;
6218 image
->data
.memory_coherent
= true;
6219 image
->data
.memory_volatile
= true;
6220 image
->data
.memory_restrict
= true;
6225 ir_function_signature
*
6226 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
6227 unsigned /* num_arguments */,
6228 unsigned /* flags */)
6230 ir_variable
*image
= in_var(image_type
, "image");
6231 ir_function_signature
*sig
=
6232 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
6234 /* Set the maximal set of qualifiers allowed for this image
6235 * built-in. Function calls with arguments having fewer
6236 * qualifiers than present in the prototype are allowed by the
6237 * spec, but not with more, i.e. this will make the compiler
6238 * accept everything that needs to be accepted, and reject cases
6239 * like loads from write-only or stores to read-only images.
6241 image
->data
.memory_read_only
= true;
6242 image
->data
.memory_write_only
= true;
6243 image
->data
.memory_coherent
= true;
6244 image
->data
.memory_volatile
= true;
6245 image
->data
.memory_restrict
= true;
6250 ir_function_signature
*
6251 builtin_builder::_image(image_prototype_ctr prototype
,
6252 const glsl_type
*image_type
,
6253 const char *intrinsic_name
,
6254 unsigned num_arguments
,
6256 enum ir_intrinsic_id id
)
6258 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
6259 num_arguments
, flags
);
6261 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
6262 ir_factory
body(&sig
->body
, mem_ctx
);
6263 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
6265 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
6266 body
.emit(call(f
, NULL
, sig
->parameters
));
6268 ir_variable
*ret_val
=
6269 body
.make_temp(sig
->return_type
, "_ret_val");
6270 body
.emit(call(f
, ret_val
, sig
->parameters
));
6271 body
.emit(ret(ret_val
));
6274 sig
->is_defined
= true;
6277 sig
->intrinsic_id
= id
;
6283 ir_function_signature
*
6284 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
,
6285 enum ir_intrinsic_id id
)
6287 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6291 ir_function_signature
*
6292 builtin_builder::_memory_barrier(const char *intrinsic_name
,
6293 builtin_available_predicate avail
)
6295 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6296 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6297 NULL
, sig
->parameters
));
6301 ir_function_signature
*
6302 builtin_builder::_ballot_intrinsic()
6304 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6305 MAKE_INTRINSIC(glsl_type::uint64_t_type
, ir_intrinsic_ballot
, shader_ballot
,
6310 ir_function_signature
*
6311 builtin_builder::_ballot()
6313 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6315 MAKE_SIG(glsl_type::uint64_t_type
, shader_ballot
, 1, value
);
6316 ir_variable
*retval
= body
.make_temp(glsl_type::uint64_t_type
, "retval");
6318 body
.emit(call(shader
->symbols
->get_function("__intrinsic_ballot"),
6319 retval
, sig
->parameters
));
6320 body
.emit(ret(retval
));
6324 ir_function_signature
*
6325 builtin_builder::_read_first_invocation_intrinsic(const glsl_type
*type
)
6327 ir_variable
*value
= in_var(type
, "value");
6328 MAKE_INTRINSIC(type
, ir_intrinsic_read_first_invocation
, shader_ballot
,
6333 ir_function_signature
*
6334 builtin_builder::_read_first_invocation(const glsl_type
*type
)
6336 ir_variable
*value
= in_var(type
, "value");
6338 MAKE_SIG(type
, shader_ballot
, 1, value
);
6339 ir_variable
*retval
= body
.make_temp(type
, "retval");
6341 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_first_invocation"),
6342 retval
, sig
->parameters
));
6343 body
.emit(ret(retval
));
6347 ir_function_signature
*
6348 builtin_builder::_read_invocation_intrinsic(const glsl_type
*type
)
6350 ir_variable
*value
= in_var(type
, "value");
6351 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6352 MAKE_INTRINSIC(type
, ir_intrinsic_read_invocation
, shader_ballot
,
6353 2, value
, invocation
);
6357 ir_function_signature
*
6358 builtin_builder::_read_invocation(const glsl_type
*type
)
6360 ir_variable
*value
= in_var(type
, "value");
6361 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6363 MAKE_SIG(type
, shader_ballot
, 2, value
, invocation
);
6364 ir_variable
*retval
= body
.make_temp(type
, "retval");
6366 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_invocation"),
6367 retval
, sig
->parameters
));
6368 body
.emit(ret(retval
));
6372 ir_function_signature
*
6373 builtin_builder::_invocation_interlock_intrinsic(builtin_available_predicate avail
,
6374 enum ir_intrinsic_id id
)
6376 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6380 ir_function_signature
*
6381 builtin_builder::_invocation_interlock(const char *intrinsic_name
,
6382 builtin_available_predicate avail
)
6384 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6385 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6386 NULL
, sig
->parameters
));
6390 ir_function_signature
*
6391 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
6392 const glsl_type
*type
)
6394 MAKE_INTRINSIC(type
, ir_intrinsic_shader_clock
, avail
, 0);
6398 ir_function_signature
*
6399 builtin_builder::_shader_clock(builtin_available_predicate avail
,
6400 const glsl_type
*type
)
6402 MAKE_SIG(type
, avail
, 0);
6404 ir_variable
*retval
= body
.make_temp(glsl_type::uvec2_type
, "clock_retval");
6406 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
6407 retval
, sig
->parameters
));
6409 if (type
== glsl_type::uint64_t_type
) {
6410 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, retval
)));
6412 body
.emit(ret(retval
));
6418 ir_function_signature
*
6419 builtin_builder::_vote_intrinsic(builtin_available_predicate avail
,
6420 enum ir_intrinsic_id id
)
6422 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6423 MAKE_INTRINSIC(glsl_type::bool_type
, id
, avail
, 1, value
);
6427 ir_function_signature
*
6428 builtin_builder::_vote(const char *intrinsic_name
,
6429 builtin_available_predicate avail
)
6431 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6433 MAKE_SIG(glsl_type::bool_type
, avail
, 1, value
);
6435 ir_variable
*retval
= body
.make_temp(glsl_type::bool_type
, "retval");
6437 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6438 retval
, sig
->parameters
));
6439 body
.emit(ret(retval
));
6445 /******************************************************************************/
6447 /* The singleton instance of builtin_builder. */
6448 static builtin_builder builtins
;
6449 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
6452 * External API (exposing the built-in module to the rest of the compiler):
6456 _mesa_glsl_initialize_builtin_functions()
6458 mtx_lock(&builtins_lock
);
6459 builtins
.initialize();
6460 mtx_unlock(&builtins_lock
);
6464 _mesa_glsl_release_builtin_functions()
6466 mtx_lock(&builtins_lock
);
6468 mtx_unlock(&builtins_lock
);
6471 ir_function_signature
*
6472 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
6473 const char *name
, exec_list
*actual_parameters
)
6475 ir_function_signature
*s
;
6476 mtx_lock(&builtins_lock
);
6477 s
= builtins
.find(state
, name
, actual_parameters
);
6478 mtx_unlock(&builtins_lock
);
6484 _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state
*state
, const char *name
)
6488 mtx_lock(&builtins_lock
);
6489 f
= builtins
.shader
->symbols
->get_function(name
);
6491 foreach_in_list(ir_function_signature
, sig
, &f
->signatures
) {
6492 if (sig
->is_builtin_available(state
)) {
6498 mtx_unlock(&builtins_lock
);
6504 _mesa_glsl_get_builtin_function_shader()
6506 return builtins
.shader
;
6511 * Get the function signature for main from a shader
6513 ir_function_signature
*
6514 _mesa_get_main_function_signature(glsl_symbol_table
*symbols
)
6516 ir_function
*const f
= symbols
->get_function("main");
6518 exec_list void_parameters
;
6520 /* Look for the 'void main()' signature and ensure that it's defined.
6521 * This keeps the linker from accidentally pick a shader that just
6522 * contains a prototype for main.
6524 * We don't have to check for multiple definitions of main (in multiple
6525 * shaders) because that would have already been caught above.
6527 ir_function_signature
*sig
=
6528 f
->matching_signature(NULL
, &void_parameters
, false);
6529 if ((sig
!= NULL
) && sig
->is_defined
) {