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
||
409 state
->EXT_texture_query_lod_enable
);
413 texture_gather_cube_map_array(const _mesa_glsl_parse_state
*state
)
415 return state
->is_version(400, 320) ||
416 state
->ARB_texture_gather_enable
||
417 state
->ARB_gpu_shader5_enable
||
418 state
->EXT_texture_cube_map_array_enable
||
419 state
->OES_texture_cube_map_array_enable
;
423 texture_texture4(const _mesa_glsl_parse_state
*state
)
425 return state
->AMD_texture_texture4_enable
;
429 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
431 return state
->is_version(400, 310) ||
432 state
->ARB_texture_gather_enable
||
433 state
->ARB_gpu_shader5_enable
;
436 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
437 * used for relaxation of const offset requirements.
440 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
442 return !state
->is_version(400, 320) &&
443 !state
->ARB_gpu_shader5_enable
&&
444 !state
->EXT_gpu_shader5_enable
&&
445 !state
->OES_gpu_shader5_enable
&&
446 (state
->ARB_texture_gather_enable
||
447 state
->is_version(0, 310));
450 /* Desktop GL or OES_standard_derivatives + fragment shader only */
452 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
454 return state
->stage
== MESA_SHADER_FRAGMENT
&&
455 (state
->is_version(110, 300) ||
456 state
->OES_standard_derivatives_enable
||
457 state
->ctx
->Const
.AllowGLSLRelaxedES
);
461 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
463 return state
->stage
== MESA_SHADER_FRAGMENT
&&
464 (state
->is_version(450, 0) ||
465 state
->ARB_derivative_control_enable
);
469 tex1d_lod(const _mesa_glsl_parse_state
*state
)
471 return !state
->es_shader
&& lod_exists_in_stage(state
);
474 /** True if sampler3D exists */
476 tex3d(const _mesa_glsl_parse_state
*state
)
478 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
479 * OES_texture_3D extension, and in GLSL ES 3.00.
481 return !state
->es_shader
||
482 state
->OES_texture_3D_enable
||
483 state
->language_version
>= 300;
487 fs_tex3d(const _mesa_glsl_parse_state
*state
)
489 return state
->stage
== MESA_SHADER_FRAGMENT
&&
490 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
494 tex3d_lod(const _mesa_glsl_parse_state
*state
)
496 return tex3d(state
) && lod_exists_in_stage(state
);
500 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
502 return state
->has_atomic_counters();
506 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
508 return state
->ARB_shader_atomic_counter_ops_enable
;
512 shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
514 return state
->ARB_shader_atomic_counter_ops_enable
|| v460_desktop(state
);
518 shader_ballot(const _mesa_glsl_parse_state
*state
)
520 return state
->ARB_shader_ballot_enable
;
524 supports_arb_fragment_shader_interlock(const _mesa_glsl_parse_state
*state
)
526 return state
->ARB_fragment_shader_interlock_enable
;
530 supports_nv_fragment_shader_interlock(const _mesa_glsl_parse_state
*state
)
532 return state
->NV_fragment_shader_interlock_enable
;
536 shader_clock(const _mesa_glsl_parse_state
*state
)
538 return state
->ARB_shader_clock_enable
;
542 shader_clock_int64(const _mesa_glsl_parse_state
*state
)
544 return state
->ARB_shader_clock_enable
&&
545 (state
->ARB_gpu_shader_int64_enable
||
546 state
->AMD_gpu_shader_int64_enable
);
550 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
552 return state
->has_shader_storage_buffer_objects();
556 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
558 return state
->AMD_shader_trinary_minmax_enable
;
562 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
564 return (state
->is_version(420, 310) ||
565 state
->ARB_shader_image_load_store_enable
);
569 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
571 return (state
->is_version(420, 320) ||
572 state
->ARB_shader_image_load_store_enable
||
573 state
->OES_shader_image_atomic_enable
);
577 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
579 return (state
->is_version(450, 320) ||
580 state
->ARB_ES3_1_compatibility_enable
||
581 state
->OES_shader_image_atomic_enable
||
582 state
->NV_shader_atomic_float_enable
);
586 shader_image_atomic_add_float(const _mesa_glsl_parse_state
*state
)
588 return state
->NV_shader_atomic_float_enable
;
592 shader_image_size(const _mesa_glsl_parse_state
*state
)
594 return state
->is_version(430, 310) ||
595 state
->ARB_shader_image_size_enable
;
599 shader_samples(const _mesa_glsl_parse_state
*state
)
601 return state
->is_version(450, 0) ||
602 state
->ARB_shader_texture_image_samples_enable
;
606 gs_streams(const _mesa_glsl_parse_state
*state
)
608 return gpu_shader5(state
) && gs_only(state
);
612 fp64(const _mesa_glsl_parse_state
*state
)
614 return state
->has_double();
618 int64(const _mesa_glsl_parse_state
*state
)
620 return state
->has_int64();
624 int64_fp64(const _mesa_glsl_parse_state
*state
)
626 return state
->has_int64() && state
->has_double();
630 compute_shader(const _mesa_glsl_parse_state
*state
)
632 return state
->stage
== MESA_SHADER_COMPUTE
;
636 compute_shader_supported(const _mesa_glsl_parse_state
*state
)
638 return state
->has_compute_shader();
642 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
644 return compute_shader(state
) || shader_storage_buffer_object(state
);
648 barrier_supported(const _mesa_glsl_parse_state
*state
)
650 return compute_shader(state
) ||
651 state
->stage
== MESA_SHADER_TESS_CTRL
;
655 vote(const _mesa_glsl_parse_state
*state
)
657 return state
->ARB_shader_group_vote_enable
;
661 vote_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
663 return state
->ARB_shader_group_vote_enable
|| v460_desktop(state
);
667 integer_functions_supported(const _mesa_glsl_parse_state
*state
)
669 return state
->extensions
->MESA_shader_integer_functions
;
673 NV_shader_atomic_float_supported(const _mesa_glsl_parse_state
*state
)
675 return state
->extensions
->NV_shader_atomic_float
;
679 shader_atomic_float_add(const _mesa_glsl_parse_state
*state
)
681 return state
->NV_shader_atomic_float_enable
;
685 shader_atomic_float_exchange(const _mesa_glsl_parse_state
*state
)
687 return state
->NV_shader_atomic_float_enable
||
688 state
->INTEL_shader_atomic_float_minmax_enable
;
692 INTEL_shader_atomic_float_minmax_supported(const _mesa_glsl_parse_state
*state
)
694 return state
->extensions
->INTEL_shader_atomic_float_minmax
;
698 shader_atomic_float_minmax(const _mesa_glsl_parse_state
*state
)
700 return state
->INTEL_shader_atomic_float_minmax_enable
;
704 /******************************************************************************/
709 * builtin_builder: A singleton object representing the core of the built-in
712 * It generates IR for every built-in function signature, and organizes them
715 class builtin_builder
{
722 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
723 const char *name
, exec_list
*actual_parameters
);
726 * A shader to hold all the built-in signatures; created by this module.
728 * This includes signatures for every built-in, regardless of version or
729 * enabled extensions. The availability predicate associated with each
730 * signature allows matching_signature() to filter out the irrelevant ones.
737 void create_shader();
738 void create_intrinsics();
739 void create_builtins();
742 * IR builder helpers:
744 * These convenience functions assist in emitting IR, but don't necessarily
745 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
748 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
749 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
750 ir_constant
*imm(float f
, unsigned vector_elements
=1);
751 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
752 ir_constant
*imm(int i
, unsigned vector_elements
=1);
753 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
754 ir_constant
*imm(double d
, unsigned vector_elements
=1);
755 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
756 ir_dereference_variable
*var_ref(ir_variable
*var
);
757 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
758 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
760 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
761 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
764 * Call function \param f with parameters specified as the linked
765 * list \param params of \c ir_variable objects. \param ret should
766 * point to the ir_variable that will hold the function return
767 * value, or be \c NULL if the function has void return type.
769 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
771 /** Create a new function and add the given signatures. */
772 void add_function(const char *name
, ...);
774 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
775 unsigned num_arguments
,
779 * Create a new image built-in function for all known image types.
780 * \p flags is a bitfield of \c image_function_flags flags.
782 void add_image_function(const char *name
,
783 const char *intrinsic_name
,
784 image_prototype_ctr prototype
,
785 unsigned num_arguments
,
787 enum ir_intrinsic_id id
);
790 * Create new functions for all known image built-ins and types.
791 * If \p glsl is \c true, use the GLSL built-in names and emit code
792 * to call into the actual compiler intrinsic. If \p glsl is
793 * false, emit a function prototype with no body for each image
796 void add_image_functions(bool glsl
);
798 ir_function_signature
*new_sig(const glsl_type
*return_type
,
799 builtin_available_predicate avail
,
800 int num_params
, ...);
803 * Function signature generators:
806 ir_function_signature
*unop(builtin_available_predicate avail
,
807 ir_expression_operation opcode
,
808 const glsl_type
*return_type
,
809 const glsl_type
*param_type
);
810 ir_function_signature
*binop(builtin_available_predicate avail
,
811 ir_expression_operation opcode
,
812 const glsl_type
*return_type
,
813 const glsl_type
*param0_type
,
814 const glsl_type
*param1_type
,
815 bool swap_operands
= false);
817 #define B0(X) ir_function_signature *_##X();
818 #define B1(X) ir_function_signature *_##X(const glsl_type *);
819 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
820 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
821 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
822 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
859 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
860 const glsl_type
*val_type
,
861 const glsl_type
*blend_type
);
871 BA1(doubleBitsToInt64
)
872 BA1(doubleBitsToUint64
)
873 BA1(int64BitsToDouble
)
874 BA1(uint64BitsToDouble
)
876 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
877 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
878 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
879 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
880 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
881 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
882 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
883 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
884 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
885 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
886 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
887 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
888 ir_function_signature
*_packInt2x32(builtin_available_predicate avail
);
889 ir_function_signature
*_unpackInt2x32(builtin_available_predicate avail
);
890 ir_function_signature
*_packUint2x32(builtin_available_predicate avail
);
891 ir_function_signature
*_unpackUint2x32(builtin_available_predicate avail
);
904 BA1(determinant_mat2
);
905 BA1(determinant_mat3
);
906 BA1(determinant_mat4
);
914 BA1(greaterThanEqual
);
923 /** Flags to _texture() */
924 #define TEX_PROJECT 1
926 #define TEX_COMPONENT 4
927 #define TEX_OFFSET_NONCONST 8
928 #define TEX_OFFSET_ARRAY 16
930 ir_function_signature
*_texture(ir_texture_opcode opcode
,
931 builtin_available_predicate avail
,
932 const glsl_type
*return_type
,
933 const glsl_type
*sampler_type
,
934 const glsl_type
*coord_type
,
936 BA1(textureCubeArrayShadow
);
937 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
938 const glsl_type
*return_type
,
939 const glsl_type
*sampler_type
,
940 const glsl_type
*coord_type
,
941 const glsl_type
*offset_type
= NULL
);
945 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
946 const glsl_type
*stream_type
);
947 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
948 const glsl_type
*stream_type
);
951 BA2(textureQueryLod
);
952 BA1(textureQueryLevels
);
953 BA2(textureSamplesIdentical
);
981 B1(interpolateAtCentroid
)
982 B1(interpolateAtOffset
)
983 B1(interpolateAtSample
)
985 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
,
986 enum ir_intrinsic_id id
);
987 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
,
988 enum ir_intrinsic_id id
);
989 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
,
990 enum ir_intrinsic_id id
);
991 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
992 builtin_available_predicate avail
);
993 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
994 builtin_available_predicate avail
);
995 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
996 builtin_available_predicate avail
);
998 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
999 const glsl_type
*type
,
1000 enum ir_intrinsic_id id
);
1001 ir_function_signature
*_atomic_op2(const char *intrinsic
,
1002 builtin_available_predicate avail
,
1003 const glsl_type
*type
);
1004 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
1005 const glsl_type
*type
,
1006 enum ir_intrinsic_id id
);
1007 ir_function_signature
*_atomic_op3(const char *intrinsic
,
1008 builtin_available_predicate avail
,
1009 const glsl_type
*type
);
1015 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
1016 unsigned num_arguments
,
1018 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
1019 unsigned num_arguments
,
1021 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
1022 unsigned num_arguments
,
1024 ir_function_signature
*_image(image_prototype_ctr prototype
,
1025 const glsl_type
*image_type
,
1026 const char *intrinsic_name
,
1027 unsigned num_arguments
,
1029 enum ir_intrinsic_id id
);
1031 ir_function_signature
*_memory_barrier_intrinsic(
1032 builtin_available_predicate avail
,
1033 enum ir_intrinsic_id id
);
1034 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
1035 builtin_available_predicate avail
);
1037 ir_function_signature
*_ballot_intrinsic();
1038 ir_function_signature
*_ballot();
1039 ir_function_signature
*_read_first_invocation_intrinsic(const glsl_type
*type
);
1040 ir_function_signature
*_read_first_invocation(const glsl_type
*type
);
1041 ir_function_signature
*_read_invocation_intrinsic(const glsl_type
*type
);
1042 ir_function_signature
*_read_invocation(const glsl_type
*type
);
1045 ir_function_signature
*_invocation_interlock_intrinsic(
1046 builtin_available_predicate avail
,
1047 enum ir_intrinsic_id id
);
1048 ir_function_signature
*_invocation_interlock(
1049 const char *intrinsic_name
,
1050 builtin_available_predicate avail
);
1052 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
1053 const glsl_type
*type
);
1054 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
1055 const glsl_type
*type
);
1057 ir_function_signature
*_vote_intrinsic(builtin_available_predicate avail
,
1058 enum ir_intrinsic_id id
);
1059 ir_function_signature
*_vote(const char *intrinsic_name
,
1060 builtin_available_predicate avail
);
1071 enum image_function_flags
{
1072 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
1073 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
1074 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
1075 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
1076 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
1077 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
1078 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
1079 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
1080 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8),
1081 IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
= (1 << 9),
1084 } /* anonymous namespace */
1087 * Core builtin_builder functionality:
1090 builtin_builder::builtin_builder()
1096 builtin_builder::~builtin_builder()
1098 ralloc_free(mem_ctx
);
1101 ir_function_signature
*
1102 builtin_builder::find(_mesa_glsl_parse_state
*state
,
1103 const char *name
, exec_list
*actual_parameters
)
1105 /* The shader currently being compiled requested a built-in function;
1106 * it needs to link against builtin_builder::shader in order to get them.
1108 * Even if we don't find a matching signature, we still need to do this so
1109 * that the "no matching signature" error will list potential candidates
1110 * from the available built-ins.
1112 state
->uses_builtin_functions
= true;
1114 ir_function
*f
= shader
->symbols
->get_function(name
);
1118 ir_function_signature
*sig
=
1119 f
->matching_signature(state
, actual_parameters
, true);
1127 builtin_builder::initialize()
1129 /* If already initialized, don't do it again. */
1130 if (mem_ctx
!= NULL
)
1133 mem_ctx
= ralloc_context(NULL
);
1135 create_intrinsics();
1140 builtin_builder::release()
1142 ralloc_free(mem_ctx
);
1145 ralloc_free(shader
);
1150 builtin_builder::create_shader()
1152 /* The target doesn't actually matter. There's no target for generic
1153 * GLSL utility code that could be linked against any stage, so just
1154 * arbitrarily pick GL_VERTEX_SHADER.
1156 shader
= _mesa_new_shader(0, MESA_SHADER_VERTEX
);
1157 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
1163 * Create ir_function and ir_function_signature objects for each
1167 builtin_builder::create_intrinsics()
1169 add_function("__intrinsic_atomic_read",
1170 _atomic_counter_intrinsic(shader_atomic_counters
,
1171 ir_intrinsic_atomic_counter_read
),
1173 add_function("__intrinsic_atomic_increment",
1174 _atomic_counter_intrinsic(shader_atomic_counters
,
1175 ir_intrinsic_atomic_counter_increment
),
1177 add_function("__intrinsic_atomic_predecrement",
1178 _atomic_counter_intrinsic(shader_atomic_counters
,
1179 ir_intrinsic_atomic_counter_predecrement
),
1182 add_function("__intrinsic_atomic_add",
1183 _atomic_intrinsic2(buffer_atomics_supported
,
1184 glsl_type::uint_type
,
1185 ir_intrinsic_generic_atomic_add
),
1186 _atomic_intrinsic2(buffer_atomics_supported
,
1187 glsl_type::int_type
,
1188 ir_intrinsic_generic_atomic_add
),
1189 _atomic_intrinsic2(NV_shader_atomic_float_supported
,
1190 glsl_type::float_type
,
1191 ir_intrinsic_generic_atomic_add
),
1192 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1193 ir_intrinsic_atomic_counter_add
),
1195 add_function("__intrinsic_atomic_min",
1196 _atomic_intrinsic2(buffer_atomics_supported
,
1197 glsl_type::uint_type
,
1198 ir_intrinsic_generic_atomic_min
),
1199 _atomic_intrinsic2(buffer_atomics_supported
,
1200 glsl_type::int_type
,
1201 ir_intrinsic_generic_atomic_min
),
1202 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported
,
1203 glsl_type::float_type
,
1204 ir_intrinsic_generic_atomic_min
),
1205 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1206 ir_intrinsic_atomic_counter_min
),
1208 add_function("__intrinsic_atomic_max",
1209 _atomic_intrinsic2(buffer_atomics_supported
,
1210 glsl_type::uint_type
,
1211 ir_intrinsic_generic_atomic_max
),
1212 _atomic_intrinsic2(buffer_atomics_supported
,
1213 glsl_type::int_type
,
1214 ir_intrinsic_generic_atomic_max
),
1215 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported
,
1216 glsl_type::float_type
,
1217 ir_intrinsic_generic_atomic_max
),
1218 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1219 ir_intrinsic_atomic_counter_max
),
1221 add_function("__intrinsic_atomic_and",
1222 _atomic_intrinsic2(buffer_atomics_supported
,
1223 glsl_type::uint_type
,
1224 ir_intrinsic_generic_atomic_and
),
1225 _atomic_intrinsic2(buffer_atomics_supported
,
1226 glsl_type::int_type
,
1227 ir_intrinsic_generic_atomic_and
),
1228 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1229 ir_intrinsic_atomic_counter_and
),
1231 add_function("__intrinsic_atomic_or",
1232 _atomic_intrinsic2(buffer_atomics_supported
,
1233 glsl_type::uint_type
,
1234 ir_intrinsic_generic_atomic_or
),
1235 _atomic_intrinsic2(buffer_atomics_supported
,
1236 glsl_type::int_type
,
1237 ir_intrinsic_generic_atomic_or
),
1238 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1239 ir_intrinsic_atomic_counter_or
),
1241 add_function("__intrinsic_atomic_xor",
1242 _atomic_intrinsic2(buffer_atomics_supported
,
1243 glsl_type::uint_type
,
1244 ir_intrinsic_generic_atomic_xor
),
1245 _atomic_intrinsic2(buffer_atomics_supported
,
1246 glsl_type::int_type
,
1247 ir_intrinsic_generic_atomic_xor
),
1248 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1249 ir_intrinsic_atomic_counter_xor
),
1251 add_function("__intrinsic_atomic_exchange",
1252 _atomic_intrinsic2(buffer_atomics_supported
,
1253 glsl_type::uint_type
,
1254 ir_intrinsic_generic_atomic_exchange
),
1255 _atomic_intrinsic2(buffer_atomics_supported
,
1256 glsl_type::int_type
,
1257 ir_intrinsic_generic_atomic_exchange
),
1258 _atomic_intrinsic2(NV_shader_atomic_float_supported
,
1259 glsl_type::float_type
,
1260 ir_intrinsic_generic_atomic_exchange
),
1261 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1262 ir_intrinsic_atomic_counter_exchange
),
1264 add_function("__intrinsic_atomic_comp_swap",
1265 _atomic_intrinsic3(buffer_atomics_supported
,
1266 glsl_type::uint_type
,
1267 ir_intrinsic_generic_atomic_comp_swap
),
1268 _atomic_intrinsic3(buffer_atomics_supported
,
1269 glsl_type::int_type
,
1270 ir_intrinsic_generic_atomic_comp_swap
),
1271 _atomic_intrinsic3(INTEL_shader_atomic_float_minmax_supported
,
1272 glsl_type::float_type
,
1273 ir_intrinsic_generic_atomic_comp_swap
),
1274 _atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop
,
1275 ir_intrinsic_atomic_counter_comp_swap
),
1278 add_image_functions(false);
1280 add_function("__intrinsic_memory_barrier",
1281 _memory_barrier_intrinsic(shader_image_load_store
,
1282 ir_intrinsic_memory_barrier
),
1284 add_function("__intrinsic_group_memory_barrier",
1285 _memory_barrier_intrinsic(compute_shader
,
1286 ir_intrinsic_group_memory_barrier
),
1288 add_function("__intrinsic_memory_barrier_atomic_counter",
1289 _memory_barrier_intrinsic(compute_shader_supported
,
1290 ir_intrinsic_memory_barrier_atomic_counter
),
1292 add_function("__intrinsic_memory_barrier_buffer",
1293 _memory_barrier_intrinsic(compute_shader_supported
,
1294 ir_intrinsic_memory_barrier_buffer
),
1296 add_function("__intrinsic_memory_barrier_image",
1297 _memory_barrier_intrinsic(compute_shader_supported
,
1298 ir_intrinsic_memory_barrier_image
),
1300 add_function("__intrinsic_memory_barrier_shared",
1301 _memory_barrier_intrinsic(compute_shader
,
1302 ir_intrinsic_memory_barrier_shared
),
1305 add_function("__intrinsic_begin_invocation_interlock",
1306 _invocation_interlock_intrinsic(
1307 supports_arb_fragment_shader_interlock
,
1308 ir_intrinsic_begin_invocation_interlock
), NULL
);
1310 add_function("__intrinsic_end_invocation_interlock",
1311 _invocation_interlock_intrinsic(
1312 supports_arb_fragment_shader_interlock
,
1313 ir_intrinsic_end_invocation_interlock
), NULL
);
1315 add_function("__intrinsic_shader_clock",
1316 _shader_clock_intrinsic(shader_clock
,
1317 glsl_type::uvec2_type
),
1320 add_function("__intrinsic_vote_all",
1321 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_all
),
1323 add_function("__intrinsic_vote_any",
1324 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_any
),
1326 add_function("__intrinsic_vote_eq",
1327 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_eq
),
1330 add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL
);
1332 add_function("__intrinsic_read_invocation",
1333 _read_invocation_intrinsic(glsl_type::float_type
),
1334 _read_invocation_intrinsic(glsl_type::vec2_type
),
1335 _read_invocation_intrinsic(glsl_type::vec3_type
),
1336 _read_invocation_intrinsic(glsl_type::vec4_type
),
1338 _read_invocation_intrinsic(glsl_type::int_type
),
1339 _read_invocation_intrinsic(glsl_type::ivec2_type
),
1340 _read_invocation_intrinsic(glsl_type::ivec3_type
),
1341 _read_invocation_intrinsic(glsl_type::ivec4_type
),
1343 _read_invocation_intrinsic(glsl_type::uint_type
),
1344 _read_invocation_intrinsic(glsl_type::uvec2_type
),
1345 _read_invocation_intrinsic(glsl_type::uvec3_type
),
1346 _read_invocation_intrinsic(glsl_type::uvec4_type
),
1349 add_function("__intrinsic_read_first_invocation",
1350 _read_first_invocation_intrinsic(glsl_type::float_type
),
1351 _read_first_invocation_intrinsic(glsl_type::vec2_type
),
1352 _read_first_invocation_intrinsic(glsl_type::vec3_type
),
1353 _read_first_invocation_intrinsic(glsl_type::vec4_type
),
1355 _read_first_invocation_intrinsic(glsl_type::int_type
),
1356 _read_first_invocation_intrinsic(glsl_type::ivec2_type
),
1357 _read_first_invocation_intrinsic(glsl_type::ivec3_type
),
1358 _read_first_invocation_intrinsic(glsl_type::ivec4_type
),
1360 _read_first_invocation_intrinsic(glsl_type::uint_type
),
1361 _read_first_invocation_intrinsic(glsl_type::uvec2_type
),
1362 _read_first_invocation_intrinsic(glsl_type::uvec3_type
),
1363 _read_first_invocation_intrinsic(glsl_type::uvec4_type
),
1369 * Create ir_function and ir_function_signature objects for each built-in.
1371 * Contains a list of every available built-in.
1374 builtin_builder::create_builtins()
1377 add_function(#NAME, \
1378 _##NAME(glsl_type::float_type), \
1379 _##NAME(glsl_type::vec2_type), \
1380 _##NAME(glsl_type::vec3_type), \
1381 _##NAME(glsl_type::vec4_type), \
1385 add_function(#NAME, \
1386 _##NAME(always_available, glsl_type::float_type), \
1387 _##NAME(always_available, glsl_type::vec2_type), \
1388 _##NAME(always_available, glsl_type::vec3_type), \
1389 _##NAME(always_available, glsl_type::vec4_type), \
1390 _##NAME(fp64, glsl_type::double_type), \
1391 _##NAME(fp64, glsl_type::dvec2_type), \
1392 _##NAME(fp64, glsl_type::dvec3_type), \
1393 _##NAME(fp64, glsl_type::dvec4_type), \
1396 #define FD130(NAME) \
1397 add_function(#NAME, \
1398 _##NAME(v130, glsl_type::float_type), \
1399 _##NAME(v130, glsl_type::vec2_type), \
1400 _##NAME(v130, glsl_type::vec3_type), \
1401 _##NAME(v130, glsl_type::vec4_type), \
1402 _##NAME(fp64, glsl_type::double_type), \
1403 _##NAME(fp64, glsl_type::dvec2_type), \
1404 _##NAME(fp64, glsl_type::dvec3_type), \
1405 _##NAME(fp64, glsl_type::dvec4_type), \
1408 #define FDGS5(NAME) \
1409 add_function(#NAME, \
1410 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1411 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1412 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1413 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1414 _##NAME(fp64, glsl_type::double_type), \
1415 _##NAME(fp64, glsl_type::dvec2_type), \
1416 _##NAME(fp64, glsl_type::dvec3_type), \
1417 _##NAME(fp64, glsl_type::dvec4_type), \
1421 add_function(#NAME, \
1422 _##NAME(glsl_type::float_type), \
1423 _##NAME(glsl_type::vec2_type), \
1424 _##NAME(glsl_type::vec3_type), \
1425 _##NAME(glsl_type::vec4_type), \
1426 _##NAME(glsl_type::int_type), \
1427 _##NAME(glsl_type::ivec2_type), \
1428 _##NAME(glsl_type::ivec3_type), \
1429 _##NAME(glsl_type::ivec4_type), \
1432 #define FI64(NAME) \
1433 add_function(#NAME, \
1434 _##NAME(always_available, glsl_type::float_type), \
1435 _##NAME(always_available, glsl_type::vec2_type), \
1436 _##NAME(always_available, glsl_type::vec3_type), \
1437 _##NAME(always_available, glsl_type::vec4_type), \
1438 _##NAME(always_available, glsl_type::int_type), \
1439 _##NAME(always_available, glsl_type::ivec2_type), \
1440 _##NAME(always_available, glsl_type::ivec3_type), \
1441 _##NAME(always_available, glsl_type::ivec4_type), \
1442 _##NAME(fp64, glsl_type::double_type), \
1443 _##NAME(fp64, glsl_type::dvec2_type), \
1444 _##NAME(fp64, glsl_type::dvec3_type), \
1445 _##NAME(fp64, glsl_type::dvec4_type), \
1446 _##NAME(int64, glsl_type::int64_t_type), \
1447 _##NAME(int64, glsl_type::i64vec2_type), \
1448 _##NAME(int64, glsl_type::i64vec3_type), \
1449 _##NAME(int64, glsl_type::i64vec4_type), \
1452 #define FIUD_VEC(NAME) \
1453 add_function(#NAME, \
1454 _##NAME(always_available, glsl_type::vec2_type), \
1455 _##NAME(always_available, glsl_type::vec3_type), \
1456 _##NAME(always_available, glsl_type::vec4_type), \
1458 _##NAME(always_available, glsl_type::ivec2_type), \
1459 _##NAME(always_available, glsl_type::ivec3_type), \
1460 _##NAME(always_available, glsl_type::ivec4_type), \
1462 _##NAME(v130, glsl_type::uvec2_type), \
1463 _##NAME(v130, glsl_type::uvec3_type), \
1464 _##NAME(v130, glsl_type::uvec4_type), \
1465 _##NAME(fp64, glsl_type::dvec2_type), \
1466 _##NAME(fp64, glsl_type::dvec3_type), \
1467 _##NAME(fp64, glsl_type::dvec4_type), \
1468 _##NAME(int64, glsl_type::int64_t_type), \
1469 _##NAME(int64, glsl_type::i64vec2_type), \
1470 _##NAME(int64, glsl_type::i64vec3_type), \
1471 _##NAME(int64, glsl_type::i64vec4_type), \
1472 _##NAME(int64, glsl_type::uint64_t_type), \
1473 _##NAME(int64, glsl_type::u64vec2_type), \
1474 _##NAME(int64, glsl_type::u64vec3_type), \
1475 _##NAME(int64, glsl_type::u64vec4_type), \
1479 add_function(#NAME, \
1480 _##NAME(glsl_type::int_type), \
1481 _##NAME(glsl_type::ivec2_type), \
1482 _##NAME(glsl_type::ivec3_type), \
1483 _##NAME(glsl_type::ivec4_type), \
1485 _##NAME(glsl_type::uint_type), \
1486 _##NAME(glsl_type::uvec2_type), \
1487 _##NAME(glsl_type::uvec3_type), \
1488 _##NAME(glsl_type::uvec4_type), \
1491 #define FIUBD_VEC(NAME) \
1492 add_function(#NAME, \
1493 _##NAME(always_available, glsl_type::vec2_type), \
1494 _##NAME(always_available, glsl_type::vec3_type), \
1495 _##NAME(always_available, glsl_type::vec4_type), \
1497 _##NAME(always_available, glsl_type::ivec2_type), \
1498 _##NAME(always_available, glsl_type::ivec3_type), \
1499 _##NAME(always_available, glsl_type::ivec4_type), \
1501 _##NAME(v130, glsl_type::uvec2_type), \
1502 _##NAME(v130, glsl_type::uvec3_type), \
1503 _##NAME(v130, glsl_type::uvec4_type), \
1505 _##NAME(always_available, glsl_type::bvec2_type), \
1506 _##NAME(always_available, glsl_type::bvec3_type), \
1507 _##NAME(always_available, glsl_type::bvec4_type), \
1509 _##NAME(fp64, glsl_type::dvec2_type), \
1510 _##NAME(fp64, glsl_type::dvec3_type), \
1511 _##NAME(fp64, glsl_type::dvec4_type), \
1512 _##NAME(int64, glsl_type::int64_t_type), \
1513 _##NAME(int64, glsl_type::i64vec2_type), \
1514 _##NAME(int64, glsl_type::i64vec3_type), \
1515 _##NAME(int64, glsl_type::i64vec4_type), \
1516 _##NAME(int64, glsl_type::uint64_t_type), \
1517 _##NAME(int64, glsl_type::u64vec2_type), \
1518 _##NAME(int64, glsl_type::u64vec3_type), \
1519 _##NAME(int64, glsl_type::u64vec4_type), \
1522 #define FIUD2_MIXED(NAME) \
1523 add_function(#NAME, \
1524 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1525 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1526 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1527 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1529 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1530 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1531 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1533 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1534 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1535 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1536 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1538 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1539 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1540 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1542 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1543 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1544 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1545 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1547 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1548 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1549 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1551 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1552 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1553 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1554 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1555 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1556 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1557 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1559 _##NAME(int64, glsl_type::int64_t_type, glsl_type::int64_t_type), \
1560 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::int64_t_type), \
1561 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::int64_t_type), \
1562 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::int64_t_type), \
1563 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::i64vec2_type), \
1564 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::i64vec3_type), \
1565 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::i64vec4_type), \
1566 _##NAME(int64, glsl_type::uint64_t_type, glsl_type::uint64_t_type), \
1567 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::uint64_t_type), \
1568 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::uint64_t_type), \
1569 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::uint64_t_type), \
1570 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::u64vec2_type), \
1571 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::u64vec3_type), \
1572 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::u64vec4_type), \
1583 add_function("atan",
1584 _atan(glsl_type::float_type
),
1585 _atan(glsl_type::vec2_type
),
1586 _atan(glsl_type::vec3_type
),
1587 _atan(glsl_type::vec4_type
),
1588 _atan2(glsl_type::float_type
),
1589 _atan2(glsl_type::vec2_type
),
1590 _atan2(glsl_type::vec3_type
),
1591 _atan2(glsl_type::vec4_type
),
1617 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1618 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1619 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1620 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1622 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1623 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1624 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1626 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1627 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1628 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1629 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1631 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1632 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1633 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1643 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1644 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1645 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1646 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1648 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1649 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1650 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1652 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1653 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1654 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1655 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1657 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1658 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1659 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1661 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1662 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1663 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1664 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1666 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1667 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1668 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1669 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1671 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1672 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1673 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1674 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1676 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1677 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1678 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1679 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1681 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1682 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1683 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1684 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1686 _mix_sel(int64
, glsl_type::int64_t_type
, glsl_type::bool_type
),
1687 _mix_sel(int64
, glsl_type::i64vec2_type
, glsl_type::bvec2_type
),
1688 _mix_sel(int64
, glsl_type::i64vec3_type
, glsl_type::bvec3_type
),
1689 _mix_sel(int64
, glsl_type::i64vec4_type
, glsl_type::bvec4_type
),
1691 _mix_sel(int64
, glsl_type::uint64_t_type
, glsl_type::bool_type
),
1692 _mix_sel(int64
, glsl_type::u64vec2_type
, glsl_type::bvec2_type
),
1693 _mix_sel(int64
, glsl_type::u64vec3_type
, glsl_type::bvec3_type
),
1694 _mix_sel(int64
, glsl_type::u64vec4_type
, glsl_type::bvec4_type
),
1697 add_function("step",
1698 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1699 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1700 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1701 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1703 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1704 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1705 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1706 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1707 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1708 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1709 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1711 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1712 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1713 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1716 add_function("smoothstep",
1717 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1718 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1719 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1720 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1722 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1723 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1724 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1725 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1726 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1727 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1728 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1730 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1731 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1732 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1740 add_function("intBitsToFloat",
1741 _intBitsToFloat(glsl_type::int_type
),
1742 _intBitsToFloat(glsl_type::ivec2_type
),
1743 _intBitsToFloat(glsl_type::ivec3_type
),
1744 _intBitsToFloat(glsl_type::ivec4_type
),
1746 add_function("uintBitsToFloat",
1747 _uintBitsToFloat(glsl_type::uint_type
),
1748 _uintBitsToFloat(glsl_type::uvec2_type
),
1749 _uintBitsToFloat(glsl_type::uvec3_type
),
1750 _uintBitsToFloat(glsl_type::uvec4_type
),
1753 add_function("doubleBitsToInt64",
1754 _doubleBitsToInt64(int64_fp64
, glsl_type::double_type
),
1755 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec2_type
),
1756 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec3_type
),
1757 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec4_type
),
1760 add_function("doubleBitsToUint64",
1761 _doubleBitsToUint64(int64_fp64
, glsl_type::double_type
),
1762 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec2_type
),
1763 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec3_type
),
1764 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec4_type
),
1767 add_function("int64BitsToDouble",
1768 _int64BitsToDouble(int64_fp64
, glsl_type::int64_t_type
),
1769 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec2_type
),
1770 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec3_type
),
1771 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec4_type
),
1774 add_function("uint64BitsToDouble",
1775 _uint64BitsToDouble(int64_fp64
, glsl_type::uint64_t_type
),
1776 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec2_type
),
1777 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec3_type
),
1778 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec4_type
),
1781 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1782 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1783 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1784 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1785 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1786 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1787 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1788 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1789 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1790 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1791 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1792 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1794 add_function("packInt2x32", _packInt2x32(int64
), NULL
);
1795 add_function("unpackInt2x32", _unpackInt2x32(int64
), NULL
);
1796 add_function("packUint2x32", _packUint2x32(int64
), NULL
);
1797 add_function("unpackUint2x32", _unpackUint2x32(int64
), NULL
);
1803 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1804 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1807 add_function("ftransform", _ftransform(), NULL
);
1812 add_function("matrixCompMult",
1813 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1814 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1815 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1816 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1817 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1818 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1819 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1820 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1821 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1822 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1823 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1824 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1825 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1826 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1827 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1828 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1829 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1830 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1832 add_function("outerProduct",
1833 _outerProduct(v120
, glsl_type::mat2_type
),
1834 _outerProduct(v120
, glsl_type::mat3_type
),
1835 _outerProduct(v120
, glsl_type::mat4_type
),
1836 _outerProduct(v120
, glsl_type::mat2x3_type
),
1837 _outerProduct(v120
, glsl_type::mat2x4_type
),
1838 _outerProduct(v120
, glsl_type::mat3x2_type
),
1839 _outerProduct(v120
, glsl_type::mat3x4_type
),
1840 _outerProduct(v120
, glsl_type::mat4x2_type
),
1841 _outerProduct(v120
, glsl_type::mat4x3_type
),
1842 _outerProduct(fp64
, glsl_type::dmat2_type
),
1843 _outerProduct(fp64
, glsl_type::dmat3_type
),
1844 _outerProduct(fp64
, glsl_type::dmat4_type
),
1845 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1846 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1847 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1848 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1849 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1850 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1852 add_function("determinant",
1853 _determinant_mat2(v120
, glsl_type::mat2_type
),
1854 _determinant_mat3(v120
, glsl_type::mat3_type
),
1855 _determinant_mat4(v120
, glsl_type::mat4_type
),
1856 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1857 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1858 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1861 add_function("inverse",
1862 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1863 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1864 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1865 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1866 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1867 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1869 add_function("transpose",
1870 _transpose(v120
, glsl_type::mat2_type
),
1871 _transpose(v120
, glsl_type::mat3_type
),
1872 _transpose(v120
, glsl_type::mat4_type
),
1873 _transpose(v120
, glsl_type::mat2x3_type
),
1874 _transpose(v120
, glsl_type::mat2x4_type
),
1875 _transpose(v120
, glsl_type::mat3x2_type
),
1876 _transpose(v120
, glsl_type::mat3x4_type
),
1877 _transpose(v120
, glsl_type::mat4x2_type
),
1878 _transpose(v120
, glsl_type::mat4x3_type
),
1879 _transpose(fp64
, glsl_type::dmat2_type
),
1880 _transpose(fp64
, glsl_type::dmat3_type
),
1881 _transpose(fp64
, glsl_type::dmat4_type
),
1882 _transpose(fp64
, glsl_type::dmat2x3_type
),
1883 _transpose(fp64
, glsl_type::dmat2x4_type
),
1884 _transpose(fp64
, glsl_type::dmat3x2_type
),
1885 _transpose(fp64
, glsl_type::dmat3x4_type
),
1886 _transpose(fp64
, glsl_type::dmat4x2_type
),
1887 _transpose(fp64
, glsl_type::dmat4x3_type
),
1890 FIUD_VEC(lessThanEqual
)
1891 FIUD_VEC(greaterThan
)
1892 FIUD_VEC(greaterThanEqual
)
1897 _any(glsl_type::bvec2_type
),
1898 _any(glsl_type::bvec3_type
),
1899 _any(glsl_type::bvec4_type
),
1903 _all(glsl_type::bvec2_type
),
1904 _all(glsl_type::bvec3_type
),
1905 _all(glsl_type::bvec4_type
),
1909 _not(glsl_type::bvec2_type
),
1910 _not(glsl_type::bvec3_type
),
1911 _not(glsl_type::bvec4_type
),
1914 add_function("textureSize",
1915 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1916 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1917 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1919 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1920 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1921 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1923 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1924 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1925 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1927 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1928 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1929 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1931 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1932 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1933 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1935 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1936 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1937 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1938 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1939 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1940 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1942 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1943 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1945 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1946 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1947 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1948 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1950 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1951 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1952 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1953 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1955 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1956 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1957 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1958 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1959 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1960 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1962 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1963 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1964 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1967 add_function("textureSamples",
1968 _textureSamples(shader_samples
, glsl_type::sampler2DMS_type
),
1969 _textureSamples(shader_samples
, glsl_type::isampler2DMS_type
),
1970 _textureSamples(shader_samples
, glsl_type::usampler2DMS_type
),
1972 _textureSamples(shader_samples
, glsl_type::sampler2DMSArray_type
),
1973 _textureSamples(shader_samples
, glsl_type::isampler2DMSArray_type
),
1974 _textureSamples(shader_samples
, glsl_type::usampler2DMSArray_type
),
1977 add_function("texture",
1978 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1979 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1980 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1982 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1983 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1984 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1986 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1987 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1988 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1990 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1991 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1992 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1994 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1995 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1996 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1998 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1999 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2000 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2002 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2003 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2004 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2006 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2007 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2008 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2010 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2011 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2012 /* samplerCubeArrayShadow is special; it has an extra parameter
2013 * for the shadow comparator since there is no vec5 type.
2015 _textureCubeArrayShadow(texture_cube_map_array
, glsl_type::samplerCubeArrayShadow_type
),
2017 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2018 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2019 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2021 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2023 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2025 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2026 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2027 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2029 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2030 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2031 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2033 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2034 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2035 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2037 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2038 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2039 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2041 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2042 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2043 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2045 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2046 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2047 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2049 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2050 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2051 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2053 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2054 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2055 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2057 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2060 add_function("textureLod",
2061 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2062 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2063 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2065 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2066 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2067 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2069 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2070 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2071 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2073 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2074 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2075 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2077 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2078 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2080 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2081 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2082 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2084 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2085 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2086 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2088 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2089 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2090 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2092 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2095 add_function("textureOffset",
2096 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2097 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2098 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2100 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2101 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2102 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2104 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2105 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2106 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2108 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2109 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2110 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2112 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2114 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2115 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2117 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2118 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2119 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2121 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2122 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2123 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2125 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2126 /* The next one was forgotten in GLSL 1.30 spec. It's from
2127 * EXT_gpu_shader4 originally. It was added in 4.30 with the
2128 * wrong syntax. This was corrected in 4.40. 4.30 indicates
2129 * that it was intended to be included previously, so allow it
2132 _texture(ir_tex
, v130_desktop
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2134 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2135 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2136 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2138 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2139 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2140 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2142 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2143 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2144 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2146 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2147 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2149 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2150 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2151 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2153 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2154 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2155 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2157 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2160 add_function("textureProj",
2161 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2162 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2163 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2164 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2165 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2166 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2168 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2169 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2170 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2171 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2172 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2173 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2175 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2176 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2177 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2179 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2180 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2182 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2183 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2184 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2185 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2187 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2188 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2189 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2190 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2192 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2194 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2195 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2196 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2197 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2198 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2199 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2201 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2202 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2203 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2204 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2205 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2206 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2208 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2209 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2210 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2212 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2213 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2216 add_function("texelFetch",
2217 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
2218 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
2219 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
2221 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
2222 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
2223 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
2225 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
2226 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
2227 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
2229 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
2230 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
2231 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
2233 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
2234 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
2235 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
2237 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
2238 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
2239 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
2241 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
2242 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
2243 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
2245 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2246 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2247 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2249 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2250 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2251 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2253 _texelFetch(texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::ivec2_type
),
2258 add_function("texelFetchOffset",
2259 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2260 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2261 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2263 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2264 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2265 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2267 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2268 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2269 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2271 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2272 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2273 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2275 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2276 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2277 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2279 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2280 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2281 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2285 add_function("textureProjOffset",
2286 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2287 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2288 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2289 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2290 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2291 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2293 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2294 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2295 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2296 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2297 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2298 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2300 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2301 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2302 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2304 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2305 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2307 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2308 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2309 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2310 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2311 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2312 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2314 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2316 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2317 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2318 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2319 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2320 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2321 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2323 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2324 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2325 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2326 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2327 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2328 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2330 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2331 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2332 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2334 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2335 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2338 add_function("textureLodOffset",
2339 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2340 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2341 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2343 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2344 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2345 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2347 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2348 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2349 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2351 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2352 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2354 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2355 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2356 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2358 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2359 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2360 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2362 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2365 add_function("textureProjLod",
2366 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2367 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2368 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2369 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2370 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2371 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2373 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2374 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2375 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2376 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2377 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2378 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2380 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2381 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2382 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2384 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2385 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2388 add_function("textureProjLodOffset",
2389 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2390 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2391 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2392 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2393 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2394 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2396 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2397 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2398 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2399 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2400 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2401 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2403 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2404 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2405 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2407 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2408 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2411 add_function("textureGrad",
2412 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2413 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2414 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2416 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2417 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2418 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2420 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2421 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2422 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2424 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2425 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2426 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2428 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2429 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2430 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2432 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2434 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2435 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2436 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2438 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2439 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2440 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2442 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2443 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2444 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2446 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2447 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2448 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2450 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2451 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2454 add_function("textureGradOffset",
2455 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2456 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2457 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2459 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2460 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2461 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2463 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2464 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2465 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2467 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2468 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2469 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2471 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2473 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2474 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2476 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2477 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2478 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2480 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2481 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2482 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2484 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2485 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2488 add_function("textureProjGrad",
2489 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2490 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2491 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2492 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2493 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2494 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2496 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2497 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2498 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2499 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2500 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2501 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2503 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2504 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2505 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2507 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2508 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2509 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2510 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2511 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2512 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2514 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2516 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2517 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2520 add_function("textureProjGradOffset",
2521 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2522 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2523 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2524 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2525 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2526 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2528 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2529 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2530 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2531 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2532 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2533 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2535 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2536 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2537 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2539 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2540 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2541 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2542 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2543 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2544 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2546 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2548 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2549 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2552 add_function("EmitVertex", _EmitVertex(), NULL
);
2553 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2554 add_function("EmitStreamVertex",
2555 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2556 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2558 add_function("EndStreamPrimitive",
2559 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2560 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2562 add_function("barrier", _barrier(), NULL
);
2564 add_function("textureQueryLOD",
2565 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2566 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2567 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2569 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2570 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2571 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2573 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2574 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2575 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2577 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2578 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2579 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2581 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2582 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2583 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2585 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2586 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2587 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2589 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2590 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2591 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2593 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2594 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2595 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2596 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2597 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2598 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2601 add_function("textureQueryLod",
2602 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2603 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2604 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2606 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2607 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2608 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2610 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2611 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2612 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2614 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2615 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2616 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2618 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2619 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2620 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2622 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2623 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2624 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2626 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2627 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2628 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2630 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2631 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2632 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2633 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2634 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2635 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2638 add_function("textureQueryLevels",
2639 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1D_type
),
2640 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2D_type
),
2641 _textureQueryLevels(texture_query_levels
, glsl_type::sampler3D_type
),
2642 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCube_type
),
2643 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArray_type
),
2644 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArray_type
),
2645 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArray_type
),
2646 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DShadow_type
),
2647 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DShadow_type
),
2648 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeShadow_type
),
2649 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArrayShadow_type
),
2650 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArrayShadow_type
),
2651 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArrayShadow_type
),
2653 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1D_type
),
2654 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2D_type
),
2655 _textureQueryLevels(texture_query_levels
, glsl_type::isampler3D_type
),
2656 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCube_type
),
2657 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1DArray_type
),
2658 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2DArray_type
),
2659 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCubeArray_type
),
2661 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1D_type
),
2662 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2D_type
),
2663 _textureQueryLevels(texture_query_levels
, glsl_type::usampler3D_type
),
2664 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCube_type
),
2665 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1DArray_type
),
2666 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2DArray_type
),
2667 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCubeArray_type
),
2671 add_function("textureSamplesIdenticalEXT",
2672 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2673 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2674 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2676 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2677 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2678 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2681 add_function("texture1D",
2682 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2683 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2686 add_function("texture1DArray",
2687 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2688 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2691 add_function("texture1DProj",
2692 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2693 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2694 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2695 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2698 add_function("texture1DLod",
2699 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2702 add_function("texture1DArrayLod",
2703 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2706 add_function("texture1DProjLod",
2707 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2708 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2711 add_function("texture2D",
2712 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2713 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2714 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2717 add_function("texture2DArray",
2718 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2719 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2722 add_function("texture2DProj",
2723 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2724 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2725 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2726 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2727 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2728 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2731 add_function("texture2DLod",
2732 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2735 add_function("texture2DArrayLod",
2736 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2739 add_function("texture2DProjLod",
2740 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2741 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2744 add_function("texture3D",
2745 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2746 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2749 add_function("texture3DProj",
2750 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2751 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2754 add_function("texture3DLod",
2755 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2758 add_function("texture3DProjLod",
2759 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2762 add_function("textureCube",
2763 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2764 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2767 add_function("textureCubeLod",
2768 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2771 add_function("texture2DRect",
2772 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2775 add_function("texture2DRectProj",
2776 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2777 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2780 add_function("shadow1D",
2781 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2782 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2785 add_function("shadow1DArray",
2786 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2787 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2790 add_function("shadow2D",
2791 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2792 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2795 add_function("shadow2DArray",
2796 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2797 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2800 add_function("shadow1DProj",
2801 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2802 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2805 add_function("shadow2DProj",
2806 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2807 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2810 add_function("shadow1DLod",
2811 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2814 add_function("shadow2DLod",
2815 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2818 add_function("shadow1DArrayLod",
2819 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2822 add_function("shadow1DProjLod",
2823 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2826 add_function("shadow2DProjLod",
2827 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2830 add_function("shadow2DRect",
2831 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2834 add_function("shadow2DRectProj",
2835 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2838 add_function("texture1DGradARB",
2839 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2842 add_function("texture1DProjGradARB",
2843 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2844 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2847 add_function("texture2DGradARB",
2848 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2851 add_function("texture2DProjGradARB",
2852 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2853 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2856 add_function("texture3DGradARB",
2857 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2860 add_function("texture3DProjGradARB",
2861 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2864 add_function("textureCubeGradARB",
2865 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2868 add_function("shadow1DGradARB",
2869 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2872 add_function("shadow1DProjGradARB",
2873 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2876 add_function("shadow2DGradARB",
2877 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2880 add_function("shadow2DProjGradARB",
2881 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2884 add_function("texture2DRectGradARB",
2885 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2888 add_function("texture2DRectProjGradARB",
2889 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2890 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2893 add_function("shadow2DRectGradARB",
2894 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2897 add_function("shadow2DRectProjGradARB",
2898 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2901 add_function("texture4",
2902 _texture(ir_tg4
, texture_texture4
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2905 add_function("textureGather",
2906 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2907 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2908 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2910 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2911 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2912 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2914 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2915 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2916 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2918 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2919 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2920 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2922 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2923 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2924 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2926 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2927 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2928 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2930 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2931 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2932 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2934 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2935 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2936 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2938 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2939 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2940 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2942 _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
),
2943 _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
),
2944 _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
),
2946 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2947 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2948 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2949 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2950 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2953 add_function("textureGatherOffset",
2954 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2955 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2956 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2958 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2959 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2960 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2962 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2963 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2964 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2966 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2967 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2968 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2970 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2971 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2972 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2974 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2975 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2976 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2978 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2979 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2980 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2982 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2983 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2984 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2986 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2987 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2988 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2990 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2991 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2992 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2994 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2995 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2996 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2998 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2999 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
3002 add_function("textureGatherOffsets",
3003 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3004 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3005 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3007 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3008 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3009 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3011 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3012 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3013 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3015 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3016 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3017 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3019 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3020 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3021 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3023 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3024 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3025 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3027 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3028 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3029 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3054 add_function("ldexp",
3055 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
3056 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
3057 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
3058 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
3059 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
3060 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
3061 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
3062 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
3065 add_function("frexp",
3066 _frexp(glsl_type::float_type
, glsl_type::int_type
),
3067 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
3068 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
3069 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
3070 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
3071 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
3072 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
3073 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
3075 add_function("uaddCarry",
3076 _uaddCarry(glsl_type::uint_type
),
3077 _uaddCarry(glsl_type::uvec2_type
),
3078 _uaddCarry(glsl_type::uvec3_type
),
3079 _uaddCarry(glsl_type::uvec4_type
),
3081 add_function("usubBorrow",
3082 _usubBorrow(glsl_type::uint_type
),
3083 _usubBorrow(glsl_type::uvec2_type
),
3084 _usubBorrow(glsl_type::uvec3_type
),
3085 _usubBorrow(glsl_type::uvec4_type
),
3087 add_function("imulExtended",
3088 _mulExtended(glsl_type::int_type
),
3089 _mulExtended(glsl_type::ivec2_type
),
3090 _mulExtended(glsl_type::ivec3_type
),
3091 _mulExtended(glsl_type::ivec4_type
),
3093 add_function("umulExtended",
3094 _mulExtended(glsl_type::uint_type
),
3095 _mulExtended(glsl_type::uvec2_type
),
3096 _mulExtended(glsl_type::uvec3_type
),
3097 _mulExtended(glsl_type::uvec4_type
),
3099 add_function("interpolateAtCentroid",
3100 _interpolateAtCentroid(glsl_type::float_type
),
3101 _interpolateAtCentroid(glsl_type::vec2_type
),
3102 _interpolateAtCentroid(glsl_type::vec3_type
),
3103 _interpolateAtCentroid(glsl_type::vec4_type
),
3105 add_function("interpolateAtOffset",
3106 _interpolateAtOffset(glsl_type::float_type
),
3107 _interpolateAtOffset(glsl_type::vec2_type
),
3108 _interpolateAtOffset(glsl_type::vec3_type
),
3109 _interpolateAtOffset(glsl_type::vec4_type
),
3111 add_function("interpolateAtSample",
3112 _interpolateAtSample(glsl_type::float_type
),
3113 _interpolateAtSample(glsl_type::vec2_type
),
3114 _interpolateAtSample(glsl_type::vec3_type
),
3115 _interpolateAtSample(glsl_type::vec4_type
),
3118 add_function("atomicCounter",
3119 _atomic_counter_op("__intrinsic_atomic_read",
3120 shader_atomic_counters
),
3122 add_function("atomicCounterIncrement",
3123 _atomic_counter_op("__intrinsic_atomic_increment",
3124 shader_atomic_counters
),
3126 add_function("atomicCounterDecrement",
3127 _atomic_counter_op("__intrinsic_atomic_predecrement",
3128 shader_atomic_counters
),
3131 add_function("atomicCounterAddARB",
3132 _atomic_counter_op1("__intrinsic_atomic_add",
3133 shader_atomic_counter_ops
),
3135 add_function("atomicCounterSubtractARB",
3136 _atomic_counter_op1("__intrinsic_atomic_sub",
3137 shader_atomic_counter_ops
),
3139 add_function("atomicCounterMinARB",
3140 _atomic_counter_op1("__intrinsic_atomic_min",
3141 shader_atomic_counter_ops
),
3143 add_function("atomicCounterMaxARB",
3144 _atomic_counter_op1("__intrinsic_atomic_max",
3145 shader_atomic_counter_ops
),
3147 add_function("atomicCounterAndARB",
3148 _atomic_counter_op1("__intrinsic_atomic_and",
3149 shader_atomic_counter_ops
),
3151 add_function("atomicCounterOrARB",
3152 _atomic_counter_op1("__intrinsic_atomic_or",
3153 shader_atomic_counter_ops
),
3155 add_function("atomicCounterXorARB",
3156 _atomic_counter_op1("__intrinsic_atomic_xor",
3157 shader_atomic_counter_ops
),
3159 add_function("atomicCounterExchangeARB",
3160 _atomic_counter_op1("__intrinsic_atomic_exchange",
3161 shader_atomic_counter_ops
),
3163 add_function("atomicCounterCompSwapARB",
3164 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3165 shader_atomic_counter_ops
),
3168 add_function("atomicCounterAdd",
3169 _atomic_counter_op1("__intrinsic_atomic_add",
3172 add_function("atomicCounterSubtract",
3173 _atomic_counter_op1("__intrinsic_atomic_sub",
3176 add_function("atomicCounterMin",
3177 _atomic_counter_op1("__intrinsic_atomic_min",
3180 add_function("atomicCounterMax",
3181 _atomic_counter_op1("__intrinsic_atomic_max",
3184 add_function("atomicCounterAnd",
3185 _atomic_counter_op1("__intrinsic_atomic_and",
3188 add_function("atomicCounterOr",
3189 _atomic_counter_op1("__intrinsic_atomic_or",
3192 add_function("atomicCounterXor",
3193 _atomic_counter_op1("__intrinsic_atomic_xor",
3196 add_function("atomicCounterExchange",
3197 _atomic_counter_op1("__intrinsic_atomic_exchange",
3200 add_function("atomicCounterCompSwap",
3201 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3205 add_function("atomicAdd",
3206 _atomic_op2("__intrinsic_atomic_add",
3207 buffer_atomics_supported
,
3208 glsl_type::uint_type
),
3209 _atomic_op2("__intrinsic_atomic_add",
3210 buffer_atomics_supported
,
3211 glsl_type::int_type
),
3212 _atomic_op2("__intrinsic_atomic_add",
3213 shader_atomic_float_add
,
3214 glsl_type::float_type
),
3216 add_function("atomicMin",
3217 _atomic_op2("__intrinsic_atomic_min",
3218 buffer_atomics_supported
,
3219 glsl_type::uint_type
),
3220 _atomic_op2("__intrinsic_atomic_min",
3221 buffer_atomics_supported
,
3222 glsl_type::int_type
),
3223 _atomic_op2("__intrinsic_atomic_min",
3224 shader_atomic_float_minmax
,
3225 glsl_type::float_type
),
3227 add_function("atomicMax",
3228 _atomic_op2("__intrinsic_atomic_max",
3229 buffer_atomics_supported
,
3230 glsl_type::uint_type
),
3231 _atomic_op2("__intrinsic_atomic_max",
3232 buffer_atomics_supported
,
3233 glsl_type::int_type
),
3234 _atomic_op2("__intrinsic_atomic_max",
3235 shader_atomic_float_minmax
,
3236 glsl_type::float_type
),
3238 add_function("atomicAnd",
3239 _atomic_op2("__intrinsic_atomic_and",
3240 buffer_atomics_supported
,
3241 glsl_type::uint_type
),
3242 _atomic_op2("__intrinsic_atomic_and",
3243 buffer_atomics_supported
,
3244 glsl_type::int_type
),
3246 add_function("atomicOr",
3247 _atomic_op2("__intrinsic_atomic_or",
3248 buffer_atomics_supported
,
3249 glsl_type::uint_type
),
3250 _atomic_op2("__intrinsic_atomic_or",
3251 buffer_atomics_supported
,
3252 glsl_type::int_type
),
3254 add_function("atomicXor",
3255 _atomic_op2("__intrinsic_atomic_xor",
3256 buffer_atomics_supported
,
3257 glsl_type::uint_type
),
3258 _atomic_op2("__intrinsic_atomic_xor",
3259 buffer_atomics_supported
,
3260 glsl_type::int_type
),
3262 add_function("atomicExchange",
3263 _atomic_op2("__intrinsic_atomic_exchange",
3264 buffer_atomics_supported
,
3265 glsl_type::uint_type
),
3266 _atomic_op2("__intrinsic_atomic_exchange",
3267 buffer_atomics_supported
,
3268 glsl_type::int_type
),
3269 _atomic_op2("__intrinsic_atomic_exchange",
3270 shader_atomic_float_exchange
,
3271 glsl_type::float_type
),
3273 add_function("atomicCompSwap",
3274 _atomic_op3("__intrinsic_atomic_comp_swap",
3275 buffer_atomics_supported
,
3276 glsl_type::uint_type
),
3277 _atomic_op3("__intrinsic_atomic_comp_swap",
3278 buffer_atomics_supported
,
3279 glsl_type::int_type
),
3280 _atomic_op3("__intrinsic_atomic_comp_swap",
3281 shader_atomic_float_minmax
,
3282 glsl_type::float_type
),
3285 add_function("min3",
3286 _min3(glsl_type::float_type
),
3287 _min3(glsl_type::vec2_type
),
3288 _min3(glsl_type::vec3_type
),
3289 _min3(glsl_type::vec4_type
),
3291 _min3(glsl_type::int_type
),
3292 _min3(glsl_type::ivec2_type
),
3293 _min3(glsl_type::ivec3_type
),
3294 _min3(glsl_type::ivec4_type
),
3296 _min3(glsl_type::uint_type
),
3297 _min3(glsl_type::uvec2_type
),
3298 _min3(glsl_type::uvec3_type
),
3299 _min3(glsl_type::uvec4_type
),
3302 add_function("max3",
3303 _max3(glsl_type::float_type
),
3304 _max3(glsl_type::vec2_type
),
3305 _max3(glsl_type::vec3_type
),
3306 _max3(glsl_type::vec4_type
),
3308 _max3(glsl_type::int_type
),
3309 _max3(glsl_type::ivec2_type
),
3310 _max3(glsl_type::ivec3_type
),
3311 _max3(glsl_type::ivec4_type
),
3313 _max3(glsl_type::uint_type
),
3314 _max3(glsl_type::uvec2_type
),
3315 _max3(glsl_type::uvec3_type
),
3316 _max3(glsl_type::uvec4_type
),
3319 add_function("mid3",
3320 _mid3(glsl_type::float_type
),
3321 _mid3(glsl_type::vec2_type
),
3322 _mid3(glsl_type::vec3_type
),
3323 _mid3(glsl_type::vec4_type
),
3325 _mid3(glsl_type::int_type
),
3326 _mid3(glsl_type::ivec2_type
),
3327 _mid3(glsl_type::ivec3_type
),
3328 _mid3(glsl_type::ivec4_type
),
3330 _mid3(glsl_type::uint_type
),
3331 _mid3(glsl_type::uvec2_type
),
3332 _mid3(glsl_type::uvec3_type
),
3333 _mid3(glsl_type::uvec4_type
),
3336 add_image_functions(true);
3338 add_function("memoryBarrier",
3339 _memory_barrier("__intrinsic_memory_barrier",
3340 shader_image_load_store
),
3342 add_function("groupMemoryBarrier",
3343 _memory_barrier("__intrinsic_group_memory_barrier",
3346 add_function("memoryBarrierAtomicCounter",
3347 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
3348 compute_shader_supported
),
3350 add_function("memoryBarrierBuffer",
3351 _memory_barrier("__intrinsic_memory_barrier_buffer",
3352 compute_shader_supported
),
3354 add_function("memoryBarrierImage",
3355 _memory_barrier("__intrinsic_memory_barrier_image",
3356 compute_shader_supported
),
3358 add_function("memoryBarrierShared",
3359 _memory_barrier("__intrinsic_memory_barrier_shared",
3363 add_function("ballotARB", _ballot(), NULL
);
3365 add_function("readInvocationARB",
3366 _read_invocation(glsl_type::float_type
),
3367 _read_invocation(glsl_type::vec2_type
),
3368 _read_invocation(glsl_type::vec3_type
),
3369 _read_invocation(glsl_type::vec4_type
),
3371 _read_invocation(glsl_type::int_type
),
3372 _read_invocation(glsl_type::ivec2_type
),
3373 _read_invocation(glsl_type::ivec3_type
),
3374 _read_invocation(glsl_type::ivec4_type
),
3376 _read_invocation(glsl_type::uint_type
),
3377 _read_invocation(glsl_type::uvec2_type
),
3378 _read_invocation(glsl_type::uvec3_type
),
3379 _read_invocation(glsl_type::uvec4_type
),
3382 add_function("readFirstInvocationARB",
3383 _read_first_invocation(glsl_type::float_type
),
3384 _read_first_invocation(glsl_type::vec2_type
),
3385 _read_first_invocation(glsl_type::vec3_type
),
3386 _read_first_invocation(glsl_type::vec4_type
),
3388 _read_first_invocation(glsl_type::int_type
),
3389 _read_first_invocation(glsl_type::ivec2_type
),
3390 _read_first_invocation(glsl_type::ivec3_type
),
3391 _read_first_invocation(glsl_type::ivec4_type
),
3393 _read_first_invocation(glsl_type::uint_type
),
3394 _read_first_invocation(glsl_type::uvec2_type
),
3395 _read_first_invocation(glsl_type::uvec3_type
),
3396 _read_first_invocation(glsl_type::uvec4_type
),
3399 add_function("clock2x32ARB",
3400 _shader_clock(shader_clock
,
3401 glsl_type::uvec2_type
),
3404 add_function("clockARB",
3405 _shader_clock(shader_clock_int64
,
3406 glsl_type::uint64_t_type
),
3409 add_function("beginInvocationInterlockARB",
3410 _invocation_interlock(
3411 "__intrinsic_begin_invocation_interlock",
3412 supports_arb_fragment_shader_interlock
),
3415 add_function("endInvocationInterlockARB",
3416 _invocation_interlock(
3417 "__intrinsic_end_invocation_interlock",
3418 supports_arb_fragment_shader_interlock
),
3421 add_function("beginInvocationInterlockNV",
3422 _invocation_interlock(
3423 "__intrinsic_begin_invocation_interlock",
3424 supports_nv_fragment_shader_interlock
),
3427 add_function("endInvocationInterlockNV",
3428 _invocation_interlock(
3429 "__intrinsic_end_invocation_interlock",
3430 supports_nv_fragment_shader_interlock
),
3433 add_function("anyInvocationARB",
3434 _vote("__intrinsic_vote_any", vote
),
3437 add_function("allInvocationsARB",
3438 _vote("__intrinsic_vote_all", vote
),
3441 add_function("allInvocationsEqualARB",
3442 _vote("__intrinsic_vote_eq", vote
),
3445 add_function("anyInvocation",
3446 _vote("__intrinsic_vote_any", v460_desktop
),
3449 add_function("allInvocations",
3450 _vote("__intrinsic_vote_all", v460_desktop
),
3453 add_function("allInvocationsEqual",
3454 _vote("__intrinsic_vote_eq", v460_desktop
),
3457 add_function("__builtin_idiv64",
3458 generate_ir::idiv64(mem_ctx
, integer_functions_supported
),
3461 add_function("__builtin_imod64",
3462 generate_ir::imod64(mem_ctx
, integer_functions_supported
),
3465 add_function("__builtin_sign64",
3466 generate_ir::sign64(mem_ctx
, integer_functions_supported
),
3469 add_function("__builtin_udiv64",
3470 generate_ir::udiv64(mem_ctx
, integer_functions_supported
),
3473 add_function("__builtin_umod64",
3474 generate_ir::umod64(mem_ctx
, integer_functions_supported
),
3477 add_function("__builtin_umul64",
3478 generate_ir::umul64(mem_ctx
, integer_functions_supported
),
3489 builtin_builder::add_function(const char *name
, ...)
3493 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3497 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
3503 stuff
.push_tail(sig
);
3504 validate_ir_tree(&stuff
);
3507 f
->add_signature(sig
);
3511 shader
->symbols
->add_function(f
);
3515 builtin_builder::add_image_function(const char *name
,
3516 const char *intrinsic_name
,
3517 image_prototype_ctr prototype
,
3518 unsigned num_arguments
,
3520 enum ir_intrinsic_id intrinsic_id
)
3522 static const glsl_type
*const types
[] = {
3523 glsl_type::image1D_type
,
3524 glsl_type::image2D_type
,
3525 glsl_type::image3D_type
,
3526 glsl_type::image2DRect_type
,
3527 glsl_type::imageCube_type
,
3528 glsl_type::imageBuffer_type
,
3529 glsl_type::image1DArray_type
,
3530 glsl_type::image2DArray_type
,
3531 glsl_type::imageCubeArray_type
,
3532 glsl_type::image2DMS_type
,
3533 glsl_type::image2DMSArray_type
,
3534 glsl_type::iimage1D_type
,
3535 glsl_type::iimage2D_type
,
3536 glsl_type::iimage3D_type
,
3537 glsl_type::iimage2DRect_type
,
3538 glsl_type::iimageCube_type
,
3539 glsl_type::iimageBuffer_type
,
3540 glsl_type::iimage1DArray_type
,
3541 glsl_type::iimage2DArray_type
,
3542 glsl_type::iimageCubeArray_type
,
3543 glsl_type::iimage2DMS_type
,
3544 glsl_type::iimage2DMSArray_type
,
3545 glsl_type::uimage1D_type
,
3546 glsl_type::uimage2D_type
,
3547 glsl_type::uimage3D_type
,
3548 glsl_type::uimage2DRect_type
,
3549 glsl_type::uimageCube_type
,
3550 glsl_type::uimageBuffer_type
,
3551 glsl_type::uimage1DArray_type
,
3552 glsl_type::uimage2DArray_type
,
3553 glsl_type::uimageCubeArray_type
,
3554 glsl_type::uimage2DMS_type
,
3555 glsl_type::uimage2DMSArray_type
3558 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3560 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3561 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3562 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3563 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3564 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3565 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3566 num_arguments
, flags
, intrinsic_id
));
3569 shader
->symbols
->add_function(f
);
3573 builtin_builder::add_image_functions(bool glsl
)
3575 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3577 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3578 "__intrinsic_image_load",
3579 &builtin_builder::_image_prototype
, 0,
3580 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3581 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3582 IMAGE_FUNCTION_READ_ONLY
),
3583 ir_intrinsic_image_load
);
3585 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3586 "__intrinsic_image_store",
3587 &builtin_builder::_image_prototype
, 1,
3588 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3589 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3590 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3591 IMAGE_FUNCTION_WRITE_ONLY
),
3592 ir_intrinsic_image_store
);
3594 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3596 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3597 "__intrinsic_image_atomic_add",
3598 &builtin_builder::_image_prototype
, 1,
3599 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
|
3600 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3601 ir_intrinsic_image_atomic_add
);
3603 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3604 "__intrinsic_image_atomic_min",
3605 &builtin_builder::_image_prototype
, 1, atom_flags
,
3606 ir_intrinsic_image_atomic_min
);
3608 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3609 "__intrinsic_image_atomic_max",
3610 &builtin_builder::_image_prototype
, 1, atom_flags
,
3611 ir_intrinsic_image_atomic_max
);
3613 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3614 "__intrinsic_image_atomic_and",
3615 &builtin_builder::_image_prototype
, 1, atom_flags
,
3616 ir_intrinsic_image_atomic_and
);
3618 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3619 "__intrinsic_image_atomic_or",
3620 &builtin_builder::_image_prototype
, 1, atom_flags
,
3621 ir_intrinsic_image_atomic_or
);
3623 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3624 "__intrinsic_image_atomic_xor",
3625 &builtin_builder::_image_prototype
, 1, atom_flags
,
3626 ir_intrinsic_image_atomic_xor
);
3628 add_image_function((glsl
? "imageAtomicExchange" :
3629 "__intrinsic_image_atomic_exchange"),
3630 "__intrinsic_image_atomic_exchange",
3631 &builtin_builder::_image_prototype
, 1,
3632 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3633 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3634 ir_intrinsic_image_atomic_exchange
);
3636 add_image_function((glsl
? "imageAtomicCompSwap" :
3637 "__intrinsic_image_atomic_comp_swap"),
3638 "__intrinsic_image_atomic_comp_swap",
3639 &builtin_builder::_image_prototype
, 2, atom_flags
,
3640 ir_intrinsic_image_atomic_comp_swap
);
3642 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3643 "__intrinsic_image_size",
3644 &builtin_builder::_image_size_prototype
, 1,
3645 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
,
3646 ir_intrinsic_image_size
);
3648 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3649 "__intrinsic_image_samples",
3650 &builtin_builder::_image_samples_prototype
, 1,
3651 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3652 IMAGE_FUNCTION_MS_ONLY
,
3653 ir_intrinsic_image_samples
);
3657 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3659 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3663 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3665 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3669 builtin_builder::imm(bool b
, unsigned vector_elements
)
3671 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3675 builtin_builder::imm(float f
, unsigned vector_elements
)
3677 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3681 builtin_builder::imm(int i
, unsigned vector_elements
)
3683 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3687 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3689 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3693 builtin_builder::imm(double d
, unsigned vector_elements
)
3695 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3699 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3701 return new(mem_ctx
) ir_constant(type
, &data
);
3704 #define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)
3706 ir_dereference_variable
*
3707 builtin_builder::var_ref(ir_variable
*var
)
3709 return new(mem_ctx
) ir_dereference_variable(var
);
3712 ir_dereference_array
*
3713 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3715 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3718 /** Return an element of a matrix */
3720 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3722 return swizzle(array_ref(var
, column
), row
, 1);
3726 * Implementations of built-in functions:
3729 ir_function_signature
*
3730 builtin_builder::new_sig(const glsl_type
*return_type
,
3731 builtin_available_predicate avail
,
3737 ir_function_signature
*sig
=
3738 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3741 va_start(ap
, num_params
);
3742 for (int i
= 0; i
< num_params
; i
++) {
3743 plist
.push_tail(va_arg(ap
, ir_variable
*));
3747 sig
->replace_parameters(&plist
);
3751 #define MAKE_SIG(return_type, avail, ...) \
3752 ir_function_signature *sig = \
3753 new_sig(return_type, avail, __VA_ARGS__); \
3754 ir_factory body(&sig->body, mem_ctx); \
3755 sig->is_defined = true;
3757 #define MAKE_INTRINSIC(return_type, id, avail, ...) \
3758 ir_function_signature *sig = \
3759 new_sig(return_type, avail, __VA_ARGS__); \
3760 sig->intrinsic_id = id;
3762 ir_function_signature
*
3763 builtin_builder::unop(builtin_available_predicate avail
,
3764 ir_expression_operation opcode
,
3765 const glsl_type
*return_type
,
3766 const glsl_type
*param_type
)
3768 ir_variable
*x
= in_var(param_type
, "x");
3769 MAKE_SIG(return_type
, avail
, 1, x
);
3770 body
.emit(ret(expr(opcode
, x
)));
3774 #define UNOP(NAME, OPCODE, AVAIL) \
3775 ir_function_signature * \
3776 builtin_builder::_##NAME(const glsl_type *type) \
3778 return unop(&AVAIL, OPCODE, type, type); \
3781 #define UNOPA(NAME, OPCODE) \
3782 ir_function_signature * \
3783 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3785 return unop(avail, OPCODE, type, type); \
3788 ir_function_signature
*
3789 builtin_builder::binop(builtin_available_predicate avail
,
3790 ir_expression_operation opcode
,
3791 const glsl_type
*return_type
,
3792 const glsl_type
*param0_type
,
3793 const glsl_type
*param1_type
,
3796 ir_variable
*x
= in_var(param0_type
, "x");
3797 ir_variable
*y
= in_var(param1_type
, "y");
3798 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3801 body
.emit(ret(expr(opcode
, y
, x
)));
3803 body
.emit(ret(expr(opcode
, x
, y
)));
3808 #define BINOP(NAME, OPCODE, AVAIL) \
3809 ir_function_signature * \
3810 builtin_builder::_##NAME(const glsl_type *return_type, \
3811 const glsl_type *param0_type, \
3812 const glsl_type *param1_type) \
3814 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3818 * Angle and Trigonometry Functions @{
3821 ir_function_signature
*
3822 builtin_builder::_radians(const glsl_type
*type
)
3824 ir_variable
*degrees
= in_var(type
, "degrees");
3825 MAKE_SIG(type
, always_available
, 1, degrees
);
3826 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3830 ir_function_signature
*
3831 builtin_builder::_degrees(const glsl_type
*type
)
3833 ir_variable
*radians
= in_var(type
, "radians");
3834 MAKE_SIG(type
, always_available
, 1, radians
);
3835 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3839 UNOP(sin
, ir_unop_sin
, always_available
)
3840 UNOP(cos
, ir_unop_cos
, always_available
)
3842 ir_function_signature
*
3843 builtin_builder::_tan(const glsl_type
*type
)
3845 ir_variable
*theta
= in_var(type
, "theta");
3846 MAKE_SIG(type
, always_available
, 1, theta
);
3847 body
.emit(ret(div(sin(theta
), cos(theta
))));
3852 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3856 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3859 add(imm(M_PI_4f
- 1.0f
),
3862 mul(abs(x
), imm(p1
))))))))));
3866 * Generate a ir_call to a function with a set of parameters
3868 * The input \c params can either be a list of \c ir_variable or a list of
3869 * \c ir_dereference_variable. In the latter case, all nodes will be removed
3870 * from \c params and used directly as the parameters to the generated
3874 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3876 exec_list actual_params
;
3878 foreach_in_list_safe(ir_instruction
, ir
, ¶ms
) {
3879 ir_dereference_variable
*d
= ir
->as_dereference_variable();
3882 actual_params
.push_tail(d
);
3884 ir_variable
*var
= ir
->as_variable();
3885 assert(var
!= NULL
);
3886 actual_params
.push_tail(var_ref(var
));
3890 ir_function_signature
*sig
=
3891 f
->exact_matching_signature(NULL
, &actual_params
);
3895 ir_dereference_variable
*deref
=
3896 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3898 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3901 ir_function_signature
*
3902 builtin_builder::_asin(const glsl_type
*type
)
3904 ir_variable
*x
= in_var(type
, "x");
3905 MAKE_SIG(type
, always_available
, 1, x
);
3907 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3912 ir_function_signature
*
3913 builtin_builder::_acos(const glsl_type
*type
)
3915 ir_variable
*x
= in_var(type
, "x");
3916 MAKE_SIG(type
, always_available
, 1, x
);
3918 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3923 ir_function_signature
*
3924 builtin_builder::_atan2(const glsl_type
*type
)
3926 const unsigned n
= type
->vector_elements
;
3927 ir_variable
*y
= in_var(type
, "y");
3928 ir_variable
*x
= in_var(type
, "x");
3929 MAKE_SIG(type
, always_available
, 2, y
, x
);
3931 /* If we're on the left half-plane rotate the coordinates π/2 clock-wise
3932 * for the y=0 discontinuity to end up aligned with the vertical
3933 * discontinuity of atan(s/t) along t=0. This also makes sure that we
3934 * don't attempt to divide by zero along the vertical line, which may give
3935 * unspecified results on non-GLSL 4.1-capable hardware.
3937 ir_variable
*flip
= body
.make_temp(glsl_type::bvec(n
), "flip");
3938 body
.emit(assign(flip
, gequal(imm(0.0f
, n
), x
)));
3939 ir_variable
*s
= body
.make_temp(type
, "s");
3940 body
.emit(assign(s
, csel(flip
, abs(x
), y
)));
3941 ir_variable
*t
= body
.make_temp(type
, "t");
3942 body
.emit(assign(t
, csel(flip
, y
, abs(x
))));
3944 /* If the magnitude of the denominator exceeds some huge value, scale down
3945 * the arguments in order to prevent the reciprocal operation from flushing
3946 * its result to zero, which would cause precision problems, and for s
3947 * infinite would cause us to return a NaN instead of the correct finite
3950 * If fmin and fmax are respectively the smallest and largest positive
3951 * normalized floating point values representable by the implementation,
3952 * the constants below should be in agreement with:
3955 * scale <= 1 / fmin / fmax (for |t| >= huge)
3957 * In addition scale should be a negative power of two in order to avoid
3958 * loss of precision. The values chosen below should work for most usual
3959 * floating point representations with at least the dynamic range of ATI's
3960 * 24-bit representation.
3962 ir_constant
*huge
= imm(1e18f
, n
);
3963 ir_variable
*scale
= body
.make_temp(type
, "scale");
3964 body
.emit(assign(scale
, csel(gequal(abs(t
), huge
),
3965 imm(0.25f
, n
), imm(1.0f
, n
))));
3966 ir_variable
*rcp_scaled_t
= body
.make_temp(type
, "rcp_scaled_t");
3967 body
.emit(assign(rcp_scaled_t
, rcp(mul(t
, scale
))));
3968 ir_expression
*s_over_t
= mul(mul(s
, scale
), rcp_scaled_t
);
3970 /* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily
3971 * that ∞/∞ = 1) in order to comply with the rather artificial rules
3972 * inherited from IEEE 754-2008, namely:
3974 * "atan2(±∞, −∞) is ±3π/4
3975 * atan2(±∞, +∞) is ±π/4"
3977 * Note that this is inconsistent with the rules for the neighborhood of
3978 * zero that are based on iterated limits:
3980 * "atan2(±0, −0) is ±π
3981 * atan2(±0, +0) is ±0"
3983 * but GLSL specifically allows implementations to deviate from IEEE rules
3984 * at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as
3987 ir_expression
*tan
= csel(equal(abs(x
), abs(y
)),
3988 imm(1.0f
, n
), abs(s_over_t
));
3990 /* Calculate the arctangent and fix up the result if we had flipped the
3991 * coordinate system.
3993 ir_variable
*arc
= body
.make_temp(type
, "arc");
3994 do_atan(body
, type
, arc
, tan
);
3995 body
.emit(assign(arc
, add(arc
, mul(b2f(flip
), imm(M_PI_2f
)))));
3997 /* Rather convoluted calculation of the sign of the result. When x < 0 we
3998 * cannot use fsign because we need to be able to distinguish between
3999 * negative and positive zero. Unfortunately we cannot use bitwise
4000 * arithmetic tricks either because of back-ends without integer support.
4001 * When x >= 0 rcp_scaled_t will always be non-negative so this won't be
4002 * able to distinguish between negative and positive zero, but we don't
4003 * care because atan2 is continuous along the whole positive y = 0
4004 * half-line, so it won't affect the result significantly.
4006 body
.emit(ret(csel(less(min2(y
, rcp_scaled_t
), imm(0.0f
, n
)),
4013 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
4016 * range-reduction, first step:
4018 * / y_over_x if |y_over_x| <= 1.0;
4020 * \ 1.0 / y_over_x otherwise
4022 ir_variable
*x
= body
.make_temp(type
, "atan_x");
4023 body
.emit(assign(x
, div(min2(abs(y_over_x
),
4029 * approximate atan by evaluating polynomial:
4031 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
4032 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
4033 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
4035 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
4036 body
.emit(assign(tmp
, mul(x
, x
)));
4037 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
4039 imm(0.0536813784310406f
)),
4041 imm(0.1173503194786851f
)),
4043 imm(0.1938924977115610f
)),
4045 imm(0.3326756418091246f
)),
4047 imm(0.9999793128310355f
)),
4050 /* range-reduction fixup */
4051 body
.emit(assign(tmp
, add(tmp
,
4052 mul(b2f(greater(abs(y_over_x
),
4053 imm(1.0f
, type
->components()))),
4059 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
4062 ir_function_signature
*
4063 builtin_builder::_atan(const glsl_type
*type
)
4065 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
4066 MAKE_SIG(type
, always_available
, 1, y_over_x
);
4068 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
4069 do_atan(body
, type
, tmp
, y_over_x
);
4070 body
.emit(ret(tmp
));
4075 ir_function_signature
*
4076 builtin_builder::_sinh(const glsl_type
*type
)
4078 ir_variable
*x
= in_var(type
, "x");
4079 MAKE_SIG(type
, v130
, 1, x
);
4081 /* 0.5 * (e^x - e^(-x)) */
4082 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
4087 ir_function_signature
*
4088 builtin_builder::_cosh(const glsl_type
*type
)
4090 ir_variable
*x
= in_var(type
, "x");
4091 MAKE_SIG(type
, v130
, 1, x
);
4093 /* 0.5 * (e^x + e^(-x)) */
4094 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
4099 ir_function_signature
*
4100 builtin_builder::_tanh(const glsl_type
*type
)
4102 ir_variable
*x
= in_var(type
, "x");
4103 MAKE_SIG(type
, v130
, 1, x
);
4105 /* tanh(x) := (0.5 * (e^x - e^(-x))) / (0.5 * (e^x + e^(-x)))
4107 * With a little algebra this reduces to (e^2x - 1) / (e^2x + 1)
4109 * Clamp x to (-inf, +10] to avoid precision problems. When x > 10, e^2x
4110 * is so much larger than 1.0 that 1.0 gets flushed to zero in the
4111 * computation e^2x +/- 1 so it can be ignored.
4113 ir_variable
*t
= body
.make_temp(type
, "tmp");
4114 body
.emit(assign(t
, min2(x
, imm(10.0f
))));
4116 body
.emit(ret(div(sub(exp(mul(t
, imm(2.0f
))), imm(1.0f
)),
4117 add(exp(mul(t
, imm(2.0f
))), imm(1.0f
)))));
4122 ir_function_signature
*
4123 builtin_builder::_asinh(const glsl_type
*type
)
4125 ir_variable
*x
= in_var(type
, "x");
4126 MAKE_SIG(type
, v130
, 1, x
);
4128 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
4133 ir_function_signature
*
4134 builtin_builder::_acosh(const glsl_type
*type
)
4136 ir_variable
*x
= in_var(type
, "x");
4137 MAKE_SIG(type
, v130
, 1, x
);
4139 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
4143 ir_function_signature
*
4144 builtin_builder::_atanh(const glsl_type
*type
)
4146 ir_variable
*x
= in_var(type
, "x");
4147 MAKE_SIG(type
, v130
, 1, x
);
4149 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
4150 sub(imm(1.0f
), x
))))));
4156 * Exponential Functions @{
4159 ir_function_signature
*
4160 builtin_builder::_pow(const glsl_type
*type
)
4162 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
4165 UNOP(exp
, ir_unop_exp
, always_available
)
4166 UNOP(log
, ir_unop_log
, always_available
)
4167 UNOP(exp2
, ir_unop_exp2
, always_available
)
4168 UNOP(log2
, ir_unop_log2
, always_available
)
4169 UNOPA(sqrt
, ir_unop_sqrt
)
4170 UNOPA(inversesqrt
, ir_unop_rsq
)
4174 UNOPA(abs
, ir_unop_abs
)
4175 UNOPA(sign
, ir_unop_sign
)
4176 UNOPA(floor
, ir_unop_floor
)
4177 UNOPA(trunc
, ir_unop_trunc
)
4178 UNOPA(round
, ir_unop_round_even
)
4179 UNOPA(roundEven
, ir_unop_round_even
)
4180 UNOPA(ceil
, ir_unop_ceil
)
4181 UNOPA(fract
, ir_unop_fract
)
4183 ir_function_signature
*
4184 builtin_builder::_mod(builtin_available_predicate avail
,
4185 const glsl_type
*x_type
, const glsl_type
*y_type
)
4187 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
4190 ir_function_signature
*
4191 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
4193 ir_variable
*x
= in_var(type
, "x");
4194 ir_variable
*i
= out_var(type
, "i");
4195 MAKE_SIG(type
, avail
, 2, x
, i
);
4197 ir_variable
*t
= body
.make_temp(type
, "t");
4198 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
4199 body
.emit(assign(i
, t
));
4200 body
.emit(ret(sub(x
, t
)));
4205 ir_function_signature
*
4206 builtin_builder::_min(builtin_available_predicate avail
,
4207 const glsl_type
*x_type
, const glsl_type
*y_type
)
4209 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
4212 ir_function_signature
*
4213 builtin_builder::_max(builtin_available_predicate avail
,
4214 const glsl_type
*x_type
, const glsl_type
*y_type
)
4216 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
4219 ir_function_signature
*
4220 builtin_builder::_clamp(builtin_available_predicate avail
,
4221 const glsl_type
*val_type
, const glsl_type
*bound_type
)
4223 ir_variable
*x
= in_var(val_type
, "x");
4224 ir_variable
*minVal
= in_var(bound_type
, "minVal");
4225 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
4226 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
4228 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
4233 ir_function_signature
*
4234 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
4236 ir_variable
*x
= in_var(val_type
, "x");
4237 ir_variable
*y
= in_var(val_type
, "y");
4238 ir_variable
*a
= in_var(blend_type
, "a");
4239 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4241 body
.emit(ret(lrp(x
, y
, a
)));
4246 ir_function_signature
*
4247 builtin_builder::_mix_sel(builtin_available_predicate avail
,
4248 const glsl_type
*val_type
,
4249 const glsl_type
*blend_type
)
4251 ir_variable
*x
= in_var(val_type
, "x");
4252 ir_variable
*y
= in_var(val_type
, "y");
4253 ir_variable
*a
= in_var(blend_type
, "a");
4254 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4256 /* csel matches the ternary operator in that a selector of true choses the
4257 * first argument. This differs from mix(x, y, false) which choses the
4258 * second argument (to remain consistent with the interpolating version of
4259 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
4261 * To handle the behavior mismatch, reverse the x and y arguments.
4263 body
.emit(ret(csel(a
, y
, x
)));
4268 ir_function_signature
*
4269 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4271 ir_variable
*edge
= in_var(edge_type
, "edge");
4272 ir_variable
*x
= in_var(x_type
, "x");
4273 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
4275 ir_variable
*t
= body
.make_temp(x_type
, "t");
4276 if (x_type
->vector_elements
== 1) {
4277 /* Both are floats */
4278 if (edge_type
->is_double())
4279 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
4281 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
4282 } else if (edge_type
->vector_elements
== 1) {
4283 /* x is a vector but edge is a float */
4284 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4285 if (edge_type
->is_double())
4286 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
4288 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
4291 /* Both are vectors */
4292 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4293 if (edge_type
->is_double())
4294 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
4297 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
4307 ir_function_signature
*
4308 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4310 ir_variable
*edge0
= in_var(edge_type
, "edge0");
4311 ir_variable
*edge1
= in_var(edge_type
, "edge1");
4312 ir_variable
*x
= in_var(x_type
, "x");
4313 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
4315 /* From the GLSL 1.10 specification:
4318 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
4319 * return t * t * (3 - 2 * t);
4322 ir_variable
*t
= body
.make_temp(x_type
, "t");
4323 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
4324 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
4326 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
4331 ir_function_signature
*
4332 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
4334 ir_variable
*x
= in_var(type
, "x");
4335 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4337 body
.emit(ret(nequal(x
, x
)));
4342 ir_function_signature
*
4343 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
4345 ir_variable
*x
= in_var(type
, "x");
4346 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4348 ir_constant_data infinities
;
4349 for (int i
= 0; i
< type
->vector_elements
; i
++) {
4350 switch (type
->base_type
) {
4351 case GLSL_TYPE_FLOAT
:
4352 infinities
.f
[i
] = INFINITY
;
4354 case GLSL_TYPE_DOUBLE
:
4355 infinities
.d
[i
] = INFINITY
;
4358 unreachable("unknown type");
4362 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
4367 ir_function_signature
*
4368 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
4370 ir_variable
*x
= in_var(type
, "x");
4371 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4372 body
.emit(ret(bitcast_f2i(x
)));
4376 ir_function_signature
*
4377 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
4379 ir_variable
*x
= in_var(type
, "x");
4380 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4381 body
.emit(ret(bitcast_f2u(x
)));
4385 ir_function_signature
*
4386 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
4388 ir_variable
*x
= in_var(type
, "x");
4389 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4390 body
.emit(ret(bitcast_i2f(x
)));
4394 ir_function_signature
*
4395 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
4397 ir_variable
*x
= in_var(type
, "x");
4398 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4399 body
.emit(ret(bitcast_u2f(x
)));
4403 ir_function_signature
*
4404 builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail
, const glsl_type
*type
)
4406 ir_variable
*x
= in_var(type
, "x");
4407 MAKE_SIG(glsl_type::i64vec(type
->vector_elements
), avail
, 1, x
);
4408 body
.emit(ret(bitcast_d2i64(x
)));
4412 ir_function_signature
*
4413 builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail
, const glsl_type
*type
)
4415 ir_variable
*x
= in_var(type
, "x");
4416 MAKE_SIG(glsl_type::u64vec(type
->vector_elements
), avail
, 1, x
);
4417 body
.emit(ret(bitcast_d2u64(x
)));
4421 ir_function_signature
*
4422 builtin_builder::_int64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4424 ir_variable
*x
= in_var(type
, "x");
4425 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4426 body
.emit(ret(bitcast_i642d(x
)));
4430 ir_function_signature
*
4431 builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4433 ir_variable
*x
= in_var(type
, "x");
4434 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4435 body
.emit(ret(bitcast_u642d(x
)));
4439 ir_function_signature
*
4440 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
4442 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4443 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4444 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
4448 ir_function_signature
*
4449 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
4451 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4452 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4453 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
4457 ir_function_signature
*
4458 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
4460 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4461 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4462 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
4466 ir_function_signature
*
4467 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
4469 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4470 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4471 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
4475 ir_function_signature
*
4476 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
4478 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4479 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4480 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
4484 ir_function_signature
*
4485 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
4487 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4488 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4489 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
4494 ir_function_signature
*
4495 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
4497 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4498 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4499 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
4503 ir_function_signature
*
4504 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
4506 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4507 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4508 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
4512 ir_function_signature
*
4513 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
4515 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4516 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4517 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
4521 ir_function_signature
*
4522 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
4524 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4525 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4526 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
4530 ir_function_signature
*
4531 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
4533 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4534 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
4535 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
4539 ir_function_signature
*
4540 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
4542 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
4543 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4544 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
4548 ir_function_signature
*
4549 builtin_builder::_packInt2x32(builtin_available_predicate avail
)
4551 ir_variable
*v
= in_var(glsl_type::ivec2_type
, "v");
4552 MAKE_SIG(glsl_type::int64_t_type
, avail
, 1, v
);
4553 body
.emit(ret(expr(ir_unop_pack_int_2x32
, v
)));
4557 ir_function_signature
*
4558 builtin_builder::_unpackInt2x32(builtin_available_predicate avail
)
4560 ir_variable
*p
= in_var(glsl_type::int64_t_type
, "p");
4561 MAKE_SIG(glsl_type::ivec2_type
, avail
, 1, p
);
4562 body
.emit(ret(expr(ir_unop_unpack_int_2x32
, p
)));
4566 ir_function_signature
*
4567 builtin_builder::_packUint2x32(builtin_available_predicate avail
)
4569 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4570 MAKE_SIG(glsl_type::uint64_t_type
, avail
, 1, v
);
4571 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, v
)));
4575 ir_function_signature
*
4576 builtin_builder::_unpackUint2x32(builtin_available_predicate avail
)
4578 ir_variable
*p
= in_var(glsl_type::uint64_t_type
, "p");
4579 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4580 body
.emit(ret(expr(ir_unop_unpack_uint_2x32
, p
)));
4584 ir_function_signature
*
4585 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
4587 ir_variable
*x
= in_var(type
, "x");
4588 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
4590 body
.emit(ret(sqrt(dot(x
, x
))));
4595 ir_function_signature
*
4596 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
4598 ir_variable
*p0
= in_var(type
, "p0");
4599 ir_variable
*p1
= in_var(type
, "p1");
4600 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
4602 if (type
->vector_elements
== 1) {
4603 body
.emit(ret(abs(sub(p0
, p1
))));
4605 ir_variable
*p
= body
.make_temp(type
, "p");
4606 body
.emit(assign(p
, sub(p0
, p1
)));
4607 body
.emit(ret(sqrt(dot(p
, p
))));
4613 ir_function_signature
*
4614 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
4616 if (type
->vector_elements
== 1)
4617 return binop(avail
, ir_binop_mul
, type
, type
, type
);
4619 return binop(avail
, ir_binop_dot
,
4620 type
->get_base_type(), type
, type
);
4623 ir_function_signature
*
4624 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
4626 ir_variable
*a
= in_var(type
, "a");
4627 ir_variable
*b
= in_var(type
, "b");
4628 MAKE_SIG(type
, avail
, 2, a
, b
);
4630 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
4631 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
4633 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
4634 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
4639 ir_function_signature
*
4640 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
4642 ir_variable
*x
= in_var(type
, "x");
4643 MAKE_SIG(type
, avail
, 1, x
);
4645 if (type
->vector_elements
== 1) {
4646 body
.emit(ret(sign(x
)));
4648 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
4654 ir_function_signature
*
4655 builtin_builder::_ftransform()
4657 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
4659 /* ftransform() refers to global variables, and is always emitted
4660 * directly by ast_function.cpp. Just emit a prototype here so we
4661 * can recognize calls to it.
4666 ir_function_signature
*
4667 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
4669 ir_variable
*N
= in_var(type
, "N");
4670 ir_variable
*I
= in_var(type
, "I");
4671 ir_variable
*Nref
= in_var(type
, "Nref");
4672 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
4674 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
4675 ret(N
), ret(neg(N
))));
4680 ir_function_signature
*
4681 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
4683 ir_variable
*I
= in_var(type
, "I");
4684 ir_variable
*N
= in_var(type
, "N");
4685 MAKE_SIG(type
, avail
, 2, I
, N
);
4687 /* I - 2 * dot(N, I) * N */
4688 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
4693 ir_function_signature
*
4694 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
4696 ir_variable
*I
= in_var(type
, "I");
4697 ir_variable
*N
= in_var(type
, "N");
4698 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
4699 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4701 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4702 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4704 /* From the GLSL 1.10 specification:
4705 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4707 * return genType(0.0)
4709 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4711 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4712 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4713 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4714 mul(n_dot_i
, n_dot_i
)))))));
4715 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4716 ret(ir_constant::zero(mem_ctx
, type
)),
4717 ret(sub(mul(eta
, I
),
4718 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4723 ir_function_signature
*
4724 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4726 ir_variable
*x
= in_var(type
, "x");
4727 ir_variable
*y
= in_var(type
, "y");
4728 MAKE_SIG(type
, avail
, 2, x
, y
);
4730 ir_variable
*z
= body
.make_temp(type
, "z");
4731 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4732 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4739 ir_function_signature
*
4740 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4745 if (type
->is_double()) {
4746 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4747 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4749 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4750 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4752 MAKE_SIG(type
, avail
, 2, c
, r
);
4754 ir_variable
*m
= body
.make_temp(type
, "m");
4755 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4756 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4763 ir_function_signature
*
4764 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4766 const glsl_type
*transpose_type
=
4767 glsl_type::get_instance(orig_type
->base_type
,
4768 orig_type
->matrix_columns
,
4769 orig_type
->vector_elements
);
4771 ir_variable
*m
= in_var(orig_type
, "m");
4772 MAKE_SIG(transpose_type
, avail
, 1, m
);
4774 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4775 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4776 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4777 body
.emit(assign(array_ref(t
, j
),
4778 matrix_elt(m
, i
, j
),
4787 ir_function_signature
*
4788 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4790 ir_variable
*m
= in_var(type
, "m");
4791 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4793 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4794 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4799 ir_function_signature
*
4800 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4802 ir_variable
*m
= in_var(type
, "m");
4803 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4806 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4807 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4810 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4811 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4814 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4815 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4817 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4818 mul(matrix_elt(m
, 0, 1), f2
)),
4819 mul(matrix_elt(m
, 0, 2), f3
))));
4824 ir_function_signature
*
4825 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4827 ir_variable
*m
= in_var(type
, "m");
4828 const glsl_type
*btype
= type
->get_base_type();
4829 MAKE_SIG(btype
, avail
, 1, m
);
4831 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4832 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4833 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4834 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4835 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4836 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4837 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4838 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4839 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4840 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4841 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4842 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4843 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4844 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4845 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4846 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4847 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4848 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4849 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4851 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)))));
4852 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)))));
4853 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)))));
4854 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)))));
4855 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)))));
4856 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)))));
4857 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)))));
4858 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)))));
4859 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)))));
4860 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)))));
4861 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)))));
4862 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)))));
4863 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)))));
4864 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)))));
4865 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)))));
4866 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)))));
4867 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)))));
4868 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)))));
4869 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)))));
4871 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4873 body
.emit(assign(adj_0
,
4874 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4875 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4876 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4878 body
.emit(assign(adj_0
, neg(
4879 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4880 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4881 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4883 body
.emit(assign(adj_0
,
4884 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4885 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4886 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4888 body
.emit(assign(adj_0
, neg(
4889 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4890 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4891 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4894 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4899 ir_function_signature
*
4900 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4902 ir_variable
*m
= in_var(type
, "m");
4903 MAKE_SIG(type
, avail
, 1, m
);
4905 ir_variable
*adj
= body
.make_temp(type
, "adj");
4906 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4907 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4908 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4909 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4911 ir_expression
*det
=
4912 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4913 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4915 body
.emit(ret(div(adj
, det
)));
4919 ir_function_signature
*
4920 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4922 ir_variable
*m
= in_var(type
, "m");
4923 const glsl_type
*btype
= type
->get_base_type();
4924 MAKE_SIG(type
, avail
, 1, m
);
4926 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4927 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4928 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4930 body
.emit(assign(f11_22_21_12
,
4931 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4932 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4933 body
.emit(assign(f10_22_20_12
,
4934 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4935 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4936 body
.emit(assign(f10_21_20_11
,
4937 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4938 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4940 ir_variable
*adj
= body
.make_temp(type
, "adj");
4941 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4942 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4943 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4945 body
.emit(assign(array_ref(adj
, 0), neg(
4946 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4947 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4949 body
.emit(assign(array_ref(adj
, 1),
4950 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4951 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4953 body
.emit(assign(array_ref(adj
, 2), neg(
4954 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4955 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4958 body
.emit(assign(array_ref(adj
, 0),
4959 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4960 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4962 body
.emit(assign(array_ref(adj
, 1), neg(
4963 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4964 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4966 body
.emit(assign(array_ref(adj
, 2),
4967 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4968 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4971 ir_expression
*det
=
4972 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4973 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4974 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4976 body
.emit(ret(div(adj
, det
)));
4981 ir_function_signature
*
4982 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4984 ir_variable
*m
= in_var(type
, "m");
4985 const glsl_type
*btype
= type
->get_base_type();
4986 MAKE_SIG(type
, avail
, 1, m
);
4988 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4989 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4990 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4991 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4992 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4993 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4994 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4995 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4996 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4997 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4998 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4999 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
5000 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
5001 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
5002 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
5003 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
5004 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
5005 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
5006 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
5008 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)))));
5009 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)))));
5010 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)))));
5011 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)))));
5012 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)))));
5013 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)))));
5014 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)))));
5015 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)))));
5016 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)))));
5017 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)))));
5018 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)))));
5019 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)))));
5020 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)))));
5021 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)))));
5022 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)))));
5023 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)))));
5024 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)))));
5025 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)))));
5026 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)))));
5028 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
5029 body
.emit(assign(array_ref(adj
, 0),
5030 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
5031 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
5032 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
5034 body
.emit(assign(array_ref(adj
, 1), neg(
5035 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
5036 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
5037 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
5039 body
.emit(assign(array_ref(adj
, 2),
5040 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
5041 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
5042 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
5044 body
.emit(assign(array_ref(adj
, 3), neg(
5045 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
5046 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
5047 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
5050 body
.emit(assign(array_ref(adj
, 0), neg(
5051 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
5052 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
5053 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
5055 body
.emit(assign(array_ref(adj
, 1),
5056 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
5057 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
5058 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
5060 body
.emit(assign(array_ref(adj
, 2), neg(
5061 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
5062 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
5063 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
5065 body
.emit(assign(array_ref(adj
, 3),
5066 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
5067 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
5068 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
5071 body
.emit(assign(array_ref(adj
, 0),
5072 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
5073 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
5074 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
5076 body
.emit(assign(array_ref(adj
, 1), neg(
5077 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
5078 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
5079 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
5081 body
.emit(assign(array_ref(adj
, 2),
5082 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
5083 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
5084 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
5086 body
.emit(assign(array_ref(adj
, 3), neg(
5087 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
5088 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
5089 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
5092 body
.emit(assign(array_ref(adj
, 0), neg(
5093 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
5094 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
5095 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
5097 body
.emit(assign(array_ref(adj
, 1),
5098 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
5099 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
5100 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
5102 body
.emit(assign(array_ref(adj
, 2), neg(
5103 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
5104 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
5105 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
5107 body
.emit(assign(array_ref(adj
, 3),
5108 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
5109 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
5110 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
5113 ir_expression
*det
=
5114 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
5115 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
5116 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
5117 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
5119 body
.emit(ret(div(adj
, det
)));
5125 ir_function_signature
*
5126 builtin_builder::_lessThan(builtin_available_predicate avail
,
5127 const glsl_type
*type
)
5129 return binop(avail
, ir_binop_less
,
5130 glsl_type::bvec(type
->vector_elements
), type
, type
);
5133 ir_function_signature
*
5134 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
5135 const glsl_type
*type
)
5137 return binop(avail
, ir_binop_gequal
,
5138 glsl_type::bvec(type
->vector_elements
), type
, type
,
5142 ir_function_signature
*
5143 builtin_builder::_greaterThan(builtin_available_predicate avail
,
5144 const glsl_type
*type
)
5146 return binop(avail
, ir_binop_less
,
5147 glsl_type::bvec(type
->vector_elements
), type
, type
,
5151 ir_function_signature
*
5152 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
5153 const glsl_type
*type
)
5155 return binop(avail
, ir_binop_gequal
,
5156 glsl_type::bvec(type
->vector_elements
), type
, type
);
5159 ir_function_signature
*
5160 builtin_builder::_equal(builtin_available_predicate avail
,
5161 const glsl_type
*type
)
5163 return binop(avail
, ir_binop_equal
,
5164 glsl_type::bvec(type
->vector_elements
), type
, type
);
5167 ir_function_signature
*
5168 builtin_builder::_notEqual(builtin_available_predicate avail
,
5169 const glsl_type
*type
)
5171 return binop(avail
, ir_binop_nequal
,
5172 glsl_type::bvec(type
->vector_elements
), type
, type
);
5175 ir_function_signature
*
5176 builtin_builder::_any(const glsl_type
*type
)
5178 ir_variable
*v
= in_var(type
, "v");
5179 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5181 const unsigned vec_elem
= v
->type
->vector_elements
;
5182 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
5187 ir_function_signature
*
5188 builtin_builder::_all(const glsl_type
*type
)
5190 ir_variable
*v
= in_var(type
, "v");
5191 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5193 const unsigned vec_elem
= v
->type
->vector_elements
;
5194 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
5199 UNOP(not, ir_unop_logic_not
, always_available
)
5202 has_lod(const glsl_type
*sampler_type
)
5204 assert(sampler_type
->is_sampler());
5206 switch (sampler_type
->sampler_dimensionality
) {
5207 case GLSL_SAMPLER_DIM_RECT
:
5208 case GLSL_SAMPLER_DIM_BUF
:
5209 case GLSL_SAMPLER_DIM_MS
:
5216 ir_function_signature
*
5217 builtin_builder::_textureSize(builtin_available_predicate avail
,
5218 const glsl_type
*return_type
,
5219 const glsl_type
*sampler_type
)
5221 ir_variable
*s
= in_var(sampler_type
, "sampler");
5222 /* The sampler always exists; add optional lod later. */
5223 MAKE_SIG(return_type
, avail
, 1, s
);
5225 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
5226 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
5228 if (has_lod(sampler_type
)) {
5229 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5230 sig
->parameters
.push_tail(lod
);
5231 tex
->lod_info
.lod
= var_ref(lod
);
5233 tex
->lod_info
.lod
= imm(0u);
5236 body
.emit(ret(tex
));
5241 ir_function_signature
*
5242 builtin_builder::_textureSamples(builtin_available_predicate avail
,
5243 const glsl_type
*sampler_type
)
5245 ir_variable
*s
= in_var(sampler_type
, "sampler");
5246 MAKE_SIG(glsl_type::int_type
, avail
, 1, s
);
5248 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
5249 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
5250 body
.emit(ret(tex
));
5255 ir_function_signature
*
5256 builtin_builder::_texture(ir_texture_opcode opcode
,
5257 builtin_available_predicate avail
,
5258 const glsl_type
*return_type
,
5259 const glsl_type
*sampler_type
,
5260 const glsl_type
*coord_type
,
5263 ir_variable
*s
= in_var(sampler_type
, "sampler");
5264 ir_variable
*P
= in_var(coord_type
, "P");
5265 /* The sampler and coordinate always exist; add optional parameters later. */
5266 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5268 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
5269 tex
->set_sampler(var_ref(s
), return_type
);
5271 const int coord_size
= sampler_type
->coordinate_components();
5273 if (coord_size
== coord_type
->vector_elements
) {
5274 tex
->coordinate
= var_ref(P
);
5276 /* The incoming coordinate also has the projector or shadow comparator,
5277 * so we need to swizzle those away.
5279 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
5282 /* The projector is always in the last component. */
5283 if (flags
& TEX_PROJECT
)
5284 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
5286 if (sampler_type
->sampler_shadow
) {
5287 if (opcode
== ir_tg4
) {
5288 /* gather has refz as a separate parameter, immediately after the
5291 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
5292 sig
->parameters
.push_tail(refz
);
5293 tex
->shadow_comparator
= var_ref(refz
);
5295 /* The shadow comparator is normally in the Z component, but a few types
5296 * have sufficiently large coordinates that it's in W.
5298 tex
->shadow_comparator
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
5302 if (opcode
== ir_txl
) {
5303 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
5304 sig
->parameters
.push_tail(lod
);
5305 tex
->lod_info
.lod
= var_ref(lod
);
5306 } else if (opcode
== ir_txd
) {
5307 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5308 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
5309 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
5310 sig
->parameters
.push_tail(dPdx
);
5311 sig
->parameters
.push_tail(dPdy
);
5312 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
5313 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
5316 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
5317 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5318 ir_variable
*offset
=
5319 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
5320 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
5321 sig
->parameters
.push_tail(offset
);
5322 tex
->offset
= var_ref(offset
);
5325 if (flags
& TEX_OFFSET_ARRAY
) {
5326 ir_variable
*offsets
=
5327 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
5328 "offsets", ir_var_const_in
);
5329 sig
->parameters
.push_tail(offsets
);
5330 tex
->offset
= var_ref(offsets
);
5333 if (opcode
== ir_tg4
) {
5334 if (flags
& TEX_COMPONENT
) {
5335 ir_variable
*component
=
5336 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
5337 sig
->parameters
.push_tail(component
);
5338 tex
->lod_info
.component
= var_ref(component
);
5341 tex
->lod_info
.component
= imm(0);
5345 /* The "bias" parameter comes /after/ the "offset" parameter, which is
5346 * inconsistent with both textureLodOffset and textureGradOffset.
5348 if (opcode
== ir_txb
) {
5349 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
5350 sig
->parameters
.push_tail(bias
);
5351 tex
->lod_info
.bias
= var_ref(bias
);
5354 body
.emit(ret(tex
));
5359 ir_function_signature
*
5360 builtin_builder::_textureCubeArrayShadow(builtin_available_predicate avail
,
5361 const glsl_type
*sampler_type
)
5363 ir_variable
*s
= in_var(sampler_type
, "sampler");
5364 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
5365 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
5366 MAKE_SIG(glsl_type::float_type
, avail
, 3, s
, P
, compare
);
5368 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
5369 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
5371 tex
->coordinate
= var_ref(P
);
5372 tex
->shadow_comparator
= var_ref(compare
);
5374 body
.emit(ret(tex
));
5379 ir_function_signature
*
5380 builtin_builder::_texelFetch(builtin_available_predicate avail
,
5381 const glsl_type
*return_type
,
5382 const glsl_type
*sampler_type
,
5383 const glsl_type
*coord_type
,
5384 const glsl_type
*offset_type
)
5386 ir_variable
*s
= in_var(sampler_type
, "sampler");
5387 ir_variable
*P
= in_var(coord_type
, "P");
5388 /* The sampler and coordinate always exist; add optional parameters later. */
5389 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5391 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
5392 tex
->coordinate
= var_ref(P
);
5393 tex
->set_sampler(var_ref(s
), return_type
);
5395 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
5396 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
5397 sig
->parameters
.push_tail(sample
);
5398 tex
->lod_info
.sample_index
= var_ref(sample
);
5399 tex
->op
= ir_txf_ms
;
5400 } else if (has_lod(sampler_type
)) {
5401 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5402 sig
->parameters
.push_tail(lod
);
5403 tex
->lod_info
.lod
= var_ref(lod
);
5405 tex
->lod_info
.lod
= imm(0u);
5408 if (offset_type
!= NULL
) {
5409 ir_variable
*offset
=
5410 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
5411 sig
->parameters
.push_tail(offset
);
5412 tex
->offset
= var_ref(offset
);
5415 body
.emit(ret(tex
));
5420 ir_function_signature
*
5421 builtin_builder::_EmitVertex()
5423 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5425 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5426 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
5431 ir_function_signature
*
5432 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
5433 const glsl_type
*stream_type
)
5435 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5437 * "Emit the current values of output variables to the current output
5438 * primitive on stream stream. The argument to stream must be a constant
5439 * integral expression."
5441 ir_variable
*stream
=
5442 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5444 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5446 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
5451 ir_function_signature
*
5452 builtin_builder::_EndPrimitive()
5454 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5456 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5457 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
5462 ir_function_signature
*
5463 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
5464 const glsl_type
*stream_type
)
5466 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5468 * "Completes the current output primitive on stream stream and starts
5469 * a new one. The argument to stream must be a constant integral
5472 ir_variable
*stream
=
5473 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5475 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5477 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
5482 ir_function_signature
*
5483 builtin_builder::_barrier()
5485 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
5487 body
.emit(new(mem_ctx
) ir_barrier());
5491 ir_function_signature
*
5492 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
5493 const glsl_type
*sampler_type
,
5494 const glsl_type
*coord_type
)
5496 ir_variable
*s
= in_var(sampler_type
, "sampler");
5497 ir_variable
*coord
= in_var(coord_type
, "coord");
5498 /* The sampler and coordinate always exist; add optional parameters later. */
5499 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
5501 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
5502 tex
->coordinate
= var_ref(coord
);
5503 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
5505 body
.emit(ret(tex
));
5510 ir_function_signature
*
5511 builtin_builder::_textureQueryLevels(builtin_available_predicate avail
,
5512 const glsl_type
*sampler_type
)
5514 ir_variable
*s
= in_var(sampler_type
, "sampler");
5515 const glsl_type
*return_type
= glsl_type::int_type
;
5516 MAKE_SIG(return_type
, avail
, 1, s
);
5518 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
5519 tex
->set_sampler(var_ref(s
), return_type
);
5521 body
.emit(ret(tex
));
5526 ir_function_signature
*
5527 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
5528 const glsl_type
*sampler_type
,
5529 const glsl_type
*coord_type
)
5531 ir_variable
*s
= in_var(sampler_type
, "sampler");
5532 ir_variable
*P
= in_var(coord_type
, "P");
5533 const glsl_type
*return_type
= glsl_type::bool_type
;
5534 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5536 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
5537 tex
->coordinate
= var_ref(P
);
5538 tex
->set_sampler(var_ref(s
), return_type
);
5540 body
.emit(ret(tex
));
5545 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
5546 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
5547 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
5548 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
5549 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
5550 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
5552 ir_function_signature
*
5553 builtin_builder::_fwidth(const glsl_type
*type
)
5555 ir_variable
*p
= in_var(type
, "p");
5556 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
5558 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
5563 ir_function_signature
*
5564 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
5566 ir_variable
*p
= in_var(type
, "p");
5567 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5569 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
5570 abs(expr(ir_unop_dFdy_coarse
, p
)))));
5575 ir_function_signature
*
5576 builtin_builder::_fwidthFine(const glsl_type
*type
)
5578 ir_variable
*p
= in_var(type
, "p");
5579 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5581 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
5582 abs(expr(ir_unop_dFdy_fine
, p
)))));
5587 ir_function_signature
*
5588 builtin_builder::_noise1(const glsl_type
*type
)
5590 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
5593 ir_function_signature
*
5594 builtin_builder::_noise2(const glsl_type
*type
)
5596 ir_variable
*p
= in_var(type
, "p");
5597 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
5599 ir_constant_data b_offset
;
5600 b_offset
.f
[0] = 601.0f
;
5601 b_offset
.f
[1] = 313.0f
;
5602 b_offset
.f
[2] = 29.0f
;
5603 b_offset
.f
[3] = 277.0f
;
5605 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5606 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5607 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
5608 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5609 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5610 body
.emit(assign(t
, a
, WRITEMASK_X
));
5611 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5617 ir_function_signature
*
5618 builtin_builder::_noise3(const glsl_type
*type
)
5620 ir_variable
*p
= in_var(type
, "p");
5621 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
5623 ir_constant_data b_offset
;
5624 b_offset
.f
[0] = 601.0f
;
5625 b_offset
.f
[1] = 313.0f
;
5626 b_offset
.f
[2] = 29.0f
;
5627 b_offset
.f
[3] = 277.0f
;
5629 ir_constant_data c_offset
;
5630 c_offset
.f
[0] = 1559.0f
;
5631 c_offset
.f
[1] = 113.0f
;
5632 c_offset
.f
[2] = 1861.0f
;
5633 c_offset
.f
[3] = 797.0f
;
5635 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5636 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5637 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5638 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
5639 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5640 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5641 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
5642 body
.emit(assign(t
, a
, WRITEMASK_X
));
5643 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5644 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5650 ir_function_signature
*
5651 builtin_builder::_noise4(const glsl_type
*type
)
5653 ir_variable
*p
= in_var(type
, "p");
5654 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
5656 ir_variable
*_p
= body
.make_temp(type
, "_p");
5658 ir_constant_data p_offset
;
5659 p_offset
.f
[0] = 1559.0f
;
5660 p_offset
.f
[1] = 113.0f
;
5661 p_offset
.f
[2] = 1861.0f
;
5662 p_offset
.f
[3] = 797.0f
;
5664 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
5666 ir_constant_data offset
;
5667 offset
.f
[0] = 601.0f
;
5668 offset
.f
[1] = 313.0f
;
5669 offset
.f
[2] = 29.0f
;
5670 offset
.f
[3] = 277.0f
;
5672 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5673 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5674 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5675 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
5676 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
5677 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5678 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
5679 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
5680 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
5681 body
.emit(assign(t
, a
, WRITEMASK_X
));
5682 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5683 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5684 body
.emit(assign(t
, d
, WRITEMASK_W
));
5690 ir_function_signature
*
5691 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
5693 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5694 ir_variable
*value
= in_var(type
, "value");
5695 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5696 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5697 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, value
, offset
,
5700 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5701 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5703 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
5704 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5705 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5710 ir_function_signature
*
5711 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5713 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5714 ir_variable
*base
= in_var(type
, "base");
5715 ir_variable
*insert
= in_var(type
, "insert");
5716 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5717 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5718 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 4, base
, insert
,
5721 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5722 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5724 body
.emit(ret(bitfield_insert(base
, insert
,
5725 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5726 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5731 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31_or_integer_functions
)
5733 ir_function_signature
*
5734 builtin_builder::_bitCount(const glsl_type
*type
)
5736 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_bit_count
,
5737 glsl_type::ivec(type
->vector_elements
), type
);
5740 ir_function_signature
*
5741 builtin_builder::_findLSB(const glsl_type
*type
)
5743 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_lsb
,
5744 glsl_type::ivec(type
->vector_elements
), type
);
5747 ir_function_signature
*
5748 builtin_builder::_findMSB(const glsl_type
*type
)
5750 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_msb
,
5751 glsl_type::ivec(type
->vector_elements
), type
);
5754 ir_function_signature
*
5755 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5757 ir_variable
*a
= in_var(type
, "a");
5758 ir_variable
*b
= in_var(type
, "b");
5759 ir_variable
*c
= in_var(type
, "c");
5760 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5762 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5767 ir_function_signature
*
5768 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5770 return binop(x_type
->is_double() ? fp64
: gpu_shader5_or_es31_or_integer_functions
,
5771 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5774 ir_function_signature
*
5775 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5777 ir_variable
*x
= in_var(x_type
, "x");
5778 ir_variable
*exponent
= out_var(exp_type
, "exp");
5779 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5781 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5783 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5787 ir_function_signature
*
5788 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5790 ir_variable
*x
= in_var(x_type
, "x");
5791 ir_variable
*exponent
= out_var(exp_type
, "exp");
5792 MAKE_SIG(x_type
, gpu_shader5_or_es31_or_integer_functions
, 2, x
, exponent
);
5794 const unsigned vec_elem
= x_type
->vector_elements
;
5795 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5796 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5798 /* Single-precision floating-point values are stored as
5803 * An exponent shift of 23 will shift the mantissa out, leaving only the
5804 * exponent and sign bit (which itself may be zero, if the absolute value
5805 * was taken before the bitcast and shift.
5807 ir_constant
*exponent_shift
= imm(23);
5808 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5810 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5812 /* Exponent of floating-point values in the range [0.5, 1.0). */
5813 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5815 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5816 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5818 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5819 * to unsigned integers to ensure that 1 bits aren't shifted in.
5821 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5822 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5823 imm(0, vec_elem
)))));
5825 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5826 body
.emit(assign(bits
, bitcast_f2u(x
)));
5827 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5828 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5829 imm(0u, vec_elem
)))));
5830 body
.emit(ret(bitcast_u2f(bits
)));
5835 ir_function_signature
*
5836 builtin_builder::_uaddCarry(const glsl_type
*type
)
5838 ir_variable
*x
= in_var(type
, "x");
5839 ir_variable
*y
= in_var(type
, "y");
5840 ir_variable
*carry
= out_var(type
, "carry");
5841 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, carry
);
5843 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5844 body
.emit(ret(add(x
, y
)));
5849 ir_function_signature
*
5850 builtin_builder::_usubBorrow(const glsl_type
*type
)
5852 ir_variable
*x
= in_var(type
, "x");
5853 ir_variable
*y
= in_var(type
, "y");
5854 ir_variable
*borrow
= out_var(type
, "borrow");
5855 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, borrow
);
5857 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5858 body
.emit(ret(sub(x
, y
)));
5864 * For both imulExtended() and umulExtended() built-ins.
5866 ir_function_signature
*
5867 builtin_builder::_mulExtended(const glsl_type
*type
)
5869 ir_variable
*x
= in_var(type
, "x");
5870 ir_variable
*y
= in_var(type
, "y");
5871 ir_variable
*msb
= out_var(type
, "msb");
5872 ir_variable
*lsb
= out_var(type
, "lsb");
5873 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31_or_integer_functions
, 4, x
, y
, msb
, lsb
);
5875 body
.emit(assign(msb
, imul_high(x
, y
)));
5876 body
.emit(assign(lsb
, mul(x
, y
)));
5881 ir_function_signature
*
5882 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5884 ir_variable
*interpolant
= in_var(type
, "interpolant");
5885 interpolant
->data
.must_be_shader_input
= 1;
5886 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5888 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5893 ir_function_signature
*
5894 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5896 ir_variable
*interpolant
= in_var(type
, "interpolant");
5897 interpolant
->data
.must_be_shader_input
= 1;
5898 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5899 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5901 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5906 ir_function_signature
*
5907 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5909 ir_variable
*interpolant
= in_var(type
, "interpolant");
5910 interpolant
->data
.must_be_shader_input
= 1;
5911 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5912 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5914 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5919 ir_function_signature
*
5920 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
,
5921 enum ir_intrinsic_id id
)
5923 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5924 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 1, counter
);
5928 ir_function_signature
*
5929 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
,
5930 enum ir_intrinsic_id id
)
5932 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5933 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5934 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 2, counter
, data
);
5938 ir_function_signature
*
5939 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
,
5940 enum ir_intrinsic_id id
)
5942 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5943 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5944 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5945 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 3, counter
, compare
, data
);
5949 ir_function_signature
*
5950 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5951 const glsl_type
*type
,
5952 enum ir_intrinsic_id id
)
5954 ir_variable
*atomic
= in_var(type
, "atomic");
5955 ir_variable
*data
= in_var(type
, "data");
5956 MAKE_INTRINSIC(type
, id
, avail
, 2, atomic
, data
);
5960 ir_function_signature
*
5961 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5962 const glsl_type
*type
,
5963 enum ir_intrinsic_id id
)
5965 ir_variable
*atomic
= in_var(type
, "atomic");
5966 ir_variable
*data1
= in_var(type
, "data1");
5967 ir_variable
*data2
= in_var(type
, "data2");
5968 MAKE_INTRINSIC(type
, id
, avail
, 3, atomic
, data1
, data2
);
5972 ir_function_signature
*
5973 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5974 builtin_available_predicate avail
)
5976 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5977 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5979 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5980 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5982 body
.emit(ret(retval
));
5986 ir_function_signature
*
5987 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5988 builtin_available_predicate avail
)
5990 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5991 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5992 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5994 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5996 /* Instead of generating an __intrinsic_atomic_sub, generate an
5997 * __intrinsic_atomic_add with the data parameter negated.
5999 if (strcmp("__intrinsic_atomic_sub", intrinsic
) == 0) {
6000 ir_variable
*const neg_data
=
6001 body
.make_temp(glsl_type::uint_type
, "neg_data");
6003 body
.emit(assign(neg_data
, neg(data
)));
6005 exec_list parameters
;
6007 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(counter
));
6008 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(neg_data
));
6010 ir_function
*const func
=
6011 shader
->symbols
->get_function("__intrinsic_atomic_add");
6012 ir_instruction
*const c
= call(func
, retval
, parameters
);
6015 assert(parameters
.is_empty());
6019 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6023 body
.emit(ret(retval
));
6027 ir_function_signature
*
6028 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
6029 builtin_available_predicate avail
)
6031 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
6032 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
6033 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
6034 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
6036 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
6037 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6039 body
.emit(ret(retval
));
6043 ir_function_signature
*
6044 builtin_builder::_atomic_op2(const char *intrinsic
,
6045 builtin_available_predicate avail
,
6046 const glsl_type
*type
)
6048 ir_variable
*atomic
= in_var(type
, "atomic_var");
6049 ir_variable
*data
= in_var(type
, "atomic_data");
6050 MAKE_SIG(type
, avail
, 2, atomic
, data
);
6052 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
6053 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6055 body
.emit(ret(retval
));
6059 ir_function_signature
*
6060 builtin_builder::_atomic_op3(const char *intrinsic
,
6061 builtin_available_predicate avail
,
6062 const glsl_type
*type
)
6064 ir_variable
*atomic
= in_var(type
, "atomic_var");
6065 ir_variable
*data1
= in_var(type
, "atomic_data1");
6066 ir_variable
*data2
= in_var(type
, "atomic_data2");
6067 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
6069 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
6070 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6072 body
.emit(ret(retval
));
6076 ir_function_signature
*
6077 builtin_builder::_min3(const glsl_type
*type
)
6079 ir_variable
*x
= in_var(type
, "x");
6080 ir_variable
*y
= in_var(type
, "y");
6081 ir_variable
*z
= in_var(type
, "z");
6082 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6084 ir_expression
*min3
= min2(x
, min2(y
,z
));
6085 body
.emit(ret(min3
));
6090 ir_function_signature
*
6091 builtin_builder::_max3(const glsl_type
*type
)
6093 ir_variable
*x
= in_var(type
, "x");
6094 ir_variable
*y
= in_var(type
, "y");
6095 ir_variable
*z
= in_var(type
, "z");
6096 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6098 ir_expression
*max3
= max2(x
, max2(y
,z
));
6099 body
.emit(ret(max3
));
6104 ir_function_signature
*
6105 builtin_builder::_mid3(const glsl_type
*type
)
6107 ir_variable
*x
= in_var(type
, "x");
6108 ir_variable
*y
= in_var(type
, "y");
6109 ir_variable
*z
= in_var(type
, "z");
6110 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6112 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
6113 body
.emit(ret(mid3
));
6118 static builtin_available_predicate
6119 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
6121 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
6122 type
->sampled_type
== GLSL_TYPE_FLOAT
)
6123 return shader_image_atomic_exchange_float
;
6125 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
) &&
6126 type
->sampled_type
== GLSL_TYPE_FLOAT
)
6127 return shader_image_atomic_add_float
;
6129 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
6130 IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
|
6131 IMAGE_FUNCTION_AVAIL_ATOMIC
))
6132 return shader_image_atomic
;
6135 return shader_image_load_store
;
6138 ir_function_signature
*
6139 builtin_builder::_image_prototype(const glsl_type
*image_type
,
6140 unsigned num_arguments
,
6143 const glsl_type
*data_type
= glsl_type::get_instance(
6144 image_type
->sampled_type
,
6145 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
6147 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
6148 glsl_type::void_type
: data_type
);
6150 /* Addressing arguments that are always present. */
6151 ir_variable
*image
= in_var(image_type
, "image");
6152 ir_variable
*coord
= in_var(
6153 glsl_type::ivec(image_type
->coordinate_components()), "coord");
6155 ir_function_signature
*sig
= new_sig(
6156 ret_type
, get_image_available_predicate(image_type
, flags
),
6159 /* Sample index for multisample images. */
6160 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
6161 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
6163 /* Data arguments. */
6164 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
6165 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
6166 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
6167 ralloc_free(arg_name
);
6170 /* Set the maximal set of qualifiers allowed for this image
6171 * built-in. Function calls with arguments having fewer
6172 * qualifiers than present in the prototype are allowed by the
6173 * spec, but not with more, i.e. this will make the compiler
6174 * accept everything that needs to be accepted, and reject cases
6175 * like loads from write-only or stores to read-only images.
6177 image
->data
.memory_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
6178 image
->data
.memory_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
6179 image
->data
.memory_coherent
= true;
6180 image
->data
.memory_volatile
= true;
6181 image
->data
.memory_restrict
= true;
6186 ir_function_signature
*
6187 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
6188 unsigned /* num_arguments */,
6189 unsigned /* flags */)
6191 const glsl_type
*ret_type
;
6192 unsigned num_components
= image_type
->coordinate_components();
6194 /* From the ARB_shader_image_size extension:
6195 * "Cube images return the dimensions of one face."
6197 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
6198 !image_type
->sampler_array
) {
6202 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
6203 * supported by mesa.
6205 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
6207 ir_variable
*image
= in_var(image_type
, "image");
6208 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
6210 /* Set the maximal set of qualifiers allowed for this image
6211 * built-in. Function calls with arguments having fewer
6212 * qualifiers than present in the prototype are allowed by the
6213 * spec, but not with more, i.e. this will make the compiler
6214 * accept everything that needs to be accepted, and reject cases
6215 * like loads from write-only or stores to read-only images.
6217 image
->data
.memory_read_only
= true;
6218 image
->data
.memory_write_only
= true;
6219 image
->data
.memory_coherent
= true;
6220 image
->data
.memory_volatile
= true;
6221 image
->data
.memory_restrict
= true;
6226 ir_function_signature
*
6227 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
6228 unsigned /* num_arguments */,
6229 unsigned /* flags */)
6231 ir_variable
*image
= in_var(image_type
, "image");
6232 ir_function_signature
*sig
=
6233 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
6235 /* Set the maximal set of qualifiers allowed for this image
6236 * built-in. Function calls with arguments having fewer
6237 * qualifiers than present in the prototype are allowed by the
6238 * spec, but not with more, i.e. this will make the compiler
6239 * accept everything that needs to be accepted, and reject cases
6240 * like loads from write-only or stores to read-only images.
6242 image
->data
.memory_read_only
= true;
6243 image
->data
.memory_write_only
= true;
6244 image
->data
.memory_coherent
= true;
6245 image
->data
.memory_volatile
= true;
6246 image
->data
.memory_restrict
= true;
6251 ir_function_signature
*
6252 builtin_builder::_image(image_prototype_ctr prototype
,
6253 const glsl_type
*image_type
,
6254 const char *intrinsic_name
,
6255 unsigned num_arguments
,
6257 enum ir_intrinsic_id id
)
6259 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
6260 num_arguments
, flags
);
6262 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
6263 ir_factory
body(&sig
->body
, mem_ctx
);
6264 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
6266 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
6267 body
.emit(call(f
, NULL
, sig
->parameters
));
6269 ir_variable
*ret_val
=
6270 body
.make_temp(sig
->return_type
, "_ret_val");
6271 body
.emit(call(f
, ret_val
, sig
->parameters
));
6272 body
.emit(ret(ret_val
));
6275 sig
->is_defined
= true;
6278 sig
->intrinsic_id
= id
;
6284 ir_function_signature
*
6285 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
,
6286 enum ir_intrinsic_id id
)
6288 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6292 ir_function_signature
*
6293 builtin_builder::_memory_barrier(const char *intrinsic_name
,
6294 builtin_available_predicate avail
)
6296 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6297 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6298 NULL
, sig
->parameters
));
6302 ir_function_signature
*
6303 builtin_builder::_ballot_intrinsic()
6305 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6306 MAKE_INTRINSIC(glsl_type::uint64_t_type
, ir_intrinsic_ballot
, shader_ballot
,
6311 ir_function_signature
*
6312 builtin_builder::_ballot()
6314 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6316 MAKE_SIG(glsl_type::uint64_t_type
, shader_ballot
, 1, value
);
6317 ir_variable
*retval
= body
.make_temp(glsl_type::uint64_t_type
, "retval");
6319 body
.emit(call(shader
->symbols
->get_function("__intrinsic_ballot"),
6320 retval
, sig
->parameters
));
6321 body
.emit(ret(retval
));
6325 ir_function_signature
*
6326 builtin_builder::_read_first_invocation_intrinsic(const glsl_type
*type
)
6328 ir_variable
*value
= in_var(type
, "value");
6329 MAKE_INTRINSIC(type
, ir_intrinsic_read_first_invocation
, shader_ballot
,
6334 ir_function_signature
*
6335 builtin_builder::_read_first_invocation(const glsl_type
*type
)
6337 ir_variable
*value
= in_var(type
, "value");
6339 MAKE_SIG(type
, shader_ballot
, 1, value
);
6340 ir_variable
*retval
= body
.make_temp(type
, "retval");
6342 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_first_invocation"),
6343 retval
, sig
->parameters
));
6344 body
.emit(ret(retval
));
6348 ir_function_signature
*
6349 builtin_builder::_read_invocation_intrinsic(const glsl_type
*type
)
6351 ir_variable
*value
= in_var(type
, "value");
6352 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6353 MAKE_INTRINSIC(type
, ir_intrinsic_read_invocation
, shader_ballot
,
6354 2, value
, invocation
);
6358 ir_function_signature
*
6359 builtin_builder::_read_invocation(const glsl_type
*type
)
6361 ir_variable
*value
= in_var(type
, "value");
6362 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6364 MAKE_SIG(type
, shader_ballot
, 2, value
, invocation
);
6365 ir_variable
*retval
= body
.make_temp(type
, "retval");
6367 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_invocation"),
6368 retval
, sig
->parameters
));
6369 body
.emit(ret(retval
));
6373 ir_function_signature
*
6374 builtin_builder::_invocation_interlock_intrinsic(builtin_available_predicate avail
,
6375 enum ir_intrinsic_id id
)
6377 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6381 ir_function_signature
*
6382 builtin_builder::_invocation_interlock(const char *intrinsic_name
,
6383 builtin_available_predicate avail
)
6385 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6386 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6387 NULL
, sig
->parameters
));
6391 ir_function_signature
*
6392 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
6393 const glsl_type
*type
)
6395 MAKE_INTRINSIC(type
, ir_intrinsic_shader_clock
, avail
, 0);
6399 ir_function_signature
*
6400 builtin_builder::_shader_clock(builtin_available_predicate avail
,
6401 const glsl_type
*type
)
6403 MAKE_SIG(type
, avail
, 0);
6405 ir_variable
*retval
= body
.make_temp(glsl_type::uvec2_type
, "clock_retval");
6407 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
6408 retval
, sig
->parameters
));
6410 if (type
== glsl_type::uint64_t_type
) {
6411 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, retval
)));
6413 body
.emit(ret(retval
));
6419 ir_function_signature
*
6420 builtin_builder::_vote_intrinsic(builtin_available_predicate avail
,
6421 enum ir_intrinsic_id id
)
6423 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6424 MAKE_INTRINSIC(glsl_type::bool_type
, id
, avail
, 1, value
);
6428 ir_function_signature
*
6429 builtin_builder::_vote(const char *intrinsic_name
,
6430 builtin_available_predicate avail
)
6432 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6434 MAKE_SIG(glsl_type::bool_type
, avail
, 1, value
);
6436 ir_variable
*retval
= body
.make_temp(glsl_type::bool_type
, "retval");
6438 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6439 retval
, sig
->parameters
));
6440 body
.emit(ret(retval
));
6446 /******************************************************************************/
6448 /* The singleton instance of builtin_builder. */
6449 static builtin_builder builtins
;
6450 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
6453 * External API (exposing the built-in module to the rest of the compiler):
6457 _mesa_glsl_initialize_builtin_functions()
6459 mtx_lock(&builtins_lock
);
6460 builtins
.initialize();
6461 mtx_unlock(&builtins_lock
);
6465 _mesa_glsl_release_builtin_functions()
6467 mtx_lock(&builtins_lock
);
6469 mtx_unlock(&builtins_lock
);
6472 ir_function_signature
*
6473 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
6474 const char *name
, exec_list
*actual_parameters
)
6476 ir_function_signature
*s
;
6477 mtx_lock(&builtins_lock
);
6478 s
= builtins
.find(state
, name
, actual_parameters
);
6479 mtx_unlock(&builtins_lock
);
6485 _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state
*state
, const char *name
)
6489 mtx_lock(&builtins_lock
);
6490 f
= builtins
.shader
->symbols
->get_function(name
);
6492 foreach_in_list(ir_function_signature
, sig
, &f
->signatures
) {
6493 if (sig
->is_builtin_available(state
)) {
6499 mtx_unlock(&builtins_lock
);
6505 _mesa_glsl_get_builtin_function_shader()
6507 return builtins
.shader
;
6512 * Get the function signature for main from a shader
6514 ir_function_signature
*
6515 _mesa_get_main_function_signature(glsl_symbol_table
*symbols
)
6517 ir_function
*const f
= symbols
->get_function("main");
6519 exec_list void_parameters
;
6521 /* Look for the 'void main()' signature and ensure that it's defined.
6522 * This keeps the linker from accidentally pick a shader that just
6523 * contains a prototype for main.
6525 * We don't have to check for multiple definitions of main (in multiple
6526 * shaders) because that would have already been caught above.
6528 ir_function_signature
*sig
=
6529 f
->matching_signature(NULL
, &void_parameters
, false);
6530 if ((sig
!= NULL
) && sig
->is_defined
) {