2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * \file builtin_functions.cpp
27 * Support for GLSL built-in functions.
29 * This file is split into several main components:
31 * 1. Availability predicates
33 * A series of small functions that check whether the current shader
34 * supports the version/extensions required to expose a built-in.
36 * 2. Core builtin_builder class functionality
38 * 3. Lists of built-in functions
40 * The builtin_builder::create_builtins() function contains lists of all
41 * built-in function signatures, where they're available, what types they
44 * 4. Implementations of built-in function signatures
46 * A series of functions which create ir_function_signatures and emit IR
47 * via ir_builder to implement them.
51 * A few functions the rest of the compiler can use to interact with the
52 * built-in function module. For example, searching for a built-in by
53 * name and parameters.
58 * Unfortunately, some versions of MinGW produce bad code if this file
59 * is compiled with -O2 or -O3. The resulting driver will crash in random
60 * places if the app uses GLSL.
61 * The work-around is to disable optimizations for just this file. Luckily,
62 * this code is basically just executed once.
64 * MinGW 4.6.3 (in Ubuntu 13.10) does not have this bug.
65 * MinGW 5.3.1 (in Ubuntu 16.04) definitely has this bug.
66 * MinGW 6.2.0 (in Ubuntu 16.10) definitely has this bug.
67 * MinGW x.y.z - don't know. Assume versions after 4.6.x are buggy
70 #if defined(__MINGW32__) && ((__GNUC__ * 100) + __GNUC_MINOR >= 407)
71 #warning "disabling optimizations for this file to work around compiler bug"
72 #pragma GCC optimize("O1")
78 #include "main/mtypes.h"
79 #include "main/shaderobj.h"
80 #include "ir_builder.h"
81 #include "glsl_parser_extras.h"
82 #include "program/prog_instruction.h"
84 #include "builtin_functions.h"
85 #include "util/hash_table.h"
87 #define M_PIf ((float) M_PI)
88 #define M_PI_2f ((float) M_PI_2)
89 #define M_PI_4f ((float) M_PI_4)
91 using namespace ir_builder
;
94 * Availability predicates:
98 always_available(const _mesa_glsl_parse_state
*)
104 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
106 return state
->stage
== MESA_SHADER_VERTEX
&&
107 (state
->compat_shader
|| state
->ARB_compatibility_enable
) &&
112 fs_only(const _mesa_glsl_parse_state
*state
)
114 return state
->stage
== MESA_SHADER_FRAGMENT
;
118 gs_only(const _mesa_glsl_parse_state
*state
)
120 return state
->stage
== MESA_SHADER_GEOMETRY
;
124 v110(const _mesa_glsl_parse_state
*state
)
126 return !state
->es_shader
;
130 v110_fs_only(const _mesa_glsl_parse_state
*state
)
132 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
136 v120(const _mesa_glsl_parse_state
*state
)
138 return state
->is_version(120, 300);
142 v130(const _mesa_glsl_parse_state
*state
)
144 return state
->is_version(130, 300);
148 v130_desktop(const _mesa_glsl_parse_state
*state
)
150 return state
->is_version(130, 0);
154 v460_desktop(const _mesa_glsl_parse_state
*state
)
156 return state
->is_version(460, 0);
160 v130_fs_only(const _mesa_glsl_parse_state
*state
)
162 return state
->is_version(130, 300) &&
163 state
->stage
== MESA_SHADER_FRAGMENT
;
167 v140_or_es3(const _mesa_glsl_parse_state
*state
)
169 return state
->is_version(140, 300);
173 v400_fs_only(const _mesa_glsl_parse_state
*state
)
175 return state
->is_version(400, 0) &&
176 state
->stage
== MESA_SHADER_FRAGMENT
;
180 texture_rectangle(const _mesa_glsl_parse_state
*state
)
182 return state
->ARB_texture_rectangle_enable
;
186 texture_external(const _mesa_glsl_parse_state
*state
)
188 return state
->OES_EGL_image_external_enable
;
192 texture_external_es3(const _mesa_glsl_parse_state
*state
)
194 return state
->OES_EGL_image_external_essl3_enable
&&
196 state
->is_version(0, 300);
199 /** True if texturing functions with explicit LOD are allowed. */
201 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
203 /* Texturing functions with "Lod" in their name exist:
204 * - In the vertex shader stage (for all languages)
205 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
206 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
208 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
209 * don't need to explicitly check state->es_shader.
211 return state
->stage
== MESA_SHADER_VERTEX
||
212 state
->is_version(130, 300) ||
213 state
->ARB_shader_texture_lod_enable
;
217 v110_lod(const _mesa_glsl_parse_state
*state
)
219 return !state
->es_shader
&& lod_exists_in_stage(state
);
223 texture_buffer(const _mesa_glsl_parse_state
*state
)
225 return state
->is_version(140, 320) ||
226 state
->EXT_texture_buffer_enable
||
227 state
->OES_texture_buffer_enable
;
231 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
233 return state
->ARB_shader_texture_lod_enable
;
237 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
239 return state
->ARB_shader_texture_lod_enable
&&
240 state
->ARB_texture_rectangle_enable
;
244 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
246 return state
->is_version(330, 300) ||
247 state
->ARB_shader_bit_encoding_enable
||
248 state
->ARB_gpu_shader5_enable
;
252 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
254 return state
->is_version(450, 310) ||
255 state
->ARB_ES3_1_compatibility_enable
||
256 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
260 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
262 return state
->ARB_shading_language_packing_enable
||
263 state
->is_version(420, 300);
267 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
269 return state
->ARB_shading_language_packing_enable
||
270 state
->ARB_gpu_shader5_enable
||
271 state
->is_version(400, 300);
275 gpu_shader5(const _mesa_glsl_parse_state
*state
)
277 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
281 gpu_shader5_es(const _mesa_glsl_parse_state
*state
)
283 return state
->is_version(400, 320) ||
284 state
->ARB_gpu_shader5_enable
||
285 state
->EXT_gpu_shader5_enable
||
286 state
->OES_gpu_shader5_enable
;
290 gpu_shader5_or_OES_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
292 return state
->is_version(400, 320) ||
293 state
->ARB_gpu_shader5_enable
||
294 state
->EXT_texture_cube_map_array_enable
||
295 state
->OES_texture_cube_map_array_enable
;
299 es31_not_gs5(const _mesa_glsl_parse_state
*state
)
301 return state
->is_version(0, 310) && !gpu_shader5_es(state
);
305 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
307 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
311 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
313 return state
->ARB_shading_language_packing_enable
||
314 state
->ARB_gpu_shader5_enable
||
315 state
->is_version(400, 310);
319 gpu_shader5_or_es31_or_integer_functions(const _mesa_glsl_parse_state
*state
)
321 return gpu_shader5_or_es31(state
) ||
322 state
->MESA_shader_integer_functions_enable
;
326 fs_interpolate_at(const _mesa_glsl_parse_state
*state
)
328 return state
->stage
== MESA_SHADER_FRAGMENT
&&
329 (state
->is_version(400, 320) ||
330 state
->ARB_gpu_shader5_enable
||
331 state
->OES_shader_multisample_interpolation_enable
);
336 texture_array_lod(const _mesa_glsl_parse_state
*state
)
338 return lod_exists_in_stage(state
) &&
339 state
->EXT_texture_array_enable
;
343 fs_texture_array(const _mesa_glsl_parse_state
*state
)
345 return state
->stage
== MESA_SHADER_FRAGMENT
&&
346 state
->EXT_texture_array_enable
;
350 texture_array(const _mesa_glsl_parse_state
*state
)
352 return state
->EXT_texture_array_enable
;
356 texture_multisample(const _mesa_glsl_parse_state
*state
)
358 return state
->is_version(150, 310) ||
359 state
->ARB_texture_multisample_enable
;
363 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
365 return state
->is_version(150, 320) ||
366 state
->ARB_texture_multisample_enable
||
367 state
->OES_texture_storage_multisample_2d_array_enable
;
371 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
373 return texture_multisample(state
) &&
374 state
->EXT_shader_samples_identical_enable
;
378 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
380 return texture_multisample_array(state
) &&
381 state
->EXT_shader_samples_identical_enable
;
385 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
387 return state
->stage
== MESA_SHADER_FRAGMENT
&&
388 state
->has_texture_cube_map_array();
392 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
394 return state
->has_texture_cube_map_array();
398 texture_query_levels(const _mesa_glsl_parse_state
*state
)
400 return state
->is_version(430, 0) ||
401 state
->ARB_texture_query_levels_enable
;
405 texture_query_lod(const _mesa_glsl_parse_state
*state
)
407 return state
->stage
== MESA_SHADER_FRAGMENT
&&
408 state
->ARB_texture_query_lod_enable
;
412 texture_gather_cube_map_array(const _mesa_glsl_parse_state
*state
)
414 return state
->is_version(400, 320) ||
415 state
->ARB_texture_gather_enable
||
416 state
->ARB_gpu_shader5_enable
||
417 state
->EXT_texture_cube_map_array_enable
||
418 state
->OES_texture_cube_map_array_enable
;
422 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
424 return state
->is_version(400, 310) ||
425 state
->ARB_texture_gather_enable
||
426 state
->ARB_gpu_shader5_enable
;
429 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
430 * used for relaxation of const offset requirements.
433 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
435 return !state
->is_version(400, 320) &&
436 !state
->ARB_gpu_shader5_enable
&&
437 !state
->EXT_gpu_shader5_enable
&&
438 !state
->OES_gpu_shader5_enable
&&
439 (state
->ARB_texture_gather_enable
||
440 state
->is_version(0, 310));
443 /* Desktop GL or OES_standard_derivatives + fragment shader only */
445 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
447 return state
->stage
== MESA_SHADER_FRAGMENT
&&
448 (state
->is_version(110, 300) ||
449 state
->OES_standard_derivatives_enable
);
453 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
455 return state
->stage
== MESA_SHADER_FRAGMENT
&&
456 (state
->is_version(450, 0) ||
457 state
->ARB_derivative_control_enable
);
461 tex1d_lod(const _mesa_glsl_parse_state
*state
)
463 return !state
->es_shader
&& lod_exists_in_stage(state
);
466 /** True if sampler3D exists */
468 tex3d(const _mesa_glsl_parse_state
*state
)
470 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
471 * OES_texture_3D extension, and in GLSL ES 3.00.
473 return !state
->es_shader
||
474 state
->OES_texture_3D_enable
||
475 state
->language_version
>= 300;
479 fs_tex3d(const _mesa_glsl_parse_state
*state
)
481 return state
->stage
== MESA_SHADER_FRAGMENT
&&
482 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
486 tex3d_lod(const _mesa_glsl_parse_state
*state
)
488 return tex3d(state
) && lod_exists_in_stage(state
);
492 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
494 return state
->has_atomic_counters();
498 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
500 return state
->ARB_shader_atomic_counter_ops_enable
;
504 shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
506 return state
->ARB_shader_atomic_counter_ops_enable
|| v460_desktop(state
);
510 shader_ballot(const _mesa_glsl_parse_state
*state
)
512 return state
->ARB_shader_ballot_enable
;
516 supports_arb_fragment_shader_interlock(const _mesa_glsl_parse_state
*state
)
518 return state
->ARB_fragment_shader_interlock_enable
;
522 shader_clock(const _mesa_glsl_parse_state
*state
)
524 return state
->ARB_shader_clock_enable
;
528 shader_clock_int64(const _mesa_glsl_parse_state
*state
)
530 return state
->ARB_shader_clock_enable
&&
531 state
->ARB_gpu_shader_int64_enable
;
535 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
537 return state
->has_shader_storage_buffer_objects();
541 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
543 return state
->AMD_shader_trinary_minmax_enable
;
547 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
549 return (state
->is_version(420, 310) ||
550 state
->ARB_shader_image_load_store_enable
);
554 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
556 return (state
->is_version(420, 320) ||
557 state
->ARB_shader_image_load_store_enable
||
558 state
->OES_shader_image_atomic_enable
);
562 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
564 return (state
->is_version(450, 320) ||
565 state
->ARB_ES3_1_compatibility_enable
||
566 state
->OES_shader_image_atomic_enable
);
570 shader_image_size(const _mesa_glsl_parse_state
*state
)
572 return state
->is_version(430, 310) ||
573 state
->ARB_shader_image_size_enable
;
577 shader_samples(const _mesa_glsl_parse_state
*state
)
579 return state
->is_version(450, 0) ||
580 state
->ARB_shader_texture_image_samples_enable
;
584 gs_streams(const _mesa_glsl_parse_state
*state
)
586 return gpu_shader5(state
) && gs_only(state
);
590 fp64(const _mesa_glsl_parse_state
*state
)
592 return state
->has_double();
596 int64(const _mesa_glsl_parse_state
*state
)
598 return state
->has_int64();
602 int64_fp64(const _mesa_glsl_parse_state
*state
)
604 return state
->has_int64() && state
->has_double();
608 compute_shader(const _mesa_glsl_parse_state
*state
)
610 return state
->stage
== MESA_SHADER_COMPUTE
;
614 compute_shader_supported(const _mesa_glsl_parse_state
*state
)
616 return state
->has_compute_shader();
620 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
622 return compute_shader(state
) || shader_storage_buffer_object(state
);
626 barrier_supported(const _mesa_glsl_parse_state
*state
)
628 return compute_shader(state
) ||
629 state
->stage
== MESA_SHADER_TESS_CTRL
;
633 vote(const _mesa_glsl_parse_state
*state
)
635 return state
->ARB_shader_group_vote_enable
;
639 vote_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
641 return state
->ARB_shader_group_vote_enable
|| v460_desktop(state
);
645 integer_functions_supported(const _mesa_glsl_parse_state
*state
)
647 return state
->extensions
->MESA_shader_integer_functions
;
651 /******************************************************************************/
656 * builtin_builder: A singleton object representing the core of the built-in
659 * It generates IR for every built-in function signature, and organizes them
662 class builtin_builder
{
669 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
670 const char *name
, exec_list
*actual_parameters
);
673 * A shader to hold all the built-in signatures; created by this module.
675 * This includes signatures for every built-in, regardless of version or
676 * enabled extensions. The availability predicate associated with each
677 * signature allows matching_signature() to filter out the irrelevant ones.
684 void create_shader();
685 void create_intrinsics();
686 void create_builtins();
689 * IR builder helpers:
691 * These convenience functions assist in emitting IR, but don't necessarily
692 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
695 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
696 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
697 ir_constant
*imm(float f
, unsigned vector_elements
=1);
698 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
699 ir_constant
*imm(int i
, unsigned vector_elements
=1);
700 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
701 ir_constant
*imm(double d
, unsigned vector_elements
=1);
702 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
703 ir_dereference_variable
*var_ref(ir_variable
*var
);
704 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
705 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
707 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
708 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
711 * Call function \param f with parameters specified as the linked
712 * list \param params of \c ir_variable objects. \param ret should
713 * point to the ir_variable that will hold the function return
714 * value, or be \c NULL if the function has void return type.
716 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
718 /** Create a new function and add the given signatures. */
719 void add_function(const char *name
, ...);
721 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
722 unsigned num_arguments
,
726 * Create a new image built-in function for all known image types.
727 * \p flags is a bitfield of \c image_function_flags flags.
729 void add_image_function(const char *name
,
730 const char *intrinsic_name
,
731 image_prototype_ctr prototype
,
732 unsigned num_arguments
,
734 enum ir_intrinsic_id id
);
737 * Create new functions for all known image built-ins and types.
738 * If \p glsl is \c true, use the GLSL built-in names and emit code
739 * to call into the actual compiler intrinsic. If \p glsl is
740 * false, emit a function prototype with no body for each image
743 void add_image_functions(bool glsl
);
745 ir_function_signature
*new_sig(const glsl_type
*return_type
,
746 builtin_available_predicate avail
,
747 int num_params
, ...);
750 * Function signature generators:
753 ir_function_signature
*unop(builtin_available_predicate avail
,
754 ir_expression_operation opcode
,
755 const glsl_type
*return_type
,
756 const glsl_type
*param_type
);
757 ir_function_signature
*binop(builtin_available_predicate avail
,
758 ir_expression_operation opcode
,
759 const glsl_type
*return_type
,
760 const glsl_type
*param0_type
,
761 const glsl_type
*param1_type
,
762 bool swap_operands
= false);
764 #define B0(X) ir_function_signature *_##X();
765 #define B1(X) ir_function_signature *_##X(const glsl_type *);
766 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
767 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
768 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
769 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
806 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
807 const glsl_type
*val_type
,
808 const glsl_type
*blend_type
);
818 BA1(doubleBitsToInt64
)
819 BA1(doubleBitsToUint64
)
820 BA1(int64BitsToDouble
)
821 BA1(uint64BitsToDouble
)
823 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
824 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
825 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
826 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
827 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
828 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
829 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
830 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
831 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
832 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
833 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
834 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
835 ir_function_signature
*_packInt2x32(builtin_available_predicate avail
);
836 ir_function_signature
*_unpackInt2x32(builtin_available_predicate avail
);
837 ir_function_signature
*_packUint2x32(builtin_available_predicate avail
);
838 ir_function_signature
*_unpackUint2x32(builtin_available_predicate avail
);
851 BA1(determinant_mat2
);
852 BA1(determinant_mat3
);
853 BA1(determinant_mat4
);
861 BA1(greaterThanEqual
);
870 /** Flags to _texture() */
871 #define TEX_PROJECT 1
873 #define TEX_COMPONENT 4
874 #define TEX_OFFSET_NONCONST 8
875 #define TEX_OFFSET_ARRAY 16
877 ir_function_signature
*_texture(ir_texture_opcode opcode
,
878 builtin_available_predicate avail
,
879 const glsl_type
*return_type
,
880 const glsl_type
*sampler_type
,
881 const glsl_type
*coord_type
,
883 BA1(textureCubeArrayShadow
);
884 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
885 const glsl_type
*return_type
,
886 const glsl_type
*sampler_type
,
887 const glsl_type
*coord_type
,
888 const glsl_type
*offset_type
= NULL
);
892 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
893 const glsl_type
*stream_type
);
894 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
895 const glsl_type
*stream_type
);
898 BA2(textureQueryLod
);
899 BA1(textureQueryLevels
);
900 BA2(textureSamplesIdentical
);
928 B1(interpolateAtCentroid
)
929 B1(interpolateAtOffset
)
930 B1(interpolateAtSample
)
932 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
,
933 enum ir_intrinsic_id id
);
934 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
,
935 enum ir_intrinsic_id id
);
936 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
,
937 enum ir_intrinsic_id id
);
938 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
939 builtin_available_predicate avail
);
940 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
941 builtin_available_predicate avail
);
942 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
943 builtin_available_predicate avail
);
945 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
946 const glsl_type
*type
,
947 enum ir_intrinsic_id id
);
948 ir_function_signature
*_atomic_op2(const char *intrinsic
,
949 builtin_available_predicate avail
,
950 const glsl_type
*type
);
951 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
952 const glsl_type
*type
,
953 enum ir_intrinsic_id id
);
954 ir_function_signature
*_atomic_op3(const char *intrinsic
,
955 builtin_available_predicate avail
,
956 const glsl_type
*type
);
962 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
963 unsigned num_arguments
,
965 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
966 unsigned num_arguments
,
968 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
969 unsigned num_arguments
,
971 ir_function_signature
*_image(image_prototype_ctr prototype
,
972 const glsl_type
*image_type
,
973 const char *intrinsic_name
,
974 unsigned num_arguments
,
976 enum ir_intrinsic_id id
);
978 ir_function_signature
*_memory_barrier_intrinsic(
979 builtin_available_predicate avail
,
980 enum ir_intrinsic_id id
);
981 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
982 builtin_available_predicate avail
);
984 ir_function_signature
*_ballot_intrinsic();
985 ir_function_signature
*_ballot();
986 ir_function_signature
*_read_first_invocation_intrinsic(const glsl_type
*type
);
987 ir_function_signature
*_read_first_invocation(const glsl_type
*type
);
988 ir_function_signature
*_read_invocation_intrinsic(const glsl_type
*type
);
989 ir_function_signature
*_read_invocation(const glsl_type
*type
);
992 ir_function_signature
*_invocation_interlock_intrinsic(
993 builtin_available_predicate avail
,
994 enum ir_intrinsic_id id
);
995 ir_function_signature
*_invocation_interlock(
996 const char *intrinsic_name
,
997 builtin_available_predicate avail
);
999 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
1000 const glsl_type
*type
);
1001 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
1002 const glsl_type
*type
);
1004 ir_function_signature
*_vote_intrinsic(builtin_available_predicate avail
,
1005 enum ir_intrinsic_id id
);
1006 ir_function_signature
*_vote(const char *intrinsic_name
,
1007 builtin_available_predicate avail
);
1018 enum image_function_flags
{
1019 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
1020 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
1021 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
1022 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
1023 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
1024 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
1025 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
1026 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
1027 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8)
1030 } /* anonymous namespace */
1033 * Core builtin_builder functionality:
1036 builtin_builder::builtin_builder()
1042 builtin_builder::~builtin_builder()
1044 ralloc_free(mem_ctx
);
1047 ir_function_signature
*
1048 builtin_builder::find(_mesa_glsl_parse_state
*state
,
1049 const char *name
, exec_list
*actual_parameters
)
1051 /* The shader currently being compiled requested a built-in function;
1052 * it needs to link against builtin_builder::shader in order to get them.
1054 * Even if we don't find a matching signature, we still need to do this so
1055 * that the "no matching signature" error will list potential candidates
1056 * from the available built-ins.
1058 state
->uses_builtin_functions
= true;
1060 ir_function
*f
= shader
->symbols
->get_function(name
);
1064 ir_function_signature
*sig
=
1065 f
->matching_signature(state
, actual_parameters
, true);
1073 builtin_builder::initialize()
1075 /* If already initialized, don't do it again. */
1076 if (mem_ctx
!= NULL
)
1079 mem_ctx
= ralloc_context(NULL
);
1081 create_intrinsics();
1086 builtin_builder::release()
1088 ralloc_free(mem_ctx
);
1091 ralloc_free(shader
);
1096 builtin_builder::create_shader()
1098 /* The target doesn't actually matter. There's no target for generic
1099 * GLSL utility code that could be linked against any stage, so just
1100 * arbitrarily pick GL_VERTEX_SHADER.
1102 shader
= _mesa_new_shader(0, MESA_SHADER_VERTEX
);
1103 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
1109 * Create ir_function and ir_function_signature objects for each
1113 builtin_builder::create_intrinsics()
1115 add_function("__intrinsic_atomic_read",
1116 _atomic_counter_intrinsic(shader_atomic_counters
,
1117 ir_intrinsic_atomic_counter_read
),
1119 add_function("__intrinsic_atomic_increment",
1120 _atomic_counter_intrinsic(shader_atomic_counters
,
1121 ir_intrinsic_atomic_counter_increment
),
1123 add_function("__intrinsic_atomic_predecrement",
1124 _atomic_counter_intrinsic(shader_atomic_counters
,
1125 ir_intrinsic_atomic_counter_predecrement
),
1128 add_function("__intrinsic_atomic_add",
1129 _atomic_intrinsic2(buffer_atomics_supported
,
1130 glsl_type::uint_type
,
1131 ir_intrinsic_generic_atomic_add
),
1132 _atomic_intrinsic2(buffer_atomics_supported
,
1133 glsl_type::int_type
,
1134 ir_intrinsic_generic_atomic_add
),
1135 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1136 ir_intrinsic_atomic_counter_add
),
1138 add_function("__intrinsic_atomic_min",
1139 _atomic_intrinsic2(buffer_atomics_supported
,
1140 glsl_type::uint_type
,
1141 ir_intrinsic_generic_atomic_min
),
1142 _atomic_intrinsic2(buffer_atomics_supported
,
1143 glsl_type::int_type
,
1144 ir_intrinsic_generic_atomic_min
),
1145 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1146 ir_intrinsic_atomic_counter_min
),
1148 add_function("__intrinsic_atomic_max",
1149 _atomic_intrinsic2(buffer_atomics_supported
,
1150 glsl_type::uint_type
,
1151 ir_intrinsic_generic_atomic_max
),
1152 _atomic_intrinsic2(buffer_atomics_supported
,
1153 glsl_type::int_type
,
1154 ir_intrinsic_generic_atomic_max
),
1155 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1156 ir_intrinsic_atomic_counter_max
),
1158 add_function("__intrinsic_atomic_and",
1159 _atomic_intrinsic2(buffer_atomics_supported
,
1160 glsl_type::uint_type
,
1161 ir_intrinsic_generic_atomic_and
),
1162 _atomic_intrinsic2(buffer_atomics_supported
,
1163 glsl_type::int_type
,
1164 ir_intrinsic_generic_atomic_and
),
1165 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1166 ir_intrinsic_atomic_counter_and
),
1168 add_function("__intrinsic_atomic_or",
1169 _atomic_intrinsic2(buffer_atomics_supported
,
1170 glsl_type::uint_type
,
1171 ir_intrinsic_generic_atomic_or
),
1172 _atomic_intrinsic2(buffer_atomics_supported
,
1173 glsl_type::int_type
,
1174 ir_intrinsic_generic_atomic_or
),
1175 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1176 ir_intrinsic_atomic_counter_or
),
1178 add_function("__intrinsic_atomic_xor",
1179 _atomic_intrinsic2(buffer_atomics_supported
,
1180 glsl_type::uint_type
,
1181 ir_intrinsic_generic_atomic_xor
),
1182 _atomic_intrinsic2(buffer_atomics_supported
,
1183 glsl_type::int_type
,
1184 ir_intrinsic_generic_atomic_xor
),
1185 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1186 ir_intrinsic_atomic_counter_xor
),
1188 add_function("__intrinsic_atomic_exchange",
1189 _atomic_intrinsic2(buffer_atomics_supported
,
1190 glsl_type::uint_type
,
1191 ir_intrinsic_generic_atomic_exchange
),
1192 _atomic_intrinsic2(buffer_atomics_supported
,
1193 glsl_type::int_type
,
1194 ir_intrinsic_generic_atomic_exchange
),
1195 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1196 ir_intrinsic_atomic_counter_exchange
),
1198 add_function("__intrinsic_atomic_comp_swap",
1199 _atomic_intrinsic3(buffer_atomics_supported
,
1200 glsl_type::uint_type
,
1201 ir_intrinsic_generic_atomic_comp_swap
),
1202 _atomic_intrinsic3(buffer_atomics_supported
,
1203 glsl_type::int_type
,
1204 ir_intrinsic_generic_atomic_comp_swap
),
1205 _atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop
,
1206 ir_intrinsic_atomic_counter_comp_swap
),
1209 add_image_functions(false);
1211 add_function("__intrinsic_memory_barrier",
1212 _memory_barrier_intrinsic(shader_image_load_store
,
1213 ir_intrinsic_memory_barrier
),
1215 add_function("__intrinsic_group_memory_barrier",
1216 _memory_barrier_intrinsic(compute_shader
,
1217 ir_intrinsic_group_memory_barrier
),
1219 add_function("__intrinsic_memory_barrier_atomic_counter",
1220 _memory_barrier_intrinsic(compute_shader_supported
,
1221 ir_intrinsic_memory_barrier_atomic_counter
),
1223 add_function("__intrinsic_memory_barrier_buffer",
1224 _memory_barrier_intrinsic(compute_shader_supported
,
1225 ir_intrinsic_memory_barrier_buffer
),
1227 add_function("__intrinsic_memory_barrier_image",
1228 _memory_barrier_intrinsic(compute_shader_supported
,
1229 ir_intrinsic_memory_barrier_image
),
1231 add_function("__intrinsic_memory_barrier_shared",
1232 _memory_barrier_intrinsic(compute_shader
,
1233 ir_intrinsic_memory_barrier_shared
),
1236 add_function("__intrinsic_begin_invocation_interlock",
1237 _invocation_interlock_intrinsic(
1238 supports_arb_fragment_shader_interlock
,
1239 ir_intrinsic_begin_invocation_interlock
), NULL
);
1241 add_function("__intrinsic_end_invocation_interlock",
1242 _invocation_interlock_intrinsic(
1243 supports_arb_fragment_shader_interlock
,
1244 ir_intrinsic_end_invocation_interlock
), NULL
);
1246 add_function("__intrinsic_shader_clock",
1247 _shader_clock_intrinsic(shader_clock
,
1248 glsl_type::uvec2_type
),
1251 add_function("__intrinsic_vote_all",
1252 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_all
),
1254 add_function("__intrinsic_vote_any",
1255 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_any
),
1257 add_function("__intrinsic_vote_eq",
1258 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_eq
),
1261 add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL
);
1263 add_function("__intrinsic_read_invocation",
1264 _read_invocation_intrinsic(glsl_type::float_type
),
1265 _read_invocation_intrinsic(glsl_type::vec2_type
),
1266 _read_invocation_intrinsic(glsl_type::vec3_type
),
1267 _read_invocation_intrinsic(glsl_type::vec4_type
),
1269 _read_invocation_intrinsic(glsl_type::int_type
),
1270 _read_invocation_intrinsic(glsl_type::ivec2_type
),
1271 _read_invocation_intrinsic(glsl_type::ivec3_type
),
1272 _read_invocation_intrinsic(glsl_type::ivec4_type
),
1274 _read_invocation_intrinsic(glsl_type::uint_type
),
1275 _read_invocation_intrinsic(glsl_type::uvec2_type
),
1276 _read_invocation_intrinsic(glsl_type::uvec3_type
),
1277 _read_invocation_intrinsic(glsl_type::uvec4_type
),
1280 add_function("__intrinsic_read_first_invocation",
1281 _read_first_invocation_intrinsic(glsl_type::float_type
),
1282 _read_first_invocation_intrinsic(glsl_type::vec2_type
),
1283 _read_first_invocation_intrinsic(glsl_type::vec3_type
),
1284 _read_first_invocation_intrinsic(glsl_type::vec4_type
),
1286 _read_first_invocation_intrinsic(glsl_type::int_type
),
1287 _read_first_invocation_intrinsic(glsl_type::ivec2_type
),
1288 _read_first_invocation_intrinsic(glsl_type::ivec3_type
),
1289 _read_first_invocation_intrinsic(glsl_type::ivec4_type
),
1291 _read_first_invocation_intrinsic(glsl_type::uint_type
),
1292 _read_first_invocation_intrinsic(glsl_type::uvec2_type
),
1293 _read_first_invocation_intrinsic(glsl_type::uvec3_type
),
1294 _read_first_invocation_intrinsic(glsl_type::uvec4_type
),
1300 * Create ir_function and ir_function_signature objects for each built-in.
1302 * Contains a list of every available built-in.
1305 builtin_builder::create_builtins()
1308 add_function(#NAME, \
1309 _##NAME(glsl_type::float_type), \
1310 _##NAME(glsl_type::vec2_type), \
1311 _##NAME(glsl_type::vec3_type), \
1312 _##NAME(glsl_type::vec4_type), \
1316 add_function(#NAME, \
1317 _##NAME(always_available, glsl_type::float_type), \
1318 _##NAME(always_available, glsl_type::vec2_type), \
1319 _##NAME(always_available, glsl_type::vec3_type), \
1320 _##NAME(always_available, glsl_type::vec4_type), \
1321 _##NAME(fp64, glsl_type::double_type), \
1322 _##NAME(fp64, glsl_type::dvec2_type), \
1323 _##NAME(fp64, glsl_type::dvec3_type), \
1324 _##NAME(fp64, glsl_type::dvec4_type), \
1327 #define FD130(NAME) \
1328 add_function(#NAME, \
1329 _##NAME(v130, glsl_type::float_type), \
1330 _##NAME(v130, glsl_type::vec2_type), \
1331 _##NAME(v130, glsl_type::vec3_type), \
1332 _##NAME(v130, glsl_type::vec4_type), \
1333 _##NAME(fp64, glsl_type::double_type), \
1334 _##NAME(fp64, glsl_type::dvec2_type), \
1335 _##NAME(fp64, glsl_type::dvec3_type), \
1336 _##NAME(fp64, glsl_type::dvec4_type), \
1339 #define FDGS5(NAME) \
1340 add_function(#NAME, \
1341 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1342 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1343 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1344 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1345 _##NAME(fp64, glsl_type::double_type), \
1346 _##NAME(fp64, glsl_type::dvec2_type), \
1347 _##NAME(fp64, glsl_type::dvec3_type), \
1348 _##NAME(fp64, glsl_type::dvec4_type), \
1352 add_function(#NAME, \
1353 _##NAME(glsl_type::float_type), \
1354 _##NAME(glsl_type::vec2_type), \
1355 _##NAME(glsl_type::vec3_type), \
1356 _##NAME(glsl_type::vec4_type), \
1357 _##NAME(glsl_type::int_type), \
1358 _##NAME(glsl_type::ivec2_type), \
1359 _##NAME(glsl_type::ivec3_type), \
1360 _##NAME(glsl_type::ivec4_type), \
1363 #define FI64(NAME) \
1364 add_function(#NAME, \
1365 _##NAME(always_available, glsl_type::float_type), \
1366 _##NAME(always_available, glsl_type::vec2_type), \
1367 _##NAME(always_available, glsl_type::vec3_type), \
1368 _##NAME(always_available, glsl_type::vec4_type), \
1369 _##NAME(always_available, glsl_type::int_type), \
1370 _##NAME(always_available, glsl_type::ivec2_type), \
1371 _##NAME(always_available, glsl_type::ivec3_type), \
1372 _##NAME(always_available, glsl_type::ivec4_type), \
1373 _##NAME(fp64, glsl_type::double_type), \
1374 _##NAME(fp64, glsl_type::dvec2_type), \
1375 _##NAME(fp64, glsl_type::dvec3_type), \
1376 _##NAME(fp64, glsl_type::dvec4_type), \
1377 _##NAME(int64, glsl_type::int64_t_type), \
1378 _##NAME(int64, glsl_type::i64vec2_type), \
1379 _##NAME(int64, glsl_type::i64vec3_type), \
1380 _##NAME(int64, glsl_type::i64vec4_type), \
1383 #define FIUD_VEC(NAME) \
1384 add_function(#NAME, \
1385 _##NAME(always_available, glsl_type::vec2_type), \
1386 _##NAME(always_available, glsl_type::vec3_type), \
1387 _##NAME(always_available, glsl_type::vec4_type), \
1389 _##NAME(always_available, glsl_type::ivec2_type), \
1390 _##NAME(always_available, glsl_type::ivec3_type), \
1391 _##NAME(always_available, glsl_type::ivec4_type), \
1393 _##NAME(v130, glsl_type::uvec2_type), \
1394 _##NAME(v130, glsl_type::uvec3_type), \
1395 _##NAME(v130, glsl_type::uvec4_type), \
1396 _##NAME(fp64, glsl_type::dvec2_type), \
1397 _##NAME(fp64, glsl_type::dvec3_type), \
1398 _##NAME(fp64, glsl_type::dvec4_type), \
1399 _##NAME(int64, glsl_type::int64_t_type), \
1400 _##NAME(int64, glsl_type::i64vec2_type), \
1401 _##NAME(int64, glsl_type::i64vec3_type), \
1402 _##NAME(int64, glsl_type::i64vec4_type), \
1403 _##NAME(int64, glsl_type::uint64_t_type), \
1404 _##NAME(int64, glsl_type::u64vec2_type), \
1405 _##NAME(int64, glsl_type::u64vec3_type), \
1406 _##NAME(int64, glsl_type::u64vec4_type), \
1410 add_function(#NAME, \
1411 _##NAME(glsl_type::int_type), \
1412 _##NAME(glsl_type::ivec2_type), \
1413 _##NAME(glsl_type::ivec3_type), \
1414 _##NAME(glsl_type::ivec4_type), \
1416 _##NAME(glsl_type::uint_type), \
1417 _##NAME(glsl_type::uvec2_type), \
1418 _##NAME(glsl_type::uvec3_type), \
1419 _##NAME(glsl_type::uvec4_type), \
1422 #define FIUBD_VEC(NAME) \
1423 add_function(#NAME, \
1424 _##NAME(always_available, glsl_type::vec2_type), \
1425 _##NAME(always_available, glsl_type::vec3_type), \
1426 _##NAME(always_available, glsl_type::vec4_type), \
1428 _##NAME(always_available, glsl_type::ivec2_type), \
1429 _##NAME(always_available, glsl_type::ivec3_type), \
1430 _##NAME(always_available, glsl_type::ivec4_type), \
1432 _##NAME(v130, glsl_type::uvec2_type), \
1433 _##NAME(v130, glsl_type::uvec3_type), \
1434 _##NAME(v130, glsl_type::uvec4_type), \
1436 _##NAME(always_available, glsl_type::bvec2_type), \
1437 _##NAME(always_available, glsl_type::bvec3_type), \
1438 _##NAME(always_available, glsl_type::bvec4_type), \
1440 _##NAME(fp64, glsl_type::dvec2_type), \
1441 _##NAME(fp64, glsl_type::dvec3_type), \
1442 _##NAME(fp64, glsl_type::dvec4_type), \
1443 _##NAME(int64, glsl_type::int64_t_type), \
1444 _##NAME(int64, glsl_type::i64vec2_type), \
1445 _##NAME(int64, glsl_type::i64vec3_type), \
1446 _##NAME(int64, glsl_type::i64vec4_type), \
1447 _##NAME(int64, glsl_type::uint64_t_type), \
1448 _##NAME(int64, glsl_type::u64vec2_type), \
1449 _##NAME(int64, glsl_type::u64vec3_type), \
1450 _##NAME(int64, glsl_type::u64vec4_type), \
1453 #define FIUD2_MIXED(NAME) \
1454 add_function(#NAME, \
1455 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1456 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1457 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1458 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1460 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1461 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1462 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1464 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1465 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1466 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1467 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1469 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1470 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1471 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1473 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1474 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1475 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1476 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1478 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1479 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1480 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1482 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1483 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1484 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1485 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1486 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1487 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1488 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1490 _##NAME(int64, glsl_type::int64_t_type, glsl_type::int64_t_type), \
1491 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::int64_t_type), \
1492 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::int64_t_type), \
1493 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::int64_t_type), \
1494 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::i64vec2_type), \
1495 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::i64vec3_type), \
1496 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::i64vec4_type), \
1497 _##NAME(int64, glsl_type::uint64_t_type, glsl_type::uint64_t_type), \
1498 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::uint64_t_type), \
1499 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::uint64_t_type), \
1500 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::uint64_t_type), \
1501 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::u64vec2_type), \
1502 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::u64vec3_type), \
1503 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::u64vec4_type), \
1514 add_function("atan",
1515 _atan(glsl_type::float_type
),
1516 _atan(glsl_type::vec2_type
),
1517 _atan(glsl_type::vec3_type
),
1518 _atan(glsl_type::vec4_type
),
1519 _atan2(glsl_type::float_type
),
1520 _atan2(glsl_type::vec2_type
),
1521 _atan2(glsl_type::vec3_type
),
1522 _atan2(glsl_type::vec4_type
),
1548 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1549 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1550 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1551 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1553 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1554 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1555 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1557 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1558 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1559 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1560 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1562 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1563 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1564 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1574 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1575 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1576 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1577 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1579 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1580 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1581 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1583 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1584 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1585 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1586 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1588 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1589 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1590 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1592 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1593 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1594 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1595 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1597 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1598 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1599 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1600 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1602 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1603 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1604 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1605 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1607 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1608 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1609 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1610 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1612 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1613 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1614 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1615 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1617 _mix_sel(int64
, glsl_type::int64_t_type
, glsl_type::bool_type
),
1618 _mix_sel(int64
, glsl_type::i64vec2_type
, glsl_type::bvec2_type
),
1619 _mix_sel(int64
, glsl_type::i64vec3_type
, glsl_type::bvec3_type
),
1620 _mix_sel(int64
, glsl_type::i64vec4_type
, glsl_type::bvec4_type
),
1622 _mix_sel(int64
, glsl_type::uint64_t_type
, glsl_type::bool_type
),
1623 _mix_sel(int64
, glsl_type::u64vec2_type
, glsl_type::bvec2_type
),
1624 _mix_sel(int64
, glsl_type::u64vec3_type
, glsl_type::bvec3_type
),
1625 _mix_sel(int64
, glsl_type::u64vec4_type
, glsl_type::bvec4_type
),
1628 add_function("step",
1629 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1630 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1631 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1632 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1634 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1635 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1636 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1637 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1638 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1639 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1640 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1642 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1643 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1644 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1647 add_function("smoothstep",
1648 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1649 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1650 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1651 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1653 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1654 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1655 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1656 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1657 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1658 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1659 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1661 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1662 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1663 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1671 add_function("intBitsToFloat",
1672 _intBitsToFloat(glsl_type::int_type
),
1673 _intBitsToFloat(glsl_type::ivec2_type
),
1674 _intBitsToFloat(glsl_type::ivec3_type
),
1675 _intBitsToFloat(glsl_type::ivec4_type
),
1677 add_function("uintBitsToFloat",
1678 _uintBitsToFloat(glsl_type::uint_type
),
1679 _uintBitsToFloat(glsl_type::uvec2_type
),
1680 _uintBitsToFloat(glsl_type::uvec3_type
),
1681 _uintBitsToFloat(glsl_type::uvec4_type
),
1684 add_function("doubleBitsToInt64",
1685 _doubleBitsToInt64(int64_fp64
, glsl_type::double_type
),
1686 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec2_type
),
1687 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec3_type
),
1688 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec4_type
),
1691 add_function("doubleBitsToUint64",
1692 _doubleBitsToUint64(int64_fp64
, glsl_type::double_type
),
1693 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec2_type
),
1694 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec3_type
),
1695 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec4_type
),
1698 add_function("int64BitsToDouble",
1699 _int64BitsToDouble(int64_fp64
, glsl_type::int64_t_type
),
1700 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec2_type
),
1701 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec3_type
),
1702 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec4_type
),
1705 add_function("uint64BitsToDouble",
1706 _uint64BitsToDouble(int64_fp64
, glsl_type::uint64_t_type
),
1707 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec2_type
),
1708 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec3_type
),
1709 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec4_type
),
1712 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1713 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1714 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1715 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1716 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1717 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1718 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1719 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1720 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1721 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1722 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1723 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1725 add_function("packInt2x32", _packInt2x32(int64
), NULL
);
1726 add_function("unpackInt2x32", _unpackInt2x32(int64
), NULL
);
1727 add_function("packUint2x32", _packUint2x32(int64
), NULL
);
1728 add_function("unpackUint2x32", _unpackUint2x32(int64
), NULL
);
1734 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1735 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1738 add_function("ftransform", _ftransform(), NULL
);
1743 add_function("matrixCompMult",
1744 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1745 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1746 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1747 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1748 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1749 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1750 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1751 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1752 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1753 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1754 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1755 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1756 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1757 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1758 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1759 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1760 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1761 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1763 add_function("outerProduct",
1764 _outerProduct(v120
, glsl_type::mat2_type
),
1765 _outerProduct(v120
, glsl_type::mat3_type
),
1766 _outerProduct(v120
, glsl_type::mat4_type
),
1767 _outerProduct(v120
, glsl_type::mat2x3_type
),
1768 _outerProduct(v120
, glsl_type::mat2x4_type
),
1769 _outerProduct(v120
, glsl_type::mat3x2_type
),
1770 _outerProduct(v120
, glsl_type::mat3x4_type
),
1771 _outerProduct(v120
, glsl_type::mat4x2_type
),
1772 _outerProduct(v120
, glsl_type::mat4x3_type
),
1773 _outerProduct(fp64
, glsl_type::dmat2_type
),
1774 _outerProduct(fp64
, glsl_type::dmat3_type
),
1775 _outerProduct(fp64
, glsl_type::dmat4_type
),
1776 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1777 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1778 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1779 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1780 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1781 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1783 add_function("determinant",
1784 _determinant_mat2(v120
, glsl_type::mat2_type
),
1785 _determinant_mat3(v120
, glsl_type::mat3_type
),
1786 _determinant_mat4(v120
, glsl_type::mat4_type
),
1787 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1788 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1789 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1792 add_function("inverse",
1793 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1794 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1795 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1796 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1797 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1798 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1800 add_function("transpose",
1801 _transpose(v120
, glsl_type::mat2_type
),
1802 _transpose(v120
, glsl_type::mat3_type
),
1803 _transpose(v120
, glsl_type::mat4_type
),
1804 _transpose(v120
, glsl_type::mat2x3_type
),
1805 _transpose(v120
, glsl_type::mat2x4_type
),
1806 _transpose(v120
, glsl_type::mat3x2_type
),
1807 _transpose(v120
, glsl_type::mat3x4_type
),
1808 _transpose(v120
, glsl_type::mat4x2_type
),
1809 _transpose(v120
, glsl_type::mat4x3_type
),
1810 _transpose(fp64
, glsl_type::dmat2_type
),
1811 _transpose(fp64
, glsl_type::dmat3_type
),
1812 _transpose(fp64
, glsl_type::dmat4_type
),
1813 _transpose(fp64
, glsl_type::dmat2x3_type
),
1814 _transpose(fp64
, glsl_type::dmat2x4_type
),
1815 _transpose(fp64
, glsl_type::dmat3x2_type
),
1816 _transpose(fp64
, glsl_type::dmat3x4_type
),
1817 _transpose(fp64
, glsl_type::dmat4x2_type
),
1818 _transpose(fp64
, glsl_type::dmat4x3_type
),
1821 FIUD_VEC(lessThanEqual
)
1822 FIUD_VEC(greaterThan
)
1823 FIUD_VEC(greaterThanEqual
)
1828 _any(glsl_type::bvec2_type
),
1829 _any(glsl_type::bvec3_type
),
1830 _any(glsl_type::bvec4_type
),
1834 _all(glsl_type::bvec2_type
),
1835 _all(glsl_type::bvec3_type
),
1836 _all(glsl_type::bvec4_type
),
1840 _not(glsl_type::bvec2_type
),
1841 _not(glsl_type::bvec3_type
),
1842 _not(glsl_type::bvec4_type
),
1845 add_function("textureSize",
1846 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1847 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1848 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1850 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1851 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1852 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1854 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1855 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1856 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1858 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1859 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1860 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1862 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1863 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1864 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1866 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1867 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1868 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1869 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1870 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1871 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1873 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1874 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1876 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1877 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1878 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1879 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1881 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1882 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1883 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1884 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1886 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1887 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1888 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1889 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1890 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1891 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1893 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1894 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1895 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1898 add_function("textureSamples",
1899 _textureSamples(shader_samples
, glsl_type::sampler2DMS_type
),
1900 _textureSamples(shader_samples
, glsl_type::isampler2DMS_type
),
1901 _textureSamples(shader_samples
, glsl_type::usampler2DMS_type
),
1903 _textureSamples(shader_samples
, glsl_type::sampler2DMSArray_type
),
1904 _textureSamples(shader_samples
, glsl_type::isampler2DMSArray_type
),
1905 _textureSamples(shader_samples
, glsl_type::usampler2DMSArray_type
),
1908 add_function("texture",
1909 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1910 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1911 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1913 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1914 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1915 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1917 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1918 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1919 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1921 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1922 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1923 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1925 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1926 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1927 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1929 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1930 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1931 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1933 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1934 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1935 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1937 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1938 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1939 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1941 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1942 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1943 /* samplerCubeArrayShadow is special; it has an extra parameter
1944 * for the shadow comparator since there is no vec5 type.
1946 _textureCubeArrayShadow(texture_cube_map_array
, glsl_type::samplerCubeArrayShadow_type
),
1948 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1949 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1950 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1952 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1954 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
1956 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1957 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1958 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1960 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1961 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1962 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1964 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1965 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1966 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1968 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1969 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1970 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1972 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1973 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1974 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1976 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1977 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1978 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1980 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1981 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1982 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1984 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1985 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1986 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1988 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1991 add_function("textureLod",
1992 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1993 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1994 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1996 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1997 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1998 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2000 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2001 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2002 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2004 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2005 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2006 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2008 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2009 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2011 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2012 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2013 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2015 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2016 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2017 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2019 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2020 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2021 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2023 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2026 add_function("textureOffset",
2027 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2028 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2029 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2031 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2032 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2033 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2035 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2036 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2037 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2039 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2040 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2041 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2043 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2045 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2046 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2048 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2049 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2050 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2052 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2053 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2054 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2056 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2057 /* The next one was forgotten in GLSL 1.30 spec. It's from
2058 * EXT_gpu_shader4 originally. It was added in 4.30 with the
2059 * wrong syntax. This was corrected in 4.40. 4.30 indicates
2060 * that it was intended to be included previously, so allow it
2063 _texture(ir_tex
, v130_desktop
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2065 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2066 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2067 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2069 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2070 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2071 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2073 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2074 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2075 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2077 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2078 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2080 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2081 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2082 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2084 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2085 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2086 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2088 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2091 add_function("textureProj",
2092 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2093 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2094 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2095 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2096 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2097 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2099 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2100 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2101 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2102 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2103 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2104 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2106 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2107 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2108 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2110 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2111 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2113 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2114 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2115 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2116 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2118 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2119 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2120 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2121 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2123 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2125 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2126 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2127 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2128 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2129 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2130 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2132 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2133 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2134 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2135 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2136 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2137 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2139 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2140 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2141 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2143 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2144 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2147 add_function("texelFetch",
2148 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
2149 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
2150 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
2152 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
2153 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
2154 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
2156 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
2157 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
2158 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
2160 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
2161 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
2162 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
2164 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
2165 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
2166 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
2168 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
2169 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
2170 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
2172 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
2173 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
2174 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
2176 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2177 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2178 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2180 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2181 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2182 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2184 _texelFetch(texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::ivec2_type
),
2189 add_function("texelFetchOffset",
2190 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2191 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2192 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2194 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2195 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2196 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2198 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2199 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2200 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2202 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2203 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2204 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2206 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2207 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2208 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2210 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2211 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2212 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2216 add_function("textureProjOffset",
2217 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2218 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2219 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2220 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2221 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2222 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2224 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2225 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2226 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2227 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2228 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2229 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2231 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2232 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2233 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2235 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2236 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2238 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2239 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2240 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2241 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2242 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2243 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2245 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2247 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2248 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2249 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2250 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2251 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2252 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2254 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2255 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2256 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2257 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2258 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2259 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2261 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2262 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2263 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2265 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2266 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2269 add_function("textureLodOffset",
2270 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2271 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2272 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2274 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2275 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2276 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2278 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2279 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2280 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2282 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2283 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2285 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2286 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2287 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2289 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2290 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2291 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2293 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2296 add_function("textureProjLod",
2297 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2298 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2299 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2300 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2301 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2302 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2304 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2305 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2306 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2307 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2308 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2309 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2311 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2312 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2313 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2315 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2316 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2319 add_function("textureProjLodOffset",
2320 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2321 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2322 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2323 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2324 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2325 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2327 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2328 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2329 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2330 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2331 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2332 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2334 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2335 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2336 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2338 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2339 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2342 add_function("textureGrad",
2343 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2344 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2345 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2347 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2348 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2349 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2351 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2352 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2353 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2355 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2356 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2357 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2359 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2360 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2361 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2363 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2365 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2366 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2367 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2369 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2370 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2371 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2373 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2374 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2375 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2377 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2378 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2379 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2381 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2382 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2385 add_function("textureGradOffset",
2386 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2387 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2388 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2390 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2391 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2392 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2394 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2395 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2396 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2398 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2399 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2400 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2402 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2404 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2405 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2407 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2408 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2409 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2411 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2412 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2413 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2415 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2416 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2419 add_function("textureProjGrad",
2420 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2421 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2422 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2423 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2424 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2425 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2427 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2428 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2429 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2430 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2431 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2432 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2434 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2435 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2436 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2438 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2439 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2440 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2441 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2442 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2443 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2445 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2447 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2448 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2451 add_function("textureProjGradOffset",
2452 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2453 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2454 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2455 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2456 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2457 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2459 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2460 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2461 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2462 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2463 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2464 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2466 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2467 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2468 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2470 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2471 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2472 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2473 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2474 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2475 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2477 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2479 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2480 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2483 add_function("EmitVertex", _EmitVertex(), NULL
);
2484 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2485 add_function("EmitStreamVertex",
2486 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2487 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2489 add_function("EndStreamPrimitive",
2490 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2491 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2493 add_function("barrier", _barrier(), NULL
);
2495 add_function("textureQueryLOD",
2496 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2497 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2498 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2500 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2501 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2502 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2504 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2505 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2506 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2508 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2509 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2510 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2512 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2513 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2514 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2516 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2517 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2518 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2520 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2521 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2522 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2524 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2525 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2526 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2527 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2528 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2529 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2532 add_function("textureQueryLod",
2533 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2534 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2535 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2537 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2538 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2539 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2541 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2542 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2543 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2545 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2546 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2547 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2549 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2550 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2551 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2553 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2554 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2555 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2557 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2558 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2559 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2561 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2562 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2563 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2564 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2565 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2566 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2569 add_function("textureQueryLevels",
2570 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1D_type
),
2571 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2D_type
),
2572 _textureQueryLevels(texture_query_levels
, glsl_type::sampler3D_type
),
2573 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCube_type
),
2574 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArray_type
),
2575 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArray_type
),
2576 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArray_type
),
2577 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DShadow_type
),
2578 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DShadow_type
),
2579 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeShadow_type
),
2580 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArrayShadow_type
),
2581 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArrayShadow_type
),
2582 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArrayShadow_type
),
2584 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1D_type
),
2585 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2D_type
),
2586 _textureQueryLevels(texture_query_levels
, glsl_type::isampler3D_type
),
2587 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCube_type
),
2588 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1DArray_type
),
2589 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2DArray_type
),
2590 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCubeArray_type
),
2592 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1D_type
),
2593 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2D_type
),
2594 _textureQueryLevels(texture_query_levels
, glsl_type::usampler3D_type
),
2595 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCube_type
),
2596 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1DArray_type
),
2597 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2DArray_type
),
2598 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCubeArray_type
),
2602 add_function("textureSamplesIdenticalEXT",
2603 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2604 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2605 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2607 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2608 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2609 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2612 add_function("texture1D",
2613 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2614 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2617 add_function("texture1DArray",
2618 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2619 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2622 add_function("texture1DProj",
2623 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2624 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2625 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2626 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2629 add_function("texture1DLod",
2630 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2633 add_function("texture1DArrayLod",
2634 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2637 add_function("texture1DProjLod",
2638 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2639 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2642 add_function("texture2D",
2643 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2644 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2645 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2648 add_function("texture2DArray",
2649 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2650 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2653 add_function("texture2DProj",
2654 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2655 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2656 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2657 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2658 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2659 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2662 add_function("texture2DLod",
2663 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2666 add_function("texture2DArrayLod",
2667 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2670 add_function("texture2DProjLod",
2671 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2672 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2675 add_function("texture3D",
2676 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2677 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2680 add_function("texture3DProj",
2681 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2682 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2685 add_function("texture3DLod",
2686 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2689 add_function("texture3DProjLod",
2690 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2693 add_function("textureCube",
2694 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2695 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2698 add_function("textureCubeLod",
2699 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2702 add_function("texture2DRect",
2703 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2706 add_function("texture2DRectProj",
2707 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2708 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2711 add_function("shadow1D",
2712 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2713 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2716 add_function("shadow1DArray",
2717 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2718 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2721 add_function("shadow2D",
2722 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2723 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2726 add_function("shadow2DArray",
2727 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2728 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2731 add_function("shadow1DProj",
2732 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2733 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2736 add_function("shadow2DProj",
2737 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2738 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2741 add_function("shadow1DLod",
2742 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2745 add_function("shadow2DLod",
2746 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2749 add_function("shadow1DArrayLod",
2750 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2753 add_function("shadow1DProjLod",
2754 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2757 add_function("shadow2DProjLod",
2758 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2761 add_function("shadow2DRect",
2762 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2765 add_function("shadow2DRectProj",
2766 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2769 add_function("texture1DGradARB",
2770 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2773 add_function("texture1DProjGradARB",
2774 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2775 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2778 add_function("texture2DGradARB",
2779 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2782 add_function("texture2DProjGradARB",
2783 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2784 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2787 add_function("texture3DGradARB",
2788 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2791 add_function("texture3DProjGradARB",
2792 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2795 add_function("textureCubeGradARB",
2796 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2799 add_function("shadow1DGradARB",
2800 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2803 add_function("shadow1DProjGradARB",
2804 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2807 add_function("shadow2DGradARB",
2808 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2811 add_function("shadow2DProjGradARB",
2812 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2815 add_function("texture2DRectGradARB",
2816 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2819 add_function("texture2DRectProjGradARB",
2820 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2821 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2824 add_function("shadow2DRectGradARB",
2825 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2828 add_function("shadow2DRectProjGradARB",
2829 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2832 add_function("textureGather",
2833 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2834 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2835 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2837 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2838 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2839 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2841 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2842 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2843 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2845 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2846 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2847 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2849 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2850 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2851 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2853 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2854 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2855 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2857 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2858 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2859 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2861 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2862 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2863 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2865 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2866 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2867 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2869 _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
),
2870 _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
),
2871 _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
),
2873 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2874 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2875 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2876 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2877 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2880 add_function("textureGatherOffset",
2881 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2882 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2883 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2885 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2886 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2887 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2889 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2890 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2891 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2893 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2894 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2895 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2897 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2898 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2899 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2901 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2902 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2903 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2905 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2906 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2907 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2909 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2910 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2911 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2913 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2914 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2915 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2917 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2918 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2919 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2921 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2922 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2923 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2925 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2926 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2929 add_function("textureGatherOffsets",
2930 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2931 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2932 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2934 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2935 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2936 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2938 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2939 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2940 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2942 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2943 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2944 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2946 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2947 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2948 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2950 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2951 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2952 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2954 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2955 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2956 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2981 add_function("ldexp",
2982 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2983 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2984 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2985 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2986 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2987 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2988 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2989 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2992 add_function("frexp",
2993 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2994 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2995 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2996 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2997 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2998 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2999 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
3000 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
3002 add_function("uaddCarry",
3003 _uaddCarry(glsl_type::uint_type
),
3004 _uaddCarry(glsl_type::uvec2_type
),
3005 _uaddCarry(glsl_type::uvec3_type
),
3006 _uaddCarry(glsl_type::uvec4_type
),
3008 add_function("usubBorrow",
3009 _usubBorrow(glsl_type::uint_type
),
3010 _usubBorrow(glsl_type::uvec2_type
),
3011 _usubBorrow(glsl_type::uvec3_type
),
3012 _usubBorrow(glsl_type::uvec4_type
),
3014 add_function("imulExtended",
3015 _mulExtended(glsl_type::int_type
),
3016 _mulExtended(glsl_type::ivec2_type
),
3017 _mulExtended(glsl_type::ivec3_type
),
3018 _mulExtended(glsl_type::ivec4_type
),
3020 add_function("umulExtended",
3021 _mulExtended(glsl_type::uint_type
),
3022 _mulExtended(glsl_type::uvec2_type
),
3023 _mulExtended(glsl_type::uvec3_type
),
3024 _mulExtended(glsl_type::uvec4_type
),
3026 add_function("interpolateAtCentroid",
3027 _interpolateAtCentroid(glsl_type::float_type
),
3028 _interpolateAtCentroid(glsl_type::vec2_type
),
3029 _interpolateAtCentroid(glsl_type::vec3_type
),
3030 _interpolateAtCentroid(glsl_type::vec4_type
),
3032 add_function("interpolateAtOffset",
3033 _interpolateAtOffset(glsl_type::float_type
),
3034 _interpolateAtOffset(glsl_type::vec2_type
),
3035 _interpolateAtOffset(glsl_type::vec3_type
),
3036 _interpolateAtOffset(glsl_type::vec4_type
),
3038 add_function("interpolateAtSample",
3039 _interpolateAtSample(glsl_type::float_type
),
3040 _interpolateAtSample(glsl_type::vec2_type
),
3041 _interpolateAtSample(glsl_type::vec3_type
),
3042 _interpolateAtSample(glsl_type::vec4_type
),
3045 add_function("atomicCounter",
3046 _atomic_counter_op("__intrinsic_atomic_read",
3047 shader_atomic_counters
),
3049 add_function("atomicCounterIncrement",
3050 _atomic_counter_op("__intrinsic_atomic_increment",
3051 shader_atomic_counters
),
3053 add_function("atomicCounterDecrement",
3054 _atomic_counter_op("__intrinsic_atomic_predecrement",
3055 shader_atomic_counters
),
3058 add_function("atomicCounterAddARB",
3059 _atomic_counter_op1("__intrinsic_atomic_add",
3060 shader_atomic_counter_ops
),
3062 add_function("atomicCounterSubtractARB",
3063 _atomic_counter_op1("__intrinsic_atomic_sub",
3064 shader_atomic_counter_ops
),
3066 add_function("atomicCounterMinARB",
3067 _atomic_counter_op1("__intrinsic_atomic_min",
3068 shader_atomic_counter_ops
),
3070 add_function("atomicCounterMaxARB",
3071 _atomic_counter_op1("__intrinsic_atomic_max",
3072 shader_atomic_counter_ops
),
3074 add_function("atomicCounterAndARB",
3075 _atomic_counter_op1("__intrinsic_atomic_and",
3076 shader_atomic_counter_ops
),
3078 add_function("atomicCounterOrARB",
3079 _atomic_counter_op1("__intrinsic_atomic_or",
3080 shader_atomic_counter_ops
),
3082 add_function("atomicCounterXorARB",
3083 _atomic_counter_op1("__intrinsic_atomic_xor",
3084 shader_atomic_counter_ops
),
3086 add_function("atomicCounterExchangeARB",
3087 _atomic_counter_op1("__intrinsic_atomic_exchange",
3088 shader_atomic_counter_ops
),
3090 add_function("atomicCounterCompSwapARB",
3091 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3092 shader_atomic_counter_ops
),
3095 add_function("atomicCounterAdd",
3096 _atomic_counter_op1("__intrinsic_atomic_add",
3099 add_function("atomicCounterSubtract",
3100 _atomic_counter_op1("__intrinsic_atomic_sub",
3103 add_function("atomicCounterMin",
3104 _atomic_counter_op1("__intrinsic_atomic_min",
3107 add_function("atomicCounterMax",
3108 _atomic_counter_op1("__intrinsic_atomic_max",
3111 add_function("atomicCounterAnd",
3112 _atomic_counter_op1("__intrinsic_atomic_and",
3115 add_function("atomicCounterOr",
3116 _atomic_counter_op1("__intrinsic_atomic_or",
3119 add_function("atomicCounterXor",
3120 _atomic_counter_op1("__intrinsic_atomic_xor",
3123 add_function("atomicCounterExchange",
3124 _atomic_counter_op1("__intrinsic_atomic_exchange",
3127 add_function("atomicCounterCompSwap",
3128 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3132 add_function("atomicAdd",
3133 _atomic_op2("__intrinsic_atomic_add",
3134 buffer_atomics_supported
,
3135 glsl_type::uint_type
),
3136 _atomic_op2("__intrinsic_atomic_add",
3137 buffer_atomics_supported
,
3138 glsl_type::int_type
),
3140 add_function("atomicMin",
3141 _atomic_op2("__intrinsic_atomic_min",
3142 buffer_atomics_supported
,
3143 glsl_type::uint_type
),
3144 _atomic_op2("__intrinsic_atomic_min",
3145 buffer_atomics_supported
,
3146 glsl_type::int_type
),
3148 add_function("atomicMax",
3149 _atomic_op2("__intrinsic_atomic_max",
3150 buffer_atomics_supported
,
3151 glsl_type::uint_type
),
3152 _atomic_op2("__intrinsic_atomic_max",
3153 buffer_atomics_supported
,
3154 glsl_type::int_type
),
3156 add_function("atomicAnd",
3157 _atomic_op2("__intrinsic_atomic_and",
3158 buffer_atomics_supported
,
3159 glsl_type::uint_type
),
3160 _atomic_op2("__intrinsic_atomic_and",
3161 buffer_atomics_supported
,
3162 glsl_type::int_type
),
3164 add_function("atomicOr",
3165 _atomic_op2("__intrinsic_atomic_or",
3166 buffer_atomics_supported
,
3167 glsl_type::uint_type
),
3168 _atomic_op2("__intrinsic_atomic_or",
3169 buffer_atomics_supported
,
3170 glsl_type::int_type
),
3172 add_function("atomicXor",
3173 _atomic_op2("__intrinsic_atomic_xor",
3174 buffer_atomics_supported
,
3175 glsl_type::uint_type
),
3176 _atomic_op2("__intrinsic_atomic_xor",
3177 buffer_atomics_supported
,
3178 glsl_type::int_type
),
3180 add_function("atomicExchange",
3181 _atomic_op2("__intrinsic_atomic_exchange",
3182 buffer_atomics_supported
,
3183 glsl_type::uint_type
),
3184 _atomic_op2("__intrinsic_atomic_exchange",
3185 buffer_atomics_supported
,
3186 glsl_type::int_type
),
3188 add_function("atomicCompSwap",
3189 _atomic_op3("__intrinsic_atomic_comp_swap",
3190 buffer_atomics_supported
,
3191 glsl_type::uint_type
),
3192 _atomic_op3("__intrinsic_atomic_comp_swap",
3193 buffer_atomics_supported
,
3194 glsl_type::int_type
),
3197 add_function("min3",
3198 _min3(glsl_type::float_type
),
3199 _min3(glsl_type::vec2_type
),
3200 _min3(glsl_type::vec3_type
),
3201 _min3(glsl_type::vec4_type
),
3203 _min3(glsl_type::int_type
),
3204 _min3(glsl_type::ivec2_type
),
3205 _min3(glsl_type::ivec3_type
),
3206 _min3(glsl_type::ivec4_type
),
3208 _min3(glsl_type::uint_type
),
3209 _min3(glsl_type::uvec2_type
),
3210 _min3(glsl_type::uvec3_type
),
3211 _min3(glsl_type::uvec4_type
),
3214 add_function("max3",
3215 _max3(glsl_type::float_type
),
3216 _max3(glsl_type::vec2_type
),
3217 _max3(glsl_type::vec3_type
),
3218 _max3(glsl_type::vec4_type
),
3220 _max3(glsl_type::int_type
),
3221 _max3(glsl_type::ivec2_type
),
3222 _max3(glsl_type::ivec3_type
),
3223 _max3(glsl_type::ivec4_type
),
3225 _max3(glsl_type::uint_type
),
3226 _max3(glsl_type::uvec2_type
),
3227 _max3(glsl_type::uvec3_type
),
3228 _max3(glsl_type::uvec4_type
),
3231 add_function("mid3",
3232 _mid3(glsl_type::float_type
),
3233 _mid3(glsl_type::vec2_type
),
3234 _mid3(glsl_type::vec3_type
),
3235 _mid3(glsl_type::vec4_type
),
3237 _mid3(glsl_type::int_type
),
3238 _mid3(glsl_type::ivec2_type
),
3239 _mid3(glsl_type::ivec3_type
),
3240 _mid3(glsl_type::ivec4_type
),
3242 _mid3(glsl_type::uint_type
),
3243 _mid3(glsl_type::uvec2_type
),
3244 _mid3(glsl_type::uvec3_type
),
3245 _mid3(glsl_type::uvec4_type
),
3248 add_image_functions(true);
3250 add_function("memoryBarrier",
3251 _memory_barrier("__intrinsic_memory_barrier",
3252 shader_image_load_store
),
3254 add_function("groupMemoryBarrier",
3255 _memory_barrier("__intrinsic_group_memory_barrier",
3258 add_function("memoryBarrierAtomicCounter",
3259 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
3260 compute_shader_supported
),
3262 add_function("memoryBarrierBuffer",
3263 _memory_barrier("__intrinsic_memory_barrier_buffer",
3264 compute_shader_supported
),
3266 add_function("memoryBarrierImage",
3267 _memory_barrier("__intrinsic_memory_barrier_image",
3268 compute_shader_supported
),
3270 add_function("memoryBarrierShared",
3271 _memory_barrier("__intrinsic_memory_barrier_shared",
3275 add_function("ballotARB", _ballot(), NULL
);
3277 add_function("readInvocationARB",
3278 _read_invocation(glsl_type::float_type
),
3279 _read_invocation(glsl_type::vec2_type
),
3280 _read_invocation(glsl_type::vec3_type
),
3281 _read_invocation(glsl_type::vec4_type
),
3283 _read_invocation(glsl_type::int_type
),
3284 _read_invocation(glsl_type::ivec2_type
),
3285 _read_invocation(glsl_type::ivec3_type
),
3286 _read_invocation(glsl_type::ivec4_type
),
3288 _read_invocation(glsl_type::uint_type
),
3289 _read_invocation(glsl_type::uvec2_type
),
3290 _read_invocation(glsl_type::uvec3_type
),
3291 _read_invocation(glsl_type::uvec4_type
),
3294 add_function("readFirstInvocationARB",
3295 _read_first_invocation(glsl_type::float_type
),
3296 _read_first_invocation(glsl_type::vec2_type
),
3297 _read_first_invocation(glsl_type::vec3_type
),
3298 _read_first_invocation(glsl_type::vec4_type
),
3300 _read_first_invocation(glsl_type::int_type
),
3301 _read_first_invocation(glsl_type::ivec2_type
),
3302 _read_first_invocation(glsl_type::ivec3_type
),
3303 _read_first_invocation(glsl_type::ivec4_type
),
3305 _read_first_invocation(glsl_type::uint_type
),
3306 _read_first_invocation(glsl_type::uvec2_type
),
3307 _read_first_invocation(glsl_type::uvec3_type
),
3308 _read_first_invocation(glsl_type::uvec4_type
),
3311 add_function("clock2x32ARB",
3312 _shader_clock(shader_clock
,
3313 glsl_type::uvec2_type
),
3316 add_function("clockARB",
3317 _shader_clock(shader_clock_int64
,
3318 glsl_type::uint64_t_type
),
3321 add_function("beginInvocationInterlockARB",
3322 _invocation_interlock(
3323 "__intrinsic_begin_invocation_interlock",
3324 supports_arb_fragment_shader_interlock
),
3327 add_function("endInvocationInterlockARB",
3328 _invocation_interlock(
3329 "__intrinsic_end_invocation_interlock",
3330 supports_arb_fragment_shader_interlock
),
3333 add_function("anyInvocationARB",
3334 _vote("__intrinsic_vote_any", vote
),
3337 add_function("allInvocationsARB",
3338 _vote("__intrinsic_vote_all", vote
),
3341 add_function("allInvocationsEqualARB",
3342 _vote("__intrinsic_vote_eq", vote
),
3345 add_function("anyInvocation",
3346 _vote("__intrinsic_vote_any", v460_desktop
),
3349 add_function("allInvocations",
3350 _vote("__intrinsic_vote_all", v460_desktop
),
3353 add_function("allInvocationsEqual",
3354 _vote("__intrinsic_vote_eq", v460_desktop
),
3357 add_function("__builtin_idiv64",
3358 generate_ir::idiv64(mem_ctx
, integer_functions_supported
),
3361 add_function("__builtin_imod64",
3362 generate_ir::imod64(mem_ctx
, integer_functions_supported
),
3365 add_function("__builtin_sign64",
3366 generate_ir::sign64(mem_ctx
, integer_functions_supported
),
3369 add_function("__builtin_udiv64",
3370 generate_ir::udiv64(mem_ctx
, integer_functions_supported
),
3373 add_function("__builtin_umod64",
3374 generate_ir::umod64(mem_ctx
, integer_functions_supported
),
3377 add_function("__builtin_umul64",
3378 generate_ir::umul64(mem_ctx
, integer_functions_supported
),
3389 builtin_builder::add_function(const char *name
, ...)
3393 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3397 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
3403 stuff
.push_tail(sig
);
3404 validate_ir_tree(&stuff
);
3407 f
->add_signature(sig
);
3411 shader
->symbols
->add_function(f
);
3415 builtin_builder::add_image_function(const char *name
,
3416 const char *intrinsic_name
,
3417 image_prototype_ctr prototype
,
3418 unsigned num_arguments
,
3420 enum ir_intrinsic_id intrinsic_id
)
3422 static const glsl_type
*const types
[] = {
3423 glsl_type::image1D_type
,
3424 glsl_type::image2D_type
,
3425 glsl_type::image3D_type
,
3426 glsl_type::image2DRect_type
,
3427 glsl_type::imageCube_type
,
3428 glsl_type::imageBuffer_type
,
3429 glsl_type::image1DArray_type
,
3430 glsl_type::image2DArray_type
,
3431 glsl_type::imageCubeArray_type
,
3432 glsl_type::image2DMS_type
,
3433 glsl_type::image2DMSArray_type
,
3434 glsl_type::iimage1D_type
,
3435 glsl_type::iimage2D_type
,
3436 glsl_type::iimage3D_type
,
3437 glsl_type::iimage2DRect_type
,
3438 glsl_type::iimageCube_type
,
3439 glsl_type::iimageBuffer_type
,
3440 glsl_type::iimage1DArray_type
,
3441 glsl_type::iimage2DArray_type
,
3442 glsl_type::iimageCubeArray_type
,
3443 glsl_type::iimage2DMS_type
,
3444 glsl_type::iimage2DMSArray_type
,
3445 glsl_type::uimage1D_type
,
3446 glsl_type::uimage2D_type
,
3447 glsl_type::uimage3D_type
,
3448 glsl_type::uimage2DRect_type
,
3449 glsl_type::uimageCube_type
,
3450 glsl_type::uimageBuffer_type
,
3451 glsl_type::uimage1DArray_type
,
3452 glsl_type::uimage2DArray_type
,
3453 glsl_type::uimageCubeArray_type
,
3454 glsl_type::uimage2DMS_type
,
3455 glsl_type::uimage2DMSArray_type
3458 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3460 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3461 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3462 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3463 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3464 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3465 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3466 num_arguments
, flags
, intrinsic_id
));
3469 shader
->symbols
->add_function(f
);
3473 builtin_builder::add_image_functions(bool glsl
)
3475 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3477 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3478 "__intrinsic_image_load",
3479 &builtin_builder::_image_prototype
, 0,
3480 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3481 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3482 IMAGE_FUNCTION_READ_ONLY
),
3483 ir_intrinsic_image_load
);
3485 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3486 "__intrinsic_image_store",
3487 &builtin_builder::_image_prototype
, 1,
3488 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3489 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3490 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3491 IMAGE_FUNCTION_WRITE_ONLY
),
3492 ir_intrinsic_image_store
);
3494 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3496 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3497 "__intrinsic_image_atomic_add",
3498 &builtin_builder::_image_prototype
, 1, atom_flags
,
3499 ir_intrinsic_image_atomic_add
);
3501 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3502 "__intrinsic_image_atomic_min",
3503 &builtin_builder::_image_prototype
, 1, atom_flags
,
3504 ir_intrinsic_image_atomic_min
);
3506 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3507 "__intrinsic_image_atomic_max",
3508 &builtin_builder::_image_prototype
, 1, atom_flags
,
3509 ir_intrinsic_image_atomic_max
);
3511 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3512 "__intrinsic_image_atomic_and",
3513 &builtin_builder::_image_prototype
, 1, atom_flags
,
3514 ir_intrinsic_image_atomic_and
);
3516 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3517 "__intrinsic_image_atomic_or",
3518 &builtin_builder::_image_prototype
, 1, atom_flags
,
3519 ir_intrinsic_image_atomic_or
);
3521 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3522 "__intrinsic_image_atomic_xor",
3523 &builtin_builder::_image_prototype
, 1, atom_flags
,
3524 ir_intrinsic_image_atomic_xor
);
3526 add_image_function((glsl
? "imageAtomicExchange" :
3527 "__intrinsic_image_atomic_exchange"),
3528 "__intrinsic_image_atomic_exchange",
3529 &builtin_builder::_image_prototype
, 1,
3530 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3531 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3532 ir_intrinsic_image_atomic_exchange
);
3534 add_image_function((glsl
? "imageAtomicCompSwap" :
3535 "__intrinsic_image_atomic_comp_swap"),
3536 "__intrinsic_image_atomic_comp_swap",
3537 &builtin_builder::_image_prototype
, 2, atom_flags
,
3538 ir_intrinsic_image_atomic_comp_swap
);
3540 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3541 "__intrinsic_image_size",
3542 &builtin_builder::_image_size_prototype
, 1,
3543 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
,
3544 ir_intrinsic_image_size
);
3546 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3547 "__intrinsic_image_samples",
3548 &builtin_builder::_image_samples_prototype
, 1,
3549 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3550 IMAGE_FUNCTION_MS_ONLY
,
3551 ir_intrinsic_image_samples
);
3555 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3557 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3561 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3563 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3567 builtin_builder::imm(bool b
, unsigned vector_elements
)
3569 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3573 builtin_builder::imm(float f
, unsigned vector_elements
)
3575 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3579 builtin_builder::imm(int i
, unsigned vector_elements
)
3581 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3585 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3587 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3591 builtin_builder::imm(double d
, unsigned vector_elements
)
3593 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3597 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3599 return new(mem_ctx
) ir_constant(type
, &data
);
3602 #define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)
3604 ir_dereference_variable
*
3605 builtin_builder::var_ref(ir_variable
*var
)
3607 return new(mem_ctx
) ir_dereference_variable(var
);
3610 ir_dereference_array
*
3611 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3613 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3616 /** Return an element of a matrix */
3618 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3620 return swizzle(array_ref(var
, column
), row
, 1);
3624 * Implementations of built-in functions:
3627 ir_function_signature
*
3628 builtin_builder::new_sig(const glsl_type
*return_type
,
3629 builtin_available_predicate avail
,
3635 ir_function_signature
*sig
=
3636 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3639 va_start(ap
, num_params
);
3640 for (int i
= 0; i
< num_params
; i
++) {
3641 plist
.push_tail(va_arg(ap
, ir_variable
*));
3645 sig
->replace_parameters(&plist
);
3649 #define MAKE_SIG(return_type, avail, ...) \
3650 ir_function_signature *sig = \
3651 new_sig(return_type, avail, __VA_ARGS__); \
3652 ir_factory body(&sig->body, mem_ctx); \
3653 sig->is_defined = true;
3655 #define MAKE_INTRINSIC(return_type, id, avail, ...) \
3656 ir_function_signature *sig = \
3657 new_sig(return_type, avail, __VA_ARGS__); \
3658 sig->intrinsic_id = id;
3660 ir_function_signature
*
3661 builtin_builder::unop(builtin_available_predicate avail
,
3662 ir_expression_operation opcode
,
3663 const glsl_type
*return_type
,
3664 const glsl_type
*param_type
)
3666 ir_variable
*x
= in_var(param_type
, "x");
3667 MAKE_SIG(return_type
, avail
, 1, x
);
3668 body
.emit(ret(expr(opcode
, x
)));
3672 #define UNOP(NAME, OPCODE, AVAIL) \
3673 ir_function_signature * \
3674 builtin_builder::_##NAME(const glsl_type *type) \
3676 return unop(&AVAIL, OPCODE, type, type); \
3679 #define UNOPA(NAME, OPCODE) \
3680 ir_function_signature * \
3681 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3683 return unop(avail, OPCODE, type, type); \
3686 ir_function_signature
*
3687 builtin_builder::binop(builtin_available_predicate avail
,
3688 ir_expression_operation opcode
,
3689 const glsl_type
*return_type
,
3690 const glsl_type
*param0_type
,
3691 const glsl_type
*param1_type
,
3694 ir_variable
*x
= in_var(param0_type
, "x");
3695 ir_variable
*y
= in_var(param1_type
, "y");
3696 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3699 body
.emit(ret(expr(opcode
, y
, x
)));
3701 body
.emit(ret(expr(opcode
, x
, y
)));
3706 #define BINOP(NAME, OPCODE, AVAIL) \
3707 ir_function_signature * \
3708 builtin_builder::_##NAME(const glsl_type *return_type, \
3709 const glsl_type *param0_type, \
3710 const glsl_type *param1_type) \
3712 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3716 * Angle and Trigonometry Functions @{
3719 ir_function_signature
*
3720 builtin_builder::_radians(const glsl_type
*type
)
3722 ir_variable
*degrees
= in_var(type
, "degrees");
3723 MAKE_SIG(type
, always_available
, 1, degrees
);
3724 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3728 ir_function_signature
*
3729 builtin_builder::_degrees(const glsl_type
*type
)
3731 ir_variable
*radians
= in_var(type
, "radians");
3732 MAKE_SIG(type
, always_available
, 1, radians
);
3733 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3737 UNOP(sin
, ir_unop_sin
, always_available
)
3738 UNOP(cos
, ir_unop_cos
, always_available
)
3740 ir_function_signature
*
3741 builtin_builder::_tan(const glsl_type
*type
)
3743 ir_variable
*theta
= in_var(type
, "theta");
3744 MAKE_SIG(type
, always_available
, 1, theta
);
3745 body
.emit(ret(div(sin(theta
), cos(theta
))));
3750 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3754 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3757 add(imm(M_PI_4f
- 1.0f
),
3760 mul(abs(x
), imm(p1
))))))))));
3764 * Generate a ir_call to a function with a set of parameters
3766 * The input \c params can either be a list of \c ir_variable or a list of
3767 * \c ir_dereference_variable. In the latter case, all nodes will be removed
3768 * from \c params and used directly as the parameters to the generated
3772 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3774 exec_list actual_params
;
3776 foreach_in_list_safe(ir_instruction
, ir
, ¶ms
) {
3777 ir_dereference_variable
*d
= ir
->as_dereference_variable();
3780 actual_params
.push_tail(d
);
3782 ir_variable
*var
= ir
->as_variable();
3783 assert(var
!= NULL
);
3784 actual_params
.push_tail(var_ref(var
));
3788 ir_function_signature
*sig
=
3789 f
->exact_matching_signature(NULL
, &actual_params
);
3793 ir_dereference_variable
*deref
=
3794 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3796 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3799 ir_function_signature
*
3800 builtin_builder::_asin(const glsl_type
*type
)
3802 ir_variable
*x
= in_var(type
, "x");
3803 MAKE_SIG(type
, always_available
, 1, x
);
3805 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3810 ir_function_signature
*
3811 builtin_builder::_acos(const glsl_type
*type
)
3813 ir_variable
*x
= in_var(type
, "x");
3814 MAKE_SIG(type
, always_available
, 1, x
);
3816 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3821 ir_function_signature
*
3822 builtin_builder::_atan2(const glsl_type
*type
)
3824 const unsigned n
= type
->vector_elements
;
3825 ir_variable
*y
= in_var(type
, "y");
3826 ir_variable
*x
= in_var(type
, "x");
3827 MAKE_SIG(type
, always_available
, 2, y
, x
);
3829 /* If we're on the left half-plane rotate the coordinates π/2 clock-wise
3830 * for the y=0 discontinuity to end up aligned with the vertical
3831 * discontinuity of atan(s/t) along t=0. This also makes sure that we
3832 * don't attempt to divide by zero along the vertical line, which may give
3833 * unspecified results on non-GLSL 4.1-capable hardware.
3835 ir_variable
*flip
= body
.make_temp(glsl_type::bvec(n
), "flip");
3836 body
.emit(assign(flip
, gequal(imm(0.0f
, n
), x
)));
3837 ir_variable
*s
= body
.make_temp(type
, "s");
3838 body
.emit(assign(s
, csel(flip
, abs(x
), y
)));
3839 ir_variable
*t
= body
.make_temp(type
, "t");
3840 body
.emit(assign(t
, csel(flip
, y
, abs(x
))));
3842 /* If the magnitude of the denominator exceeds some huge value, scale down
3843 * the arguments in order to prevent the reciprocal operation from flushing
3844 * its result to zero, which would cause precision problems, and for s
3845 * infinite would cause us to return a NaN instead of the correct finite
3848 * If fmin and fmax are respectively the smallest and largest positive
3849 * normalized floating point values representable by the implementation,
3850 * the constants below should be in agreement with:
3853 * scale <= 1 / fmin / fmax (for |t| >= huge)
3855 * In addition scale should be a negative power of two in order to avoid
3856 * loss of precision. The values chosen below should work for most usual
3857 * floating point representations with at least the dynamic range of ATI's
3858 * 24-bit representation.
3860 ir_constant
*huge
= imm(1e18f
, n
);
3861 ir_variable
*scale
= body
.make_temp(type
, "scale");
3862 body
.emit(assign(scale
, csel(gequal(abs(t
), huge
),
3863 imm(0.25f
, n
), imm(1.0f
, n
))));
3864 ir_variable
*rcp_scaled_t
= body
.make_temp(type
, "rcp_scaled_t");
3865 body
.emit(assign(rcp_scaled_t
, rcp(mul(t
, scale
))));
3866 ir_expression
*s_over_t
= mul(mul(s
, scale
), rcp_scaled_t
);
3868 /* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily
3869 * that ∞/∞ = 1) in order to comply with the rather artificial rules
3870 * inherited from IEEE 754-2008, namely:
3872 * "atan2(±∞, −∞) is ±3π/4
3873 * atan2(±∞, +∞) is ±π/4"
3875 * Note that this is inconsistent with the rules for the neighborhood of
3876 * zero that are based on iterated limits:
3878 * "atan2(±0, −0) is ±π
3879 * atan2(±0, +0) is ±0"
3881 * but GLSL specifically allows implementations to deviate from IEEE rules
3882 * at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as
3885 ir_expression
*tan
= csel(equal(abs(x
), abs(y
)),
3886 imm(1.0f
, n
), abs(s_over_t
));
3888 /* Calculate the arctangent and fix up the result if we had flipped the
3889 * coordinate system.
3891 ir_variable
*arc
= body
.make_temp(type
, "arc");
3892 do_atan(body
, type
, arc
, tan
);
3893 body
.emit(assign(arc
, add(arc
, mul(b2f(flip
), imm(M_PI_2f
)))));
3895 /* Rather convoluted calculation of the sign of the result. When x < 0 we
3896 * cannot use fsign because we need to be able to distinguish between
3897 * negative and positive zero. Unfortunately we cannot use bitwise
3898 * arithmetic tricks either because of back-ends without integer support.
3899 * When x >= 0 rcp_scaled_t will always be non-negative so this won't be
3900 * able to distinguish between negative and positive zero, but we don't
3901 * care because atan2 is continuous along the whole positive y = 0
3902 * half-line, so it won't affect the result significantly.
3904 body
.emit(ret(csel(less(min2(y
, rcp_scaled_t
), imm(0.0f
, n
)),
3911 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3914 * range-reduction, first step:
3916 * / y_over_x if |y_over_x| <= 1.0;
3918 * \ 1.0 / y_over_x otherwise
3920 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3921 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3927 * approximate atan by evaluating polynomial:
3929 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3930 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3931 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3933 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3934 body
.emit(assign(tmp
, mul(x
, x
)));
3935 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3937 imm(0.0536813784310406f
)),
3939 imm(0.1173503194786851f
)),
3941 imm(0.1938924977115610f
)),
3943 imm(0.3326756418091246f
)),
3945 imm(0.9999793128310355f
)),
3948 /* range-reduction fixup */
3949 body
.emit(assign(tmp
, add(tmp
,
3950 mul(b2f(greater(abs(y_over_x
),
3951 imm(1.0f
, type
->components()))),
3957 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3960 ir_function_signature
*
3961 builtin_builder::_atan(const glsl_type
*type
)
3963 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3964 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3966 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3967 do_atan(body
, type
, tmp
, y_over_x
);
3968 body
.emit(ret(tmp
));
3973 ir_function_signature
*
3974 builtin_builder::_sinh(const glsl_type
*type
)
3976 ir_variable
*x
= in_var(type
, "x");
3977 MAKE_SIG(type
, v130
, 1, x
);
3979 /* 0.5 * (e^x - e^(-x)) */
3980 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3985 ir_function_signature
*
3986 builtin_builder::_cosh(const glsl_type
*type
)
3988 ir_variable
*x
= in_var(type
, "x");
3989 MAKE_SIG(type
, v130
, 1, x
);
3991 /* 0.5 * (e^x + e^(-x)) */
3992 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3997 ir_function_signature
*
3998 builtin_builder::_tanh(const glsl_type
*type
)
4000 ir_variable
*x
= in_var(type
, "x");
4001 MAKE_SIG(type
, v130
, 1, x
);
4003 /* tanh(x) := (0.5 * (e^x - e^(-x))) / (0.5 * (e^x + e^(-x)))
4005 * With a little algebra this reduces to (e^2x - 1) / (e^2x + 1)
4007 * Clamp x to (-inf, +10] to avoid precision problems. When x > 10, e^2x
4008 * is so much larger than 1.0 that 1.0 gets flushed to zero in the
4009 * computation e^2x +/- 1 so it can be ignored.
4011 ir_variable
*t
= body
.make_temp(type
, "tmp");
4012 body
.emit(assign(t
, min2(x
, imm(10.0f
))));
4014 body
.emit(ret(div(sub(exp(mul(t
, imm(2.0f
))), imm(1.0f
)),
4015 add(exp(mul(t
, imm(2.0f
))), imm(1.0f
)))));
4020 ir_function_signature
*
4021 builtin_builder::_asinh(const glsl_type
*type
)
4023 ir_variable
*x
= in_var(type
, "x");
4024 MAKE_SIG(type
, v130
, 1, x
);
4026 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
4031 ir_function_signature
*
4032 builtin_builder::_acosh(const glsl_type
*type
)
4034 ir_variable
*x
= in_var(type
, "x");
4035 MAKE_SIG(type
, v130
, 1, x
);
4037 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
4041 ir_function_signature
*
4042 builtin_builder::_atanh(const glsl_type
*type
)
4044 ir_variable
*x
= in_var(type
, "x");
4045 MAKE_SIG(type
, v130
, 1, x
);
4047 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
4048 sub(imm(1.0f
), x
))))));
4054 * Exponential Functions @{
4057 ir_function_signature
*
4058 builtin_builder::_pow(const glsl_type
*type
)
4060 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
4063 UNOP(exp
, ir_unop_exp
, always_available
)
4064 UNOP(log
, ir_unop_log
, always_available
)
4065 UNOP(exp2
, ir_unop_exp2
, always_available
)
4066 UNOP(log2
, ir_unop_log2
, always_available
)
4067 UNOPA(sqrt
, ir_unop_sqrt
)
4068 UNOPA(inversesqrt
, ir_unop_rsq
)
4072 UNOPA(abs
, ir_unop_abs
)
4073 UNOPA(sign
, ir_unop_sign
)
4074 UNOPA(floor
, ir_unop_floor
)
4075 UNOPA(trunc
, ir_unop_trunc
)
4076 UNOPA(round
, ir_unop_round_even
)
4077 UNOPA(roundEven
, ir_unop_round_even
)
4078 UNOPA(ceil
, ir_unop_ceil
)
4079 UNOPA(fract
, ir_unop_fract
)
4081 ir_function_signature
*
4082 builtin_builder::_mod(builtin_available_predicate avail
,
4083 const glsl_type
*x_type
, const glsl_type
*y_type
)
4085 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
4088 ir_function_signature
*
4089 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
4091 ir_variable
*x
= in_var(type
, "x");
4092 ir_variable
*i
= out_var(type
, "i");
4093 MAKE_SIG(type
, avail
, 2, x
, i
);
4095 ir_variable
*t
= body
.make_temp(type
, "t");
4096 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
4097 body
.emit(assign(i
, t
));
4098 body
.emit(ret(sub(x
, t
)));
4103 ir_function_signature
*
4104 builtin_builder::_min(builtin_available_predicate avail
,
4105 const glsl_type
*x_type
, const glsl_type
*y_type
)
4107 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
4110 ir_function_signature
*
4111 builtin_builder::_max(builtin_available_predicate avail
,
4112 const glsl_type
*x_type
, const glsl_type
*y_type
)
4114 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
4117 ir_function_signature
*
4118 builtin_builder::_clamp(builtin_available_predicate avail
,
4119 const glsl_type
*val_type
, const glsl_type
*bound_type
)
4121 ir_variable
*x
= in_var(val_type
, "x");
4122 ir_variable
*minVal
= in_var(bound_type
, "minVal");
4123 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
4124 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
4126 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
4131 ir_function_signature
*
4132 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
4134 ir_variable
*x
= in_var(val_type
, "x");
4135 ir_variable
*y
= in_var(val_type
, "y");
4136 ir_variable
*a
= in_var(blend_type
, "a");
4137 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4139 body
.emit(ret(lrp(x
, y
, a
)));
4144 ir_function_signature
*
4145 builtin_builder::_mix_sel(builtin_available_predicate avail
,
4146 const glsl_type
*val_type
,
4147 const glsl_type
*blend_type
)
4149 ir_variable
*x
= in_var(val_type
, "x");
4150 ir_variable
*y
= in_var(val_type
, "y");
4151 ir_variable
*a
= in_var(blend_type
, "a");
4152 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4154 /* csel matches the ternary operator in that a selector of true choses the
4155 * first argument. This differs from mix(x, y, false) which choses the
4156 * second argument (to remain consistent with the interpolating version of
4157 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
4159 * To handle the behavior mismatch, reverse the x and y arguments.
4161 body
.emit(ret(csel(a
, y
, x
)));
4166 ir_function_signature
*
4167 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4169 ir_variable
*edge
= in_var(edge_type
, "edge");
4170 ir_variable
*x
= in_var(x_type
, "x");
4171 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
4173 ir_variable
*t
= body
.make_temp(x_type
, "t");
4174 if (x_type
->vector_elements
== 1) {
4175 /* Both are floats */
4176 if (edge_type
->is_double())
4177 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
4179 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
4180 } else if (edge_type
->vector_elements
== 1) {
4181 /* x is a vector but edge is a float */
4182 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4183 if (edge_type
->is_double())
4184 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
4186 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
4189 /* Both are vectors */
4190 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4191 if (edge_type
->is_double())
4192 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
4195 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
4205 ir_function_signature
*
4206 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4208 ir_variable
*edge0
= in_var(edge_type
, "edge0");
4209 ir_variable
*edge1
= in_var(edge_type
, "edge1");
4210 ir_variable
*x
= in_var(x_type
, "x");
4211 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
4213 /* From the GLSL 1.10 specification:
4216 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
4217 * return t * t * (3 - 2 * t);
4220 ir_variable
*t
= body
.make_temp(x_type
, "t");
4221 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
4222 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
4224 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
4229 ir_function_signature
*
4230 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
4232 ir_variable
*x
= in_var(type
, "x");
4233 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4235 body
.emit(ret(nequal(x
, x
)));
4240 ir_function_signature
*
4241 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
4243 ir_variable
*x
= in_var(type
, "x");
4244 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4246 ir_constant_data infinities
;
4247 for (int i
= 0; i
< type
->vector_elements
; i
++) {
4248 switch (type
->base_type
) {
4249 case GLSL_TYPE_FLOAT
:
4250 infinities
.f
[i
] = INFINITY
;
4252 case GLSL_TYPE_DOUBLE
:
4253 infinities
.d
[i
] = INFINITY
;
4256 unreachable("unknown type");
4260 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
4265 ir_function_signature
*
4266 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
4268 ir_variable
*x
= in_var(type
, "x");
4269 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4270 body
.emit(ret(bitcast_f2i(x
)));
4274 ir_function_signature
*
4275 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
4277 ir_variable
*x
= in_var(type
, "x");
4278 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4279 body
.emit(ret(bitcast_f2u(x
)));
4283 ir_function_signature
*
4284 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
4286 ir_variable
*x
= in_var(type
, "x");
4287 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4288 body
.emit(ret(bitcast_i2f(x
)));
4292 ir_function_signature
*
4293 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
4295 ir_variable
*x
= in_var(type
, "x");
4296 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4297 body
.emit(ret(bitcast_u2f(x
)));
4301 ir_function_signature
*
4302 builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail
, const glsl_type
*type
)
4304 ir_variable
*x
= in_var(type
, "x");
4305 MAKE_SIG(glsl_type::i64vec(type
->vector_elements
), avail
, 1, x
);
4306 body
.emit(ret(bitcast_d2i64(x
)));
4310 ir_function_signature
*
4311 builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail
, const glsl_type
*type
)
4313 ir_variable
*x
= in_var(type
, "x");
4314 MAKE_SIG(glsl_type::u64vec(type
->vector_elements
), avail
, 1, x
);
4315 body
.emit(ret(bitcast_d2u64(x
)));
4319 ir_function_signature
*
4320 builtin_builder::_int64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4322 ir_variable
*x
= in_var(type
, "x");
4323 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4324 body
.emit(ret(bitcast_i642d(x
)));
4328 ir_function_signature
*
4329 builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4331 ir_variable
*x
= in_var(type
, "x");
4332 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4333 body
.emit(ret(bitcast_u642d(x
)));
4337 ir_function_signature
*
4338 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
4340 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4341 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4342 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
4346 ir_function_signature
*
4347 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
4349 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4350 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4351 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
4355 ir_function_signature
*
4356 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
4358 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4359 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4360 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
4364 ir_function_signature
*
4365 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
4367 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4368 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4369 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
4373 ir_function_signature
*
4374 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
4376 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4377 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4378 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
4382 ir_function_signature
*
4383 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
4385 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4386 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4387 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
4392 ir_function_signature
*
4393 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
4395 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4396 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4397 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
4401 ir_function_signature
*
4402 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
4404 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4405 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4406 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
4410 ir_function_signature
*
4411 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
4413 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4414 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4415 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
4419 ir_function_signature
*
4420 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
4422 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4423 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4424 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
4428 ir_function_signature
*
4429 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
4431 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4432 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
4433 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
4437 ir_function_signature
*
4438 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
4440 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
4441 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4442 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
4446 ir_function_signature
*
4447 builtin_builder::_packInt2x32(builtin_available_predicate avail
)
4449 ir_variable
*v
= in_var(glsl_type::ivec2_type
, "v");
4450 MAKE_SIG(glsl_type::int64_t_type
, avail
, 1, v
);
4451 body
.emit(ret(expr(ir_unop_pack_int_2x32
, v
)));
4455 ir_function_signature
*
4456 builtin_builder::_unpackInt2x32(builtin_available_predicate avail
)
4458 ir_variable
*p
= in_var(glsl_type::int64_t_type
, "p");
4459 MAKE_SIG(glsl_type::ivec2_type
, avail
, 1, p
);
4460 body
.emit(ret(expr(ir_unop_unpack_int_2x32
, p
)));
4464 ir_function_signature
*
4465 builtin_builder::_packUint2x32(builtin_available_predicate avail
)
4467 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4468 MAKE_SIG(glsl_type::uint64_t_type
, avail
, 1, v
);
4469 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, v
)));
4473 ir_function_signature
*
4474 builtin_builder::_unpackUint2x32(builtin_available_predicate avail
)
4476 ir_variable
*p
= in_var(glsl_type::uint64_t_type
, "p");
4477 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4478 body
.emit(ret(expr(ir_unop_unpack_uint_2x32
, p
)));
4482 ir_function_signature
*
4483 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
4485 ir_variable
*x
= in_var(type
, "x");
4486 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
4488 body
.emit(ret(sqrt(dot(x
, x
))));
4493 ir_function_signature
*
4494 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
4496 ir_variable
*p0
= in_var(type
, "p0");
4497 ir_variable
*p1
= in_var(type
, "p1");
4498 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
4500 if (type
->vector_elements
== 1) {
4501 body
.emit(ret(abs(sub(p0
, p1
))));
4503 ir_variable
*p
= body
.make_temp(type
, "p");
4504 body
.emit(assign(p
, sub(p0
, p1
)));
4505 body
.emit(ret(sqrt(dot(p
, p
))));
4511 ir_function_signature
*
4512 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
4514 if (type
->vector_elements
== 1)
4515 return binop(avail
, ir_binop_mul
, type
, type
, type
);
4517 return binop(avail
, ir_binop_dot
,
4518 type
->get_base_type(), type
, type
);
4521 ir_function_signature
*
4522 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
4524 ir_variable
*a
= in_var(type
, "a");
4525 ir_variable
*b
= in_var(type
, "b");
4526 MAKE_SIG(type
, avail
, 2, a
, b
);
4528 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
4529 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
4531 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
4532 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
4537 ir_function_signature
*
4538 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
4540 ir_variable
*x
= in_var(type
, "x");
4541 MAKE_SIG(type
, avail
, 1, x
);
4543 if (type
->vector_elements
== 1) {
4544 body
.emit(ret(sign(x
)));
4546 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
4552 ir_function_signature
*
4553 builtin_builder::_ftransform()
4555 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
4557 /* ftransform() refers to global variables, and is always emitted
4558 * directly by ast_function.cpp. Just emit a prototype here so we
4559 * can recognize calls to it.
4564 ir_function_signature
*
4565 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
4567 ir_variable
*N
= in_var(type
, "N");
4568 ir_variable
*I
= in_var(type
, "I");
4569 ir_variable
*Nref
= in_var(type
, "Nref");
4570 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
4572 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
4573 ret(N
), ret(neg(N
))));
4578 ir_function_signature
*
4579 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
4581 ir_variable
*I
= in_var(type
, "I");
4582 ir_variable
*N
= in_var(type
, "N");
4583 MAKE_SIG(type
, avail
, 2, I
, N
);
4585 /* I - 2 * dot(N, I) * N */
4586 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
4591 ir_function_signature
*
4592 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
4594 ir_variable
*I
= in_var(type
, "I");
4595 ir_variable
*N
= in_var(type
, "N");
4596 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
4597 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4599 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4600 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4602 /* From the GLSL 1.10 specification:
4603 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4605 * return genType(0.0)
4607 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4609 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4610 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4611 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4612 mul(n_dot_i
, n_dot_i
)))))));
4613 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4614 ret(ir_constant::zero(mem_ctx
, type
)),
4615 ret(sub(mul(eta
, I
),
4616 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4621 ir_function_signature
*
4622 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4624 ir_variable
*x
= in_var(type
, "x");
4625 ir_variable
*y
= in_var(type
, "y");
4626 MAKE_SIG(type
, avail
, 2, x
, y
);
4628 ir_variable
*z
= body
.make_temp(type
, "z");
4629 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4630 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4637 ir_function_signature
*
4638 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4643 if (type
->is_double()) {
4644 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4645 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4647 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4648 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4650 MAKE_SIG(type
, avail
, 2, c
, r
);
4652 ir_variable
*m
= body
.make_temp(type
, "m");
4653 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4654 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4661 ir_function_signature
*
4662 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4664 const glsl_type
*transpose_type
=
4665 glsl_type::get_instance(orig_type
->base_type
,
4666 orig_type
->matrix_columns
,
4667 orig_type
->vector_elements
);
4669 ir_variable
*m
= in_var(orig_type
, "m");
4670 MAKE_SIG(transpose_type
, avail
, 1, m
);
4672 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4673 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4674 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4675 body
.emit(assign(array_ref(t
, j
),
4676 matrix_elt(m
, i
, j
),
4685 ir_function_signature
*
4686 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4688 ir_variable
*m
= in_var(type
, "m");
4689 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4691 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4692 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4697 ir_function_signature
*
4698 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4700 ir_variable
*m
= in_var(type
, "m");
4701 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4704 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4705 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4708 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4709 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4712 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4713 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4715 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4716 mul(matrix_elt(m
, 0, 1), f2
)),
4717 mul(matrix_elt(m
, 0, 2), f3
))));
4722 ir_function_signature
*
4723 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4725 ir_variable
*m
= in_var(type
, "m");
4726 const glsl_type
*btype
= type
->get_base_type();
4727 MAKE_SIG(btype
, avail
, 1, m
);
4729 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4730 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4731 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4732 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4733 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4734 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4735 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4736 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4737 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4738 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4739 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4740 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4741 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4742 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4743 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4744 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4745 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4746 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4747 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4749 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)))));
4750 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)))));
4751 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)))));
4752 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)))));
4753 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)))));
4754 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)))));
4755 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)))));
4756 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)))));
4757 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)))));
4758 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)))));
4759 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)))));
4760 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)))));
4761 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)))));
4762 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)))));
4763 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)))));
4764 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)))));
4765 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)))));
4766 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)))));
4767 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)))));
4769 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4771 body
.emit(assign(adj_0
,
4772 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4773 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4774 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4776 body
.emit(assign(adj_0
, neg(
4777 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4778 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4779 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4781 body
.emit(assign(adj_0
,
4782 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4783 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4784 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4786 body
.emit(assign(adj_0
, neg(
4787 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4788 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4789 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4792 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4797 ir_function_signature
*
4798 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4800 ir_variable
*m
= in_var(type
, "m");
4801 MAKE_SIG(type
, avail
, 1, m
);
4803 ir_variable
*adj
= body
.make_temp(type
, "adj");
4804 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4805 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4806 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4807 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4809 ir_expression
*det
=
4810 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4811 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4813 body
.emit(ret(div(adj
, det
)));
4817 ir_function_signature
*
4818 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4820 ir_variable
*m
= in_var(type
, "m");
4821 const glsl_type
*btype
= type
->get_base_type();
4822 MAKE_SIG(type
, avail
, 1, m
);
4824 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4825 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4826 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4828 body
.emit(assign(f11_22_21_12
,
4829 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4830 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4831 body
.emit(assign(f10_22_20_12
,
4832 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4833 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4834 body
.emit(assign(f10_21_20_11
,
4835 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4836 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4838 ir_variable
*adj
= body
.make_temp(type
, "adj");
4839 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4840 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4841 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4843 body
.emit(assign(array_ref(adj
, 0), neg(
4844 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4845 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4847 body
.emit(assign(array_ref(adj
, 1),
4848 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4849 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4851 body
.emit(assign(array_ref(adj
, 2), neg(
4852 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4853 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4856 body
.emit(assign(array_ref(adj
, 0),
4857 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4858 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4860 body
.emit(assign(array_ref(adj
, 1), neg(
4861 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4862 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4864 body
.emit(assign(array_ref(adj
, 2),
4865 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4866 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4869 ir_expression
*det
=
4870 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4871 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4872 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4874 body
.emit(ret(div(adj
, det
)));
4879 ir_function_signature
*
4880 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4882 ir_variable
*m
= in_var(type
, "m");
4883 const glsl_type
*btype
= type
->get_base_type();
4884 MAKE_SIG(type
, avail
, 1, m
);
4886 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4887 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4888 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4889 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4890 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4891 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4892 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4893 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4894 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4895 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4896 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4897 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4898 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4899 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4900 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4901 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4902 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4903 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4904 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4906 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)))));
4907 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)))));
4908 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)))));
4909 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)))));
4910 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)))));
4911 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)))));
4912 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)))));
4913 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)))));
4914 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)))));
4915 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)))));
4916 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)))));
4917 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)))));
4918 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)))));
4919 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)))));
4920 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)))));
4921 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)))));
4922 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)))));
4923 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)))));
4924 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)))));
4926 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4927 body
.emit(assign(array_ref(adj
, 0),
4928 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4929 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4930 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4932 body
.emit(assign(array_ref(adj
, 1), neg(
4933 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4934 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4935 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4937 body
.emit(assign(array_ref(adj
, 2),
4938 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4939 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4940 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4942 body
.emit(assign(array_ref(adj
, 3), neg(
4943 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4944 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4945 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4948 body
.emit(assign(array_ref(adj
, 0), neg(
4949 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4950 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4951 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4953 body
.emit(assign(array_ref(adj
, 1),
4954 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4955 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4956 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4958 body
.emit(assign(array_ref(adj
, 2), neg(
4959 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4960 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4961 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4963 body
.emit(assign(array_ref(adj
, 3),
4964 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4965 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4966 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4969 body
.emit(assign(array_ref(adj
, 0),
4970 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4971 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4972 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4974 body
.emit(assign(array_ref(adj
, 1), neg(
4975 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4976 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4977 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4979 body
.emit(assign(array_ref(adj
, 2),
4980 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4981 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4982 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4984 body
.emit(assign(array_ref(adj
, 3), neg(
4985 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4986 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4987 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4990 body
.emit(assign(array_ref(adj
, 0), neg(
4991 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4992 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4993 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4995 body
.emit(assign(array_ref(adj
, 1),
4996 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4997 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4998 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
5000 body
.emit(assign(array_ref(adj
, 2), neg(
5001 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
5002 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
5003 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
5005 body
.emit(assign(array_ref(adj
, 3),
5006 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
5007 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
5008 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
5011 ir_expression
*det
=
5012 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
5013 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
5014 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
5015 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
5017 body
.emit(ret(div(adj
, det
)));
5023 ir_function_signature
*
5024 builtin_builder::_lessThan(builtin_available_predicate avail
,
5025 const glsl_type
*type
)
5027 return binop(avail
, ir_binop_less
,
5028 glsl_type::bvec(type
->vector_elements
), type
, type
);
5031 ir_function_signature
*
5032 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
5033 const glsl_type
*type
)
5035 return binop(avail
, ir_binop_gequal
,
5036 glsl_type::bvec(type
->vector_elements
), type
, type
,
5040 ir_function_signature
*
5041 builtin_builder::_greaterThan(builtin_available_predicate avail
,
5042 const glsl_type
*type
)
5044 return binop(avail
, ir_binop_less
,
5045 glsl_type::bvec(type
->vector_elements
), type
, type
,
5049 ir_function_signature
*
5050 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
5051 const glsl_type
*type
)
5053 return binop(avail
, ir_binop_gequal
,
5054 glsl_type::bvec(type
->vector_elements
), type
, type
);
5057 ir_function_signature
*
5058 builtin_builder::_equal(builtin_available_predicate avail
,
5059 const glsl_type
*type
)
5061 return binop(avail
, ir_binop_equal
,
5062 glsl_type::bvec(type
->vector_elements
), type
, type
);
5065 ir_function_signature
*
5066 builtin_builder::_notEqual(builtin_available_predicate avail
,
5067 const glsl_type
*type
)
5069 return binop(avail
, ir_binop_nequal
,
5070 glsl_type::bvec(type
->vector_elements
), type
, type
);
5073 ir_function_signature
*
5074 builtin_builder::_any(const glsl_type
*type
)
5076 ir_variable
*v
= in_var(type
, "v");
5077 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5079 const unsigned vec_elem
= v
->type
->vector_elements
;
5080 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
5085 ir_function_signature
*
5086 builtin_builder::_all(const glsl_type
*type
)
5088 ir_variable
*v
= in_var(type
, "v");
5089 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5091 const unsigned vec_elem
= v
->type
->vector_elements
;
5092 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
5097 UNOP(not, ir_unop_logic_not
, always_available
)
5100 has_lod(const glsl_type
*sampler_type
)
5102 assert(sampler_type
->is_sampler());
5104 switch (sampler_type
->sampler_dimensionality
) {
5105 case GLSL_SAMPLER_DIM_RECT
:
5106 case GLSL_SAMPLER_DIM_BUF
:
5107 case GLSL_SAMPLER_DIM_MS
:
5114 ir_function_signature
*
5115 builtin_builder::_textureSize(builtin_available_predicate avail
,
5116 const glsl_type
*return_type
,
5117 const glsl_type
*sampler_type
)
5119 ir_variable
*s
= in_var(sampler_type
, "sampler");
5120 /* The sampler always exists; add optional lod later. */
5121 MAKE_SIG(return_type
, avail
, 1, s
);
5123 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
5124 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
5126 if (has_lod(sampler_type
)) {
5127 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5128 sig
->parameters
.push_tail(lod
);
5129 tex
->lod_info
.lod
= var_ref(lod
);
5131 tex
->lod_info
.lod
= imm(0u);
5134 body
.emit(ret(tex
));
5139 ir_function_signature
*
5140 builtin_builder::_textureSamples(builtin_available_predicate avail
,
5141 const glsl_type
*sampler_type
)
5143 ir_variable
*s
= in_var(sampler_type
, "sampler");
5144 MAKE_SIG(glsl_type::int_type
, avail
, 1, s
);
5146 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
5147 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
5148 body
.emit(ret(tex
));
5153 ir_function_signature
*
5154 builtin_builder::_texture(ir_texture_opcode opcode
,
5155 builtin_available_predicate avail
,
5156 const glsl_type
*return_type
,
5157 const glsl_type
*sampler_type
,
5158 const glsl_type
*coord_type
,
5161 ir_variable
*s
= in_var(sampler_type
, "sampler");
5162 ir_variable
*P
= in_var(coord_type
, "P");
5163 /* The sampler and coordinate always exist; add optional parameters later. */
5164 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5166 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
5167 tex
->set_sampler(var_ref(s
), return_type
);
5169 const int coord_size
= sampler_type
->coordinate_components();
5171 if (coord_size
== coord_type
->vector_elements
) {
5172 tex
->coordinate
= var_ref(P
);
5174 /* The incoming coordinate also has the projector or shadow comparator,
5175 * so we need to swizzle those away.
5177 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
5180 /* The projector is always in the last component. */
5181 if (flags
& TEX_PROJECT
)
5182 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
5184 if (sampler_type
->sampler_shadow
) {
5185 if (opcode
== ir_tg4
) {
5186 /* gather has refz as a separate parameter, immediately after the
5189 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
5190 sig
->parameters
.push_tail(refz
);
5191 tex
->shadow_comparator
= var_ref(refz
);
5193 /* The shadow comparator is normally in the Z component, but a few types
5194 * have sufficiently large coordinates that it's in W.
5196 tex
->shadow_comparator
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
5200 if (opcode
== ir_txl
) {
5201 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
5202 sig
->parameters
.push_tail(lod
);
5203 tex
->lod_info
.lod
= var_ref(lod
);
5204 } else if (opcode
== ir_txd
) {
5205 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5206 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
5207 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
5208 sig
->parameters
.push_tail(dPdx
);
5209 sig
->parameters
.push_tail(dPdy
);
5210 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
5211 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
5214 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
5215 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5216 ir_variable
*offset
=
5217 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
5218 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
5219 sig
->parameters
.push_tail(offset
);
5220 tex
->offset
= var_ref(offset
);
5223 if (flags
& TEX_OFFSET_ARRAY
) {
5224 ir_variable
*offsets
=
5225 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
5226 "offsets", ir_var_const_in
);
5227 sig
->parameters
.push_tail(offsets
);
5228 tex
->offset
= var_ref(offsets
);
5231 if (opcode
== ir_tg4
) {
5232 if (flags
& TEX_COMPONENT
) {
5233 ir_variable
*component
=
5234 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
5235 sig
->parameters
.push_tail(component
);
5236 tex
->lod_info
.component
= var_ref(component
);
5239 tex
->lod_info
.component
= imm(0);
5243 /* The "bias" parameter comes /after/ the "offset" parameter, which is
5244 * inconsistent with both textureLodOffset and textureGradOffset.
5246 if (opcode
== ir_txb
) {
5247 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
5248 sig
->parameters
.push_tail(bias
);
5249 tex
->lod_info
.bias
= var_ref(bias
);
5252 body
.emit(ret(tex
));
5257 ir_function_signature
*
5258 builtin_builder::_textureCubeArrayShadow(builtin_available_predicate avail
,
5259 const glsl_type
*sampler_type
)
5261 ir_variable
*s
= in_var(sampler_type
, "sampler");
5262 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
5263 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
5264 MAKE_SIG(glsl_type::float_type
, avail
, 3, s
, P
, compare
);
5266 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
5267 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
5269 tex
->coordinate
= var_ref(P
);
5270 tex
->shadow_comparator
= var_ref(compare
);
5272 body
.emit(ret(tex
));
5277 ir_function_signature
*
5278 builtin_builder::_texelFetch(builtin_available_predicate avail
,
5279 const glsl_type
*return_type
,
5280 const glsl_type
*sampler_type
,
5281 const glsl_type
*coord_type
,
5282 const glsl_type
*offset_type
)
5284 ir_variable
*s
= in_var(sampler_type
, "sampler");
5285 ir_variable
*P
= in_var(coord_type
, "P");
5286 /* The sampler and coordinate always exist; add optional parameters later. */
5287 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5289 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
5290 tex
->coordinate
= var_ref(P
);
5291 tex
->set_sampler(var_ref(s
), return_type
);
5293 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
5294 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
5295 sig
->parameters
.push_tail(sample
);
5296 tex
->lod_info
.sample_index
= var_ref(sample
);
5297 tex
->op
= ir_txf_ms
;
5298 } else if (has_lod(sampler_type
)) {
5299 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5300 sig
->parameters
.push_tail(lod
);
5301 tex
->lod_info
.lod
= var_ref(lod
);
5303 tex
->lod_info
.lod
= imm(0u);
5306 if (offset_type
!= NULL
) {
5307 ir_variable
*offset
=
5308 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
5309 sig
->parameters
.push_tail(offset
);
5310 tex
->offset
= var_ref(offset
);
5313 body
.emit(ret(tex
));
5318 ir_function_signature
*
5319 builtin_builder::_EmitVertex()
5321 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5323 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5324 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
5329 ir_function_signature
*
5330 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
5331 const glsl_type
*stream_type
)
5333 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5335 * "Emit the current values of output variables to the current output
5336 * primitive on stream stream. The argument to stream must be a constant
5337 * integral expression."
5339 ir_variable
*stream
=
5340 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5342 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5344 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
5349 ir_function_signature
*
5350 builtin_builder::_EndPrimitive()
5352 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5354 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5355 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
5360 ir_function_signature
*
5361 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
5362 const glsl_type
*stream_type
)
5364 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5366 * "Completes the current output primitive on stream stream and starts
5367 * a new one. The argument to stream must be a constant integral
5370 ir_variable
*stream
=
5371 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5373 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5375 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
5380 ir_function_signature
*
5381 builtin_builder::_barrier()
5383 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
5385 body
.emit(new(mem_ctx
) ir_barrier());
5389 ir_function_signature
*
5390 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
5391 const glsl_type
*sampler_type
,
5392 const glsl_type
*coord_type
)
5394 ir_variable
*s
= in_var(sampler_type
, "sampler");
5395 ir_variable
*coord
= in_var(coord_type
, "coord");
5396 /* The sampler and coordinate always exist; add optional parameters later. */
5397 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
5399 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
5400 tex
->coordinate
= var_ref(coord
);
5401 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
5403 body
.emit(ret(tex
));
5408 ir_function_signature
*
5409 builtin_builder::_textureQueryLevels(builtin_available_predicate avail
,
5410 const glsl_type
*sampler_type
)
5412 ir_variable
*s
= in_var(sampler_type
, "sampler");
5413 const glsl_type
*return_type
= glsl_type::int_type
;
5414 MAKE_SIG(return_type
, avail
, 1, s
);
5416 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
5417 tex
->set_sampler(var_ref(s
), return_type
);
5419 body
.emit(ret(tex
));
5424 ir_function_signature
*
5425 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
5426 const glsl_type
*sampler_type
,
5427 const glsl_type
*coord_type
)
5429 ir_variable
*s
= in_var(sampler_type
, "sampler");
5430 ir_variable
*P
= in_var(coord_type
, "P");
5431 const glsl_type
*return_type
= glsl_type::bool_type
;
5432 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5434 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
5435 tex
->coordinate
= var_ref(P
);
5436 tex
->set_sampler(var_ref(s
), return_type
);
5438 body
.emit(ret(tex
));
5443 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
5444 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
5445 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
5446 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
5447 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
5448 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
5450 ir_function_signature
*
5451 builtin_builder::_fwidth(const glsl_type
*type
)
5453 ir_variable
*p
= in_var(type
, "p");
5454 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
5456 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
5461 ir_function_signature
*
5462 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
5464 ir_variable
*p
= in_var(type
, "p");
5465 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5467 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
5468 abs(expr(ir_unop_dFdy_coarse
, p
)))));
5473 ir_function_signature
*
5474 builtin_builder::_fwidthFine(const glsl_type
*type
)
5476 ir_variable
*p
= in_var(type
, "p");
5477 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5479 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
5480 abs(expr(ir_unop_dFdy_fine
, p
)))));
5485 ir_function_signature
*
5486 builtin_builder::_noise1(const glsl_type
*type
)
5488 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
5491 ir_function_signature
*
5492 builtin_builder::_noise2(const glsl_type
*type
)
5494 ir_variable
*p
= in_var(type
, "p");
5495 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
5497 ir_constant_data b_offset
;
5498 b_offset
.f
[0] = 601.0f
;
5499 b_offset
.f
[1] = 313.0f
;
5500 b_offset
.f
[2] = 29.0f
;
5501 b_offset
.f
[3] = 277.0f
;
5503 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5504 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5505 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
5506 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5507 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5508 body
.emit(assign(t
, a
, WRITEMASK_X
));
5509 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5515 ir_function_signature
*
5516 builtin_builder::_noise3(const glsl_type
*type
)
5518 ir_variable
*p
= in_var(type
, "p");
5519 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
5521 ir_constant_data b_offset
;
5522 b_offset
.f
[0] = 601.0f
;
5523 b_offset
.f
[1] = 313.0f
;
5524 b_offset
.f
[2] = 29.0f
;
5525 b_offset
.f
[3] = 277.0f
;
5527 ir_constant_data c_offset
;
5528 c_offset
.f
[0] = 1559.0f
;
5529 c_offset
.f
[1] = 113.0f
;
5530 c_offset
.f
[2] = 1861.0f
;
5531 c_offset
.f
[3] = 797.0f
;
5533 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5534 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5535 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5536 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
5537 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5538 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5539 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
5540 body
.emit(assign(t
, a
, WRITEMASK_X
));
5541 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5542 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5548 ir_function_signature
*
5549 builtin_builder::_noise4(const glsl_type
*type
)
5551 ir_variable
*p
= in_var(type
, "p");
5552 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
5554 ir_variable
*_p
= body
.make_temp(type
, "_p");
5556 ir_constant_data p_offset
;
5557 p_offset
.f
[0] = 1559.0f
;
5558 p_offset
.f
[1] = 113.0f
;
5559 p_offset
.f
[2] = 1861.0f
;
5560 p_offset
.f
[3] = 797.0f
;
5562 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
5564 ir_constant_data offset
;
5565 offset
.f
[0] = 601.0f
;
5566 offset
.f
[1] = 313.0f
;
5567 offset
.f
[2] = 29.0f
;
5568 offset
.f
[3] = 277.0f
;
5570 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5571 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5572 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5573 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
5574 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
5575 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5576 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
5577 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
5578 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
5579 body
.emit(assign(t
, a
, WRITEMASK_X
));
5580 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5581 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5582 body
.emit(assign(t
, d
, WRITEMASK_W
));
5588 ir_function_signature
*
5589 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
5591 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5592 ir_variable
*value
= in_var(type
, "value");
5593 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5594 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5595 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, value
, offset
,
5598 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5599 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5601 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
5602 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5603 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5608 ir_function_signature
*
5609 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5611 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5612 ir_variable
*base
= in_var(type
, "base");
5613 ir_variable
*insert
= in_var(type
, "insert");
5614 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5615 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5616 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 4, base
, insert
,
5619 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5620 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5622 body
.emit(ret(bitfield_insert(base
, insert
,
5623 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5624 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5629 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31_or_integer_functions
)
5631 ir_function_signature
*
5632 builtin_builder::_bitCount(const glsl_type
*type
)
5634 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_bit_count
,
5635 glsl_type::ivec(type
->vector_elements
), type
);
5638 ir_function_signature
*
5639 builtin_builder::_findLSB(const glsl_type
*type
)
5641 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_lsb
,
5642 glsl_type::ivec(type
->vector_elements
), type
);
5645 ir_function_signature
*
5646 builtin_builder::_findMSB(const glsl_type
*type
)
5648 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_msb
,
5649 glsl_type::ivec(type
->vector_elements
), type
);
5652 ir_function_signature
*
5653 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5655 ir_variable
*a
= in_var(type
, "a");
5656 ir_variable
*b
= in_var(type
, "b");
5657 ir_variable
*c
= in_var(type
, "c");
5658 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5660 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5665 ir_function_signature
*
5666 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5668 return binop(x_type
->is_double() ? fp64
: gpu_shader5_or_es31_or_integer_functions
,
5669 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5672 ir_function_signature
*
5673 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5675 ir_variable
*x
= in_var(x_type
, "x");
5676 ir_variable
*exponent
= out_var(exp_type
, "exp");
5677 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5679 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5681 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5685 ir_function_signature
*
5686 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5688 ir_variable
*x
= in_var(x_type
, "x");
5689 ir_variable
*exponent
= out_var(exp_type
, "exp");
5690 MAKE_SIG(x_type
, gpu_shader5_or_es31_or_integer_functions
, 2, x
, exponent
);
5692 const unsigned vec_elem
= x_type
->vector_elements
;
5693 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5694 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5696 /* Single-precision floating-point values are stored as
5701 * An exponent shift of 23 will shift the mantissa out, leaving only the
5702 * exponent and sign bit (which itself may be zero, if the absolute value
5703 * was taken before the bitcast and shift.
5705 ir_constant
*exponent_shift
= imm(23);
5706 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5708 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5710 /* Exponent of floating-point values in the range [0.5, 1.0). */
5711 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5713 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5714 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5716 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5717 * to unsigned integers to ensure that 1 bits aren't shifted in.
5719 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5720 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5721 imm(0, vec_elem
)))));
5723 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5724 body
.emit(assign(bits
, bitcast_f2u(x
)));
5725 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5726 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5727 imm(0u, vec_elem
)))));
5728 body
.emit(ret(bitcast_u2f(bits
)));
5733 ir_function_signature
*
5734 builtin_builder::_uaddCarry(const glsl_type
*type
)
5736 ir_variable
*x
= in_var(type
, "x");
5737 ir_variable
*y
= in_var(type
, "y");
5738 ir_variable
*carry
= out_var(type
, "carry");
5739 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, carry
);
5741 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5742 body
.emit(ret(add(x
, y
)));
5747 ir_function_signature
*
5748 builtin_builder::_usubBorrow(const glsl_type
*type
)
5750 ir_variable
*x
= in_var(type
, "x");
5751 ir_variable
*y
= in_var(type
, "y");
5752 ir_variable
*borrow
= out_var(type
, "borrow");
5753 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, borrow
);
5755 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5756 body
.emit(ret(sub(x
, y
)));
5762 * For both imulExtended() and umulExtended() built-ins.
5764 ir_function_signature
*
5765 builtin_builder::_mulExtended(const glsl_type
*type
)
5767 ir_variable
*x
= in_var(type
, "x");
5768 ir_variable
*y
= in_var(type
, "y");
5769 ir_variable
*msb
= out_var(type
, "msb");
5770 ir_variable
*lsb
= out_var(type
, "lsb");
5771 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31_or_integer_functions
, 4, x
, y
, msb
, lsb
);
5773 body
.emit(assign(msb
, imul_high(x
, y
)));
5774 body
.emit(assign(lsb
, mul(x
, y
)));
5779 ir_function_signature
*
5780 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5782 ir_variable
*interpolant
= in_var(type
, "interpolant");
5783 interpolant
->data
.must_be_shader_input
= 1;
5784 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5786 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5791 ir_function_signature
*
5792 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5794 ir_variable
*interpolant
= in_var(type
, "interpolant");
5795 interpolant
->data
.must_be_shader_input
= 1;
5796 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5797 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5799 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5804 ir_function_signature
*
5805 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5807 ir_variable
*interpolant
= in_var(type
, "interpolant");
5808 interpolant
->data
.must_be_shader_input
= 1;
5809 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5810 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5812 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5817 ir_function_signature
*
5818 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
,
5819 enum ir_intrinsic_id id
)
5821 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5822 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 1, counter
);
5826 ir_function_signature
*
5827 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
,
5828 enum ir_intrinsic_id id
)
5830 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5831 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5832 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 2, counter
, data
);
5836 ir_function_signature
*
5837 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
,
5838 enum ir_intrinsic_id id
)
5840 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5841 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5842 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5843 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 3, counter
, compare
, data
);
5847 ir_function_signature
*
5848 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5849 const glsl_type
*type
,
5850 enum ir_intrinsic_id id
)
5852 ir_variable
*atomic
= in_var(type
, "atomic");
5853 ir_variable
*data
= in_var(type
, "data");
5854 MAKE_INTRINSIC(type
, id
, avail
, 2, atomic
, data
);
5858 ir_function_signature
*
5859 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5860 const glsl_type
*type
,
5861 enum ir_intrinsic_id id
)
5863 ir_variable
*atomic
= in_var(type
, "atomic");
5864 ir_variable
*data1
= in_var(type
, "data1");
5865 ir_variable
*data2
= in_var(type
, "data2");
5866 MAKE_INTRINSIC(type
, id
, avail
, 3, atomic
, data1
, data2
);
5870 ir_function_signature
*
5871 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5872 builtin_available_predicate avail
)
5874 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5875 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5877 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5878 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5880 body
.emit(ret(retval
));
5884 ir_function_signature
*
5885 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5886 builtin_available_predicate avail
)
5888 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5889 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5890 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5892 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5894 /* Instead of generating an __intrinsic_atomic_sub, generate an
5895 * __intrinsic_atomic_add with the data parameter negated.
5897 if (strcmp("__intrinsic_atomic_sub", intrinsic
) == 0) {
5898 ir_variable
*const neg_data
=
5899 body
.make_temp(glsl_type::uint_type
, "neg_data");
5901 body
.emit(assign(neg_data
, neg(data
)));
5903 exec_list parameters
;
5905 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(counter
));
5906 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(neg_data
));
5908 ir_function
*const func
=
5909 shader
->symbols
->get_function("__intrinsic_atomic_add");
5910 ir_instruction
*const c
= call(func
, retval
, parameters
);
5913 assert(parameters
.is_empty());
5917 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5921 body
.emit(ret(retval
));
5925 ir_function_signature
*
5926 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
5927 builtin_available_predicate avail
)
5929 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5930 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5931 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5932 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5934 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5935 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5937 body
.emit(ret(retval
));
5941 ir_function_signature
*
5942 builtin_builder::_atomic_op2(const char *intrinsic
,
5943 builtin_available_predicate avail
,
5944 const glsl_type
*type
)
5946 ir_variable
*atomic
= in_var(type
, "atomic_var");
5947 ir_variable
*data
= in_var(type
, "atomic_data");
5948 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5950 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5951 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5953 body
.emit(ret(retval
));
5957 ir_function_signature
*
5958 builtin_builder::_atomic_op3(const char *intrinsic
,
5959 builtin_available_predicate avail
,
5960 const glsl_type
*type
)
5962 ir_variable
*atomic
= in_var(type
, "atomic_var");
5963 ir_variable
*data1
= in_var(type
, "atomic_data1");
5964 ir_variable
*data2
= in_var(type
, "atomic_data2");
5965 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5967 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5968 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5970 body
.emit(ret(retval
));
5974 ir_function_signature
*
5975 builtin_builder::_min3(const glsl_type
*type
)
5977 ir_variable
*x
= in_var(type
, "x");
5978 ir_variable
*y
= in_var(type
, "y");
5979 ir_variable
*z
= in_var(type
, "z");
5980 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5982 ir_expression
*min3
= min2(x
, min2(y
,z
));
5983 body
.emit(ret(min3
));
5988 ir_function_signature
*
5989 builtin_builder::_max3(const glsl_type
*type
)
5991 ir_variable
*x
= in_var(type
, "x");
5992 ir_variable
*y
= in_var(type
, "y");
5993 ir_variable
*z
= in_var(type
, "z");
5994 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5996 ir_expression
*max3
= max2(x
, max2(y
,z
));
5997 body
.emit(ret(max3
));
6002 ir_function_signature
*
6003 builtin_builder::_mid3(const glsl_type
*type
)
6005 ir_variable
*x
= in_var(type
, "x");
6006 ir_variable
*y
= in_var(type
, "y");
6007 ir_variable
*z
= in_var(type
, "z");
6008 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6010 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
6011 body
.emit(ret(mid3
));
6016 static builtin_available_predicate
6017 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
6019 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
6020 type
->sampled_type
== GLSL_TYPE_FLOAT
)
6021 return shader_image_atomic_exchange_float
;
6023 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
6024 IMAGE_FUNCTION_AVAIL_ATOMIC
))
6025 return shader_image_atomic
;
6028 return shader_image_load_store
;
6031 ir_function_signature
*
6032 builtin_builder::_image_prototype(const glsl_type
*image_type
,
6033 unsigned num_arguments
,
6036 const glsl_type
*data_type
= glsl_type::get_instance(
6037 image_type
->sampled_type
,
6038 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
6040 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
6041 glsl_type::void_type
: data_type
);
6043 /* Addressing arguments that are always present. */
6044 ir_variable
*image
= in_var(image_type
, "image");
6045 ir_variable
*coord
= in_var(
6046 glsl_type::ivec(image_type
->coordinate_components()), "coord");
6048 ir_function_signature
*sig
= new_sig(
6049 ret_type
, get_image_available_predicate(image_type
, flags
),
6052 /* Sample index for multisample images. */
6053 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
6054 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
6056 /* Data arguments. */
6057 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
6058 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
6059 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
6060 ralloc_free(arg_name
);
6063 /* Set the maximal set of qualifiers allowed for this image
6064 * built-in. Function calls with arguments having fewer
6065 * qualifiers than present in the prototype are allowed by the
6066 * spec, but not with more, i.e. this will make the compiler
6067 * accept everything that needs to be accepted, and reject cases
6068 * like loads from write-only or stores to read-only images.
6070 image
->data
.memory_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
6071 image
->data
.memory_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
6072 image
->data
.memory_coherent
= true;
6073 image
->data
.memory_volatile
= true;
6074 image
->data
.memory_restrict
= true;
6079 ir_function_signature
*
6080 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
6081 unsigned /* num_arguments */,
6082 unsigned /* flags */)
6084 const glsl_type
*ret_type
;
6085 unsigned num_components
= image_type
->coordinate_components();
6087 /* From the ARB_shader_image_size extension:
6088 * "Cube images return the dimensions of one face."
6090 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
6091 !image_type
->sampler_array
) {
6095 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
6096 * supported by mesa.
6098 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
6100 ir_variable
*image
= in_var(image_type
, "image");
6101 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
6103 /* Set the maximal set of qualifiers allowed for this image
6104 * built-in. Function calls with arguments having fewer
6105 * qualifiers than present in the prototype are allowed by the
6106 * spec, but not with more, i.e. this will make the compiler
6107 * accept everything that needs to be accepted, and reject cases
6108 * like loads from write-only or stores to read-only images.
6110 image
->data
.memory_read_only
= true;
6111 image
->data
.memory_write_only
= true;
6112 image
->data
.memory_coherent
= true;
6113 image
->data
.memory_volatile
= true;
6114 image
->data
.memory_restrict
= true;
6119 ir_function_signature
*
6120 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
6121 unsigned /* num_arguments */,
6122 unsigned /* flags */)
6124 ir_variable
*image
= in_var(image_type
, "image");
6125 ir_function_signature
*sig
=
6126 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
6128 /* Set the maximal set of qualifiers allowed for this image
6129 * built-in. Function calls with arguments having fewer
6130 * qualifiers than present in the prototype are allowed by the
6131 * spec, but not with more, i.e. this will make the compiler
6132 * accept everything that needs to be accepted, and reject cases
6133 * like loads from write-only or stores to read-only images.
6135 image
->data
.memory_read_only
= true;
6136 image
->data
.memory_write_only
= true;
6137 image
->data
.memory_coherent
= true;
6138 image
->data
.memory_volatile
= true;
6139 image
->data
.memory_restrict
= true;
6144 ir_function_signature
*
6145 builtin_builder::_image(image_prototype_ctr prototype
,
6146 const glsl_type
*image_type
,
6147 const char *intrinsic_name
,
6148 unsigned num_arguments
,
6150 enum ir_intrinsic_id id
)
6152 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
6153 num_arguments
, flags
);
6155 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
6156 ir_factory
body(&sig
->body
, mem_ctx
);
6157 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
6159 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
6160 body
.emit(call(f
, NULL
, sig
->parameters
));
6162 ir_variable
*ret_val
=
6163 body
.make_temp(sig
->return_type
, "_ret_val");
6164 body
.emit(call(f
, ret_val
, sig
->parameters
));
6165 body
.emit(ret(ret_val
));
6168 sig
->is_defined
= true;
6171 sig
->intrinsic_id
= id
;
6177 ir_function_signature
*
6178 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
,
6179 enum ir_intrinsic_id id
)
6181 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6185 ir_function_signature
*
6186 builtin_builder::_memory_barrier(const char *intrinsic_name
,
6187 builtin_available_predicate avail
)
6189 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6190 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6191 NULL
, sig
->parameters
));
6195 ir_function_signature
*
6196 builtin_builder::_ballot_intrinsic()
6198 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6199 MAKE_INTRINSIC(glsl_type::uint64_t_type
, ir_intrinsic_ballot
, shader_ballot
,
6204 ir_function_signature
*
6205 builtin_builder::_ballot()
6207 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6209 MAKE_SIG(glsl_type::uint64_t_type
, shader_ballot
, 1, value
);
6210 ir_variable
*retval
= body
.make_temp(glsl_type::uint64_t_type
, "retval");
6212 body
.emit(call(shader
->symbols
->get_function("__intrinsic_ballot"),
6213 retval
, sig
->parameters
));
6214 body
.emit(ret(retval
));
6218 ir_function_signature
*
6219 builtin_builder::_read_first_invocation_intrinsic(const glsl_type
*type
)
6221 ir_variable
*value
= in_var(type
, "value");
6222 MAKE_INTRINSIC(type
, ir_intrinsic_read_first_invocation
, shader_ballot
,
6227 ir_function_signature
*
6228 builtin_builder::_read_first_invocation(const glsl_type
*type
)
6230 ir_variable
*value
= in_var(type
, "value");
6232 MAKE_SIG(type
, shader_ballot
, 1, value
);
6233 ir_variable
*retval
= body
.make_temp(type
, "retval");
6235 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_first_invocation"),
6236 retval
, sig
->parameters
));
6237 body
.emit(ret(retval
));
6241 ir_function_signature
*
6242 builtin_builder::_read_invocation_intrinsic(const glsl_type
*type
)
6244 ir_variable
*value
= in_var(type
, "value");
6245 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6246 MAKE_INTRINSIC(type
, ir_intrinsic_read_invocation
, shader_ballot
,
6247 2, value
, invocation
);
6251 ir_function_signature
*
6252 builtin_builder::_read_invocation(const glsl_type
*type
)
6254 ir_variable
*value
= in_var(type
, "value");
6255 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6257 MAKE_SIG(type
, shader_ballot
, 2, value
, invocation
);
6258 ir_variable
*retval
= body
.make_temp(type
, "retval");
6260 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_invocation"),
6261 retval
, sig
->parameters
));
6262 body
.emit(ret(retval
));
6266 ir_function_signature
*
6267 builtin_builder::_invocation_interlock_intrinsic(builtin_available_predicate avail
,
6268 enum ir_intrinsic_id id
)
6270 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6274 ir_function_signature
*
6275 builtin_builder::_invocation_interlock(const char *intrinsic_name
,
6276 builtin_available_predicate avail
)
6278 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6279 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6280 NULL
, sig
->parameters
));
6284 ir_function_signature
*
6285 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
6286 const glsl_type
*type
)
6288 MAKE_INTRINSIC(type
, ir_intrinsic_shader_clock
, avail
, 0);
6292 ir_function_signature
*
6293 builtin_builder::_shader_clock(builtin_available_predicate avail
,
6294 const glsl_type
*type
)
6296 MAKE_SIG(type
, avail
, 0);
6298 ir_variable
*retval
= body
.make_temp(glsl_type::uvec2_type
, "clock_retval");
6300 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
6301 retval
, sig
->parameters
));
6303 if (type
== glsl_type::uint64_t_type
) {
6304 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, retval
)));
6306 body
.emit(ret(retval
));
6312 ir_function_signature
*
6313 builtin_builder::_vote_intrinsic(builtin_available_predicate avail
,
6314 enum ir_intrinsic_id id
)
6316 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6317 MAKE_INTRINSIC(glsl_type::bool_type
, id
, avail
, 1, value
);
6321 ir_function_signature
*
6322 builtin_builder::_vote(const char *intrinsic_name
,
6323 builtin_available_predicate avail
)
6325 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6327 MAKE_SIG(glsl_type::bool_type
, avail
, 1, value
);
6329 ir_variable
*retval
= body
.make_temp(glsl_type::bool_type
, "retval");
6331 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6332 retval
, sig
->parameters
));
6333 body
.emit(ret(retval
));
6339 /******************************************************************************/
6341 /* The singleton instance of builtin_builder. */
6342 static builtin_builder builtins
;
6343 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
6346 * External API (exposing the built-in module to the rest of the compiler):
6350 _mesa_glsl_initialize_builtin_functions()
6352 mtx_lock(&builtins_lock
);
6353 builtins
.initialize();
6354 mtx_unlock(&builtins_lock
);
6358 _mesa_glsl_release_builtin_functions()
6360 mtx_lock(&builtins_lock
);
6362 mtx_unlock(&builtins_lock
);
6365 ir_function_signature
*
6366 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
6367 const char *name
, exec_list
*actual_parameters
)
6369 ir_function_signature
*s
;
6370 mtx_lock(&builtins_lock
);
6371 s
= builtins
.find(state
, name
, actual_parameters
);
6372 mtx_unlock(&builtins_lock
);
6378 _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state
*state
, const char *name
)
6382 mtx_lock(&builtins_lock
);
6383 f
= builtins
.shader
->symbols
->get_function(name
);
6385 foreach_in_list(ir_function_signature
, sig
, &f
->signatures
) {
6386 if (sig
->is_builtin_available(state
)) {
6392 mtx_unlock(&builtins_lock
);
6398 _mesa_glsl_get_builtin_function_shader()
6400 return builtins
.shader
;
6405 * Get the function signature for main from a shader
6407 ir_function_signature
*
6408 _mesa_get_main_function_signature(glsl_symbol_table
*symbols
)
6410 ir_function
*const f
= symbols
->get_function("main");
6412 exec_list void_parameters
;
6414 /* Look for the 'void main()' signature and ensure that it's defined.
6415 * This keeps the linker from accidentally pick a shader that just
6416 * contains a prototype for main.
6418 * We don't have to check for multiple definitions of main (in multiple
6419 * shaders) because that would have already been caught above.
6421 ir_function_signature
*sig
=
6422 f
->matching_signature(NULL
, &void_parameters
, false);
6423 if ((sig
!= NULL
) && sig
->is_defined
) {