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
||
450 state
->ctx
->Const
.AllowGLSLRelaxedES
);
454 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
456 return state
->stage
== MESA_SHADER_FRAGMENT
&&
457 (state
->is_version(450, 0) ||
458 state
->ARB_derivative_control_enable
);
462 tex1d_lod(const _mesa_glsl_parse_state
*state
)
464 return !state
->es_shader
&& lod_exists_in_stage(state
);
467 /** True if sampler3D exists */
469 tex3d(const _mesa_glsl_parse_state
*state
)
471 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
472 * OES_texture_3D extension, and in GLSL ES 3.00.
474 return !state
->es_shader
||
475 state
->OES_texture_3D_enable
||
476 state
->language_version
>= 300;
480 fs_tex3d(const _mesa_glsl_parse_state
*state
)
482 return state
->stage
== MESA_SHADER_FRAGMENT
&&
483 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
487 tex3d_lod(const _mesa_glsl_parse_state
*state
)
489 return tex3d(state
) && lod_exists_in_stage(state
);
493 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
495 return state
->has_atomic_counters();
499 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
501 return state
->ARB_shader_atomic_counter_ops_enable
;
505 shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
507 return state
->ARB_shader_atomic_counter_ops_enable
|| v460_desktop(state
);
511 shader_ballot(const _mesa_glsl_parse_state
*state
)
513 return state
->ARB_shader_ballot_enable
;
517 supports_arb_fragment_shader_interlock(const _mesa_glsl_parse_state
*state
)
519 return state
->ARB_fragment_shader_interlock_enable
;
523 supports_nv_fragment_shader_interlock(const _mesa_glsl_parse_state
*state
)
525 return state
->NV_fragment_shader_interlock_enable
;
529 shader_clock(const _mesa_glsl_parse_state
*state
)
531 return state
->ARB_shader_clock_enable
;
535 shader_clock_int64(const _mesa_glsl_parse_state
*state
)
537 return state
->ARB_shader_clock_enable
&&
538 (state
->ARB_gpu_shader_int64_enable
||
539 state
->AMD_gpu_shader_int64_enable
);
543 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
545 return state
->has_shader_storage_buffer_objects();
549 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
551 return state
->AMD_shader_trinary_minmax_enable
;
555 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
557 return (state
->is_version(420, 310) ||
558 state
->ARB_shader_image_load_store_enable
);
562 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
564 return (state
->is_version(420, 320) ||
565 state
->ARB_shader_image_load_store_enable
||
566 state
->OES_shader_image_atomic_enable
);
570 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
572 return (state
->is_version(450, 320) ||
573 state
->ARB_ES3_1_compatibility_enable
||
574 state
->OES_shader_image_atomic_enable
||
575 state
->NV_shader_atomic_float_enable
);
579 shader_image_atomic_add_float(const _mesa_glsl_parse_state
*state
)
581 return state
->NV_shader_atomic_float_enable
;
585 shader_image_size(const _mesa_glsl_parse_state
*state
)
587 return state
->is_version(430, 310) ||
588 state
->ARB_shader_image_size_enable
;
592 shader_samples(const _mesa_glsl_parse_state
*state
)
594 return state
->is_version(450, 0) ||
595 state
->ARB_shader_texture_image_samples_enable
;
599 gs_streams(const _mesa_glsl_parse_state
*state
)
601 return gpu_shader5(state
) && gs_only(state
);
605 fp64(const _mesa_glsl_parse_state
*state
)
607 return state
->has_double();
611 int64(const _mesa_glsl_parse_state
*state
)
613 return state
->has_int64();
617 int64_fp64(const _mesa_glsl_parse_state
*state
)
619 return state
->has_int64() && state
->has_double();
623 compute_shader(const _mesa_glsl_parse_state
*state
)
625 return state
->stage
== MESA_SHADER_COMPUTE
;
629 compute_shader_supported(const _mesa_glsl_parse_state
*state
)
631 return state
->has_compute_shader();
635 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
637 return compute_shader(state
) || shader_storage_buffer_object(state
);
641 barrier_supported(const _mesa_glsl_parse_state
*state
)
643 return compute_shader(state
) ||
644 state
->stage
== MESA_SHADER_TESS_CTRL
;
648 vote(const _mesa_glsl_parse_state
*state
)
650 return state
->ARB_shader_group_vote_enable
;
654 vote_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
656 return state
->ARB_shader_group_vote_enable
|| v460_desktop(state
);
660 integer_functions_supported(const _mesa_glsl_parse_state
*state
)
662 return state
->extensions
->MESA_shader_integer_functions
;
666 NV_shader_atomic_float_supported(const _mesa_glsl_parse_state
*state
)
668 return state
->extensions
->NV_shader_atomic_float
;
672 shader_atomic_float_add(const _mesa_glsl_parse_state
*state
)
674 return state
->NV_shader_atomic_float_enable
;
678 shader_atomic_float_exchange(const _mesa_glsl_parse_state
*state
)
680 return state
->NV_shader_atomic_float_enable
||
681 state
->INTEL_shader_atomic_float_minmax_enable
;
685 INTEL_shader_atomic_float_minmax_supported(const _mesa_glsl_parse_state
*state
)
687 return state
->extensions
->INTEL_shader_atomic_float_minmax
;
691 shader_atomic_float_minmax(const _mesa_glsl_parse_state
*state
)
693 return state
->INTEL_shader_atomic_float_minmax_enable
;
697 /******************************************************************************/
702 * builtin_builder: A singleton object representing the core of the built-in
705 * It generates IR for every built-in function signature, and organizes them
708 class builtin_builder
{
715 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
716 const char *name
, exec_list
*actual_parameters
);
719 * A shader to hold all the built-in signatures; created by this module.
721 * This includes signatures for every built-in, regardless of version or
722 * enabled extensions. The availability predicate associated with each
723 * signature allows matching_signature() to filter out the irrelevant ones.
730 void create_shader();
731 void create_intrinsics();
732 void create_builtins();
735 * IR builder helpers:
737 * These convenience functions assist in emitting IR, but don't necessarily
738 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
741 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
742 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
743 ir_constant
*imm(float f
, unsigned vector_elements
=1);
744 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
745 ir_constant
*imm(int i
, unsigned vector_elements
=1);
746 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
747 ir_constant
*imm(double d
, unsigned vector_elements
=1);
748 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
749 ir_dereference_variable
*var_ref(ir_variable
*var
);
750 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
751 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
753 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
754 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
757 * Call function \param f with parameters specified as the linked
758 * list \param params of \c ir_variable objects. \param ret should
759 * point to the ir_variable that will hold the function return
760 * value, or be \c NULL if the function has void return type.
762 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
764 /** Create a new function and add the given signatures. */
765 void add_function(const char *name
, ...);
767 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
768 unsigned num_arguments
,
772 * Create a new image built-in function for all known image types.
773 * \p flags is a bitfield of \c image_function_flags flags.
775 void add_image_function(const char *name
,
776 const char *intrinsic_name
,
777 image_prototype_ctr prototype
,
778 unsigned num_arguments
,
780 enum ir_intrinsic_id id
);
783 * Create new functions for all known image built-ins and types.
784 * If \p glsl is \c true, use the GLSL built-in names and emit code
785 * to call into the actual compiler intrinsic. If \p glsl is
786 * false, emit a function prototype with no body for each image
789 void add_image_functions(bool glsl
);
791 ir_function_signature
*new_sig(const glsl_type
*return_type
,
792 builtin_available_predicate avail
,
793 int num_params
, ...);
796 * Function signature generators:
799 ir_function_signature
*unop(builtin_available_predicate avail
,
800 ir_expression_operation opcode
,
801 const glsl_type
*return_type
,
802 const glsl_type
*param_type
);
803 ir_function_signature
*binop(builtin_available_predicate avail
,
804 ir_expression_operation opcode
,
805 const glsl_type
*return_type
,
806 const glsl_type
*param0_type
,
807 const glsl_type
*param1_type
,
808 bool swap_operands
= false);
810 #define B0(X) ir_function_signature *_##X();
811 #define B1(X) ir_function_signature *_##X(const glsl_type *);
812 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
813 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
814 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
815 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
852 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
853 const glsl_type
*val_type
,
854 const glsl_type
*blend_type
);
864 BA1(doubleBitsToInt64
)
865 BA1(doubleBitsToUint64
)
866 BA1(int64BitsToDouble
)
867 BA1(uint64BitsToDouble
)
869 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
870 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
871 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
872 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
873 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
874 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
875 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
876 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
877 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
878 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
879 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
880 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
881 ir_function_signature
*_packInt2x32(builtin_available_predicate avail
);
882 ir_function_signature
*_unpackInt2x32(builtin_available_predicate avail
);
883 ir_function_signature
*_packUint2x32(builtin_available_predicate avail
);
884 ir_function_signature
*_unpackUint2x32(builtin_available_predicate avail
);
897 BA1(determinant_mat2
);
898 BA1(determinant_mat3
);
899 BA1(determinant_mat4
);
907 BA1(greaterThanEqual
);
916 /** Flags to _texture() */
917 #define TEX_PROJECT 1
919 #define TEX_COMPONENT 4
920 #define TEX_OFFSET_NONCONST 8
921 #define TEX_OFFSET_ARRAY 16
923 ir_function_signature
*_texture(ir_texture_opcode opcode
,
924 builtin_available_predicate avail
,
925 const glsl_type
*return_type
,
926 const glsl_type
*sampler_type
,
927 const glsl_type
*coord_type
,
929 BA1(textureCubeArrayShadow
);
930 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
931 const glsl_type
*return_type
,
932 const glsl_type
*sampler_type
,
933 const glsl_type
*coord_type
,
934 const glsl_type
*offset_type
= NULL
);
938 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
939 const glsl_type
*stream_type
);
940 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
941 const glsl_type
*stream_type
);
944 BA2(textureQueryLod
);
945 BA1(textureQueryLevels
);
946 BA2(textureSamplesIdentical
);
974 B1(interpolateAtCentroid
)
975 B1(interpolateAtOffset
)
976 B1(interpolateAtSample
)
978 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
,
979 enum ir_intrinsic_id id
);
980 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
,
981 enum ir_intrinsic_id id
);
982 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
,
983 enum ir_intrinsic_id id
);
984 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
985 builtin_available_predicate avail
);
986 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
987 builtin_available_predicate avail
);
988 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
989 builtin_available_predicate avail
);
991 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
992 const glsl_type
*type
,
993 enum ir_intrinsic_id id
);
994 ir_function_signature
*_atomic_op2(const char *intrinsic
,
995 builtin_available_predicate avail
,
996 const glsl_type
*type
);
997 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
998 const glsl_type
*type
,
999 enum ir_intrinsic_id id
);
1000 ir_function_signature
*_atomic_op3(const char *intrinsic
,
1001 builtin_available_predicate avail
,
1002 const glsl_type
*type
);
1008 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
1009 unsigned num_arguments
,
1011 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
1012 unsigned num_arguments
,
1014 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
1015 unsigned num_arguments
,
1017 ir_function_signature
*_image(image_prototype_ctr prototype
,
1018 const glsl_type
*image_type
,
1019 const char *intrinsic_name
,
1020 unsigned num_arguments
,
1022 enum ir_intrinsic_id id
);
1024 ir_function_signature
*_memory_barrier_intrinsic(
1025 builtin_available_predicate avail
,
1026 enum ir_intrinsic_id id
);
1027 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
1028 builtin_available_predicate avail
);
1030 ir_function_signature
*_ballot_intrinsic();
1031 ir_function_signature
*_ballot();
1032 ir_function_signature
*_read_first_invocation_intrinsic(const glsl_type
*type
);
1033 ir_function_signature
*_read_first_invocation(const glsl_type
*type
);
1034 ir_function_signature
*_read_invocation_intrinsic(const glsl_type
*type
);
1035 ir_function_signature
*_read_invocation(const glsl_type
*type
);
1038 ir_function_signature
*_invocation_interlock_intrinsic(
1039 builtin_available_predicate avail
,
1040 enum ir_intrinsic_id id
);
1041 ir_function_signature
*_invocation_interlock(
1042 const char *intrinsic_name
,
1043 builtin_available_predicate avail
);
1045 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
1046 const glsl_type
*type
);
1047 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
1048 const glsl_type
*type
);
1050 ir_function_signature
*_vote_intrinsic(builtin_available_predicate avail
,
1051 enum ir_intrinsic_id id
);
1052 ir_function_signature
*_vote(const char *intrinsic_name
,
1053 builtin_available_predicate avail
);
1064 enum image_function_flags
{
1065 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
1066 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
1067 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
1068 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
1069 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
1070 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
1071 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
1072 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
1073 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8),
1074 IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
= (1 << 9),
1077 } /* anonymous namespace */
1080 * Core builtin_builder functionality:
1083 builtin_builder::builtin_builder()
1089 builtin_builder::~builtin_builder()
1091 ralloc_free(mem_ctx
);
1094 ir_function_signature
*
1095 builtin_builder::find(_mesa_glsl_parse_state
*state
,
1096 const char *name
, exec_list
*actual_parameters
)
1098 /* The shader currently being compiled requested a built-in function;
1099 * it needs to link against builtin_builder::shader in order to get them.
1101 * Even if we don't find a matching signature, we still need to do this so
1102 * that the "no matching signature" error will list potential candidates
1103 * from the available built-ins.
1105 state
->uses_builtin_functions
= true;
1107 ir_function
*f
= shader
->symbols
->get_function(name
);
1111 ir_function_signature
*sig
=
1112 f
->matching_signature(state
, actual_parameters
, true);
1120 builtin_builder::initialize()
1122 /* If already initialized, don't do it again. */
1123 if (mem_ctx
!= NULL
)
1126 mem_ctx
= ralloc_context(NULL
);
1128 create_intrinsics();
1133 builtin_builder::release()
1135 ralloc_free(mem_ctx
);
1138 ralloc_free(shader
);
1143 builtin_builder::create_shader()
1145 /* The target doesn't actually matter. There's no target for generic
1146 * GLSL utility code that could be linked against any stage, so just
1147 * arbitrarily pick GL_VERTEX_SHADER.
1149 shader
= _mesa_new_shader(0, MESA_SHADER_VERTEX
);
1150 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
1156 * Create ir_function and ir_function_signature objects for each
1160 builtin_builder::create_intrinsics()
1162 add_function("__intrinsic_atomic_read",
1163 _atomic_counter_intrinsic(shader_atomic_counters
,
1164 ir_intrinsic_atomic_counter_read
),
1166 add_function("__intrinsic_atomic_increment",
1167 _atomic_counter_intrinsic(shader_atomic_counters
,
1168 ir_intrinsic_atomic_counter_increment
),
1170 add_function("__intrinsic_atomic_predecrement",
1171 _atomic_counter_intrinsic(shader_atomic_counters
,
1172 ir_intrinsic_atomic_counter_predecrement
),
1175 add_function("__intrinsic_atomic_add",
1176 _atomic_intrinsic2(buffer_atomics_supported
,
1177 glsl_type::uint_type
,
1178 ir_intrinsic_generic_atomic_add
),
1179 _atomic_intrinsic2(buffer_atomics_supported
,
1180 glsl_type::int_type
,
1181 ir_intrinsic_generic_atomic_add
),
1182 _atomic_intrinsic2(NV_shader_atomic_float_supported
,
1183 glsl_type::float_type
,
1184 ir_intrinsic_generic_atomic_add
),
1185 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1186 ir_intrinsic_atomic_counter_add
),
1188 add_function("__intrinsic_atomic_min",
1189 _atomic_intrinsic2(buffer_atomics_supported
,
1190 glsl_type::uint_type
,
1191 ir_intrinsic_generic_atomic_min
),
1192 _atomic_intrinsic2(buffer_atomics_supported
,
1193 glsl_type::int_type
,
1194 ir_intrinsic_generic_atomic_min
),
1195 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported
,
1196 glsl_type::float_type
,
1197 ir_intrinsic_generic_atomic_min
),
1198 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1199 ir_intrinsic_atomic_counter_min
),
1201 add_function("__intrinsic_atomic_max",
1202 _atomic_intrinsic2(buffer_atomics_supported
,
1203 glsl_type::uint_type
,
1204 ir_intrinsic_generic_atomic_max
),
1205 _atomic_intrinsic2(buffer_atomics_supported
,
1206 glsl_type::int_type
,
1207 ir_intrinsic_generic_atomic_max
),
1208 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported
,
1209 glsl_type::float_type
,
1210 ir_intrinsic_generic_atomic_max
),
1211 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1212 ir_intrinsic_atomic_counter_max
),
1214 add_function("__intrinsic_atomic_and",
1215 _atomic_intrinsic2(buffer_atomics_supported
,
1216 glsl_type::uint_type
,
1217 ir_intrinsic_generic_atomic_and
),
1218 _atomic_intrinsic2(buffer_atomics_supported
,
1219 glsl_type::int_type
,
1220 ir_intrinsic_generic_atomic_and
),
1221 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1222 ir_intrinsic_atomic_counter_and
),
1224 add_function("__intrinsic_atomic_or",
1225 _atomic_intrinsic2(buffer_atomics_supported
,
1226 glsl_type::uint_type
,
1227 ir_intrinsic_generic_atomic_or
),
1228 _atomic_intrinsic2(buffer_atomics_supported
,
1229 glsl_type::int_type
,
1230 ir_intrinsic_generic_atomic_or
),
1231 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1232 ir_intrinsic_atomic_counter_or
),
1234 add_function("__intrinsic_atomic_xor",
1235 _atomic_intrinsic2(buffer_atomics_supported
,
1236 glsl_type::uint_type
,
1237 ir_intrinsic_generic_atomic_xor
),
1238 _atomic_intrinsic2(buffer_atomics_supported
,
1239 glsl_type::int_type
,
1240 ir_intrinsic_generic_atomic_xor
),
1241 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1242 ir_intrinsic_atomic_counter_xor
),
1244 add_function("__intrinsic_atomic_exchange",
1245 _atomic_intrinsic2(buffer_atomics_supported
,
1246 glsl_type::uint_type
,
1247 ir_intrinsic_generic_atomic_exchange
),
1248 _atomic_intrinsic2(buffer_atomics_supported
,
1249 glsl_type::int_type
,
1250 ir_intrinsic_generic_atomic_exchange
),
1251 _atomic_intrinsic2(NV_shader_atomic_float_supported
,
1252 glsl_type::float_type
,
1253 ir_intrinsic_generic_atomic_exchange
),
1254 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1255 ir_intrinsic_atomic_counter_exchange
),
1257 add_function("__intrinsic_atomic_comp_swap",
1258 _atomic_intrinsic3(buffer_atomics_supported
,
1259 glsl_type::uint_type
,
1260 ir_intrinsic_generic_atomic_comp_swap
),
1261 _atomic_intrinsic3(buffer_atomics_supported
,
1262 glsl_type::int_type
,
1263 ir_intrinsic_generic_atomic_comp_swap
),
1264 _atomic_intrinsic3(INTEL_shader_atomic_float_minmax_supported
,
1265 glsl_type::float_type
,
1266 ir_intrinsic_generic_atomic_comp_swap
),
1267 _atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop
,
1268 ir_intrinsic_atomic_counter_comp_swap
),
1271 add_image_functions(false);
1273 add_function("__intrinsic_memory_barrier",
1274 _memory_barrier_intrinsic(shader_image_load_store
,
1275 ir_intrinsic_memory_barrier
),
1277 add_function("__intrinsic_group_memory_barrier",
1278 _memory_barrier_intrinsic(compute_shader
,
1279 ir_intrinsic_group_memory_barrier
),
1281 add_function("__intrinsic_memory_barrier_atomic_counter",
1282 _memory_barrier_intrinsic(compute_shader_supported
,
1283 ir_intrinsic_memory_barrier_atomic_counter
),
1285 add_function("__intrinsic_memory_barrier_buffer",
1286 _memory_barrier_intrinsic(compute_shader_supported
,
1287 ir_intrinsic_memory_barrier_buffer
),
1289 add_function("__intrinsic_memory_barrier_image",
1290 _memory_barrier_intrinsic(compute_shader_supported
,
1291 ir_intrinsic_memory_barrier_image
),
1293 add_function("__intrinsic_memory_barrier_shared",
1294 _memory_barrier_intrinsic(compute_shader
,
1295 ir_intrinsic_memory_barrier_shared
),
1298 add_function("__intrinsic_begin_invocation_interlock",
1299 _invocation_interlock_intrinsic(
1300 supports_arb_fragment_shader_interlock
,
1301 ir_intrinsic_begin_invocation_interlock
), NULL
);
1303 add_function("__intrinsic_end_invocation_interlock",
1304 _invocation_interlock_intrinsic(
1305 supports_arb_fragment_shader_interlock
,
1306 ir_intrinsic_end_invocation_interlock
), NULL
);
1308 add_function("__intrinsic_shader_clock",
1309 _shader_clock_intrinsic(shader_clock
,
1310 glsl_type::uvec2_type
),
1313 add_function("__intrinsic_vote_all",
1314 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_all
),
1316 add_function("__intrinsic_vote_any",
1317 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_any
),
1319 add_function("__intrinsic_vote_eq",
1320 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_eq
),
1323 add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL
);
1325 add_function("__intrinsic_read_invocation",
1326 _read_invocation_intrinsic(glsl_type::float_type
),
1327 _read_invocation_intrinsic(glsl_type::vec2_type
),
1328 _read_invocation_intrinsic(glsl_type::vec3_type
),
1329 _read_invocation_intrinsic(glsl_type::vec4_type
),
1331 _read_invocation_intrinsic(glsl_type::int_type
),
1332 _read_invocation_intrinsic(glsl_type::ivec2_type
),
1333 _read_invocation_intrinsic(glsl_type::ivec3_type
),
1334 _read_invocation_intrinsic(glsl_type::ivec4_type
),
1336 _read_invocation_intrinsic(glsl_type::uint_type
),
1337 _read_invocation_intrinsic(glsl_type::uvec2_type
),
1338 _read_invocation_intrinsic(glsl_type::uvec3_type
),
1339 _read_invocation_intrinsic(glsl_type::uvec4_type
),
1342 add_function("__intrinsic_read_first_invocation",
1343 _read_first_invocation_intrinsic(glsl_type::float_type
),
1344 _read_first_invocation_intrinsic(glsl_type::vec2_type
),
1345 _read_first_invocation_intrinsic(glsl_type::vec3_type
),
1346 _read_first_invocation_intrinsic(glsl_type::vec4_type
),
1348 _read_first_invocation_intrinsic(glsl_type::int_type
),
1349 _read_first_invocation_intrinsic(glsl_type::ivec2_type
),
1350 _read_first_invocation_intrinsic(glsl_type::ivec3_type
),
1351 _read_first_invocation_intrinsic(glsl_type::ivec4_type
),
1353 _read_first_invocation_intrinsic(glsl_type::uint_type
),
1354 _read_first_invocation_intrinsic(glsl_type::uvec2_type
),
1355 _read_first_invocation_intrinsic(glsl_type::uvec3_type
),
1356 _read_first_invocation_intrinsic(glsl_type::uvec4_type
),
1362 * Create ir_function and ir_function_signature objects for each built-in.
1364 * Contains a list of every available built-in.
1367 builtin_builder::create_builtins()
1370 add_function(#NAME, \
1371 _##NAME(glsl_type::float_type), \
1372 _##NAME(glsl_type::vec2_type), \
1373 _##NAME(glsl_type::vec3_type), \
1374 _##NAME(glsl_type::vec4_type), \
1378 add_function(#NAME, \
1379 _##NAME(always_available, glsl_type::float_type), \
1380 _##NAME(always_available, glsl_type::vec2_type), \
1381 _##NAME(always_available, glsl_type::vec3_type), \
1382 _##NAME(always_available, glsl_type::vec4_type), \
1383 _##NAME(fp64, glsl_type::double_type), \
1384 _##NAME(fp64, glsl_type::dvec2_type), \
1385 _##NAME(fp64, glsl_type::dvec3_type), \
1386 _##NAME(fp64, glsl_type::dvec4_type), \
1389 #define FD130(NAME) \
1390 add_function(#NAME, \
1391 _##NAME(v130, glsl_type::float_type), \
1392 _##NAME(v130, glsl_type::vec2_type), \
1393 _##NAME(v130, glsl_type::vec3_type), \
1394 _##NAME(v130, glsl_type::vec4_type), \
1395 _##NAME(fp64, glsl_type::double_type), \
1396 _##NAME(fp64, glsl_type::dvec2_type), \
1397 _##NAME(fp64, glsl_type::dvec3_type), \
1398 _##NAME(fp64, glsl_type::dvec4_type), \
1401 #define FDGS5(NAME) \
1402 add_function(#NAME, \
1403 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1404 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1405 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1406 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1407 _##NAME(fp64, glsl_type::double_type), \
1408 _##NAME(fp64, glsl_type::dvec2_type), \
1409 _##NAME(fp64, glsl_type::dvec3_type), \
1410 _##NAME(fp64, glsl_type::dvec4_type), \
1414 add_function(#NAME, \
1415 _##NAME(glsl_type::float_type), \
1416 _##NAME(glsl_type::vec2_type), \
1417 _##NAME(glsl_type::vec3_type), \
1418 _##NAME(glsl_type::vec4_type), \
1419 _##NAME(glsl_type::int_type), \
1420 _##NAME(glsl_type::ivec2_type), \
1421 _##NAME(glsl_type::ivec3_type), \
1422 _##NAME(glsl_type::ivec4_type), \
1425 #define FI64(NAME) \
1426 add_function(#NAME, \
1427 _##NAME(always_available, glsl_type::float_type), \
1428 _##NAME(always_available, glsl_type::vec2_type), \
1429 _##NAME(always_available, glsl_type::vec3_type), \
1430 _##NAME(always_available, glsl_type::vec4_type), \
1431 _##NAME(always_available, glsl_type::int_type), \
1432 _##NAME(always_available, glsl_type::ivec2_type), \
1433 _##NAME(always_available, glsl_type::ivec3_type), \
1434 _##NAME(always_available, glsl_type::ivec4_type), \
1435 _##NAME(fp64, glsl_type::double_type), \
1436 _##NAME(fp64, glsl_type::dvec2_type), \
1437 _##NAME(fp64, glsl_type::dvec3_type), \
1438 _##NAME(fp64, glsl_type::dvec4_type), \
1439 _##NAME(int64, glsl_type::int64_t_type), \
1440 _##NAME(int64, glsl_type::i64vec2_type), \
1441 _##NAME(int64, glsl_type::i64vec3_type), \
1442 _##NAME(int64, glsl_type::i64vec4_type), \
1445 #define FIUD_VEC(NAME) \
1446 add_function(#NAME, \
1447 _##NAME(always_available, glsl_type::vec2_type), \
1448 _##NAME(always_available, glsl_type::vec3_type), \
1449 _##NAME(always_available, glsl_type::vec4_type), \
1451 _##NAME(always_available, glsl_type::ivec2_type), \
1452 _##NAME(always_available, glsl_type::ivec3_type), \
1453 _##NAME(always_available, glsl_type::ivec4_type), \
1455 _##NAME(v130, glsl_type::uvec2_type), \
1456 _##NAME(v130, glsl_type::uvec3_type), \
1457 _##NAME(v130, glsl_type::uvec4_type), \
1458 _##NAME(fp64, glsl_type::dvec2_type), \
1459 _##NAME(fp64, glsl_type::dvec3_type), \
1460 _##NAME(fp64, glsl_type::dvec4_type), \
1461 _##NAME(int64, glsl_type::int64_t_type), \
1462 _##NAME(int64, glsl_type::i64vec2_type), \
1463 _##NAME(int64, glsl_type::i64vec3_type), \
1464 _##NAME(int64, glsl_type::i64vec4_type), \
1465 _##NAME(int64, glsl_type::uint64_t_type), \
1466 _##NAME(int64, glsl_type::u64vec2_type), \
1467 _##NAME(int64, glsl_type::u64vec3_type), \
1468 _##NAME(int64, glsl_type::u64vec4_type), \
1472 add_function(#NAME, \
1473 _##NAME(glsl_type::int_type), \
1474 _##NAME(glsl_type::ivec2_type), \
1475 _##NAME(glsl_type::ivec3_type), \
1476 _##NAME(glsl_type::ivec4_type), \
1478 _##NAME(glsl_type::uint_type), \
1479 _##NAME(glsl_type::uvec2_type), \
1480 _##NAME(glsl_type::uvec3_type), \
1481 _##NAME(glsl_type::uvec4_type), \
1484 #define FIUBD_VEC(NAME) \
1485 add_function(#NAME, \
1486 _##NAME(always_available, glsl_type::vec2_type), \
1487 _##NAME(always_available, glsl_type::vec3_type), \
1488 _##NAME(always_available, glsl_type::vec4_type), \
1490 _##NAME(always_available, glsl_type::ivec2_type), \
1491 _##NAME(always_available, glsl_type::ivec3_type), \
1492 _##NAME(always_available, glsl_type::ivec4_type), \
1494 _##NAME(v130, glsl_type::uvec2_type), \
1495 _##NAME(v130, glsl_type::uvec3_type), \
1496 _##NAME(v130, glsl_type::uvec4_type), \
1498 _##NAME(always_available, glsl_type::bvec2_type), \
1499 _##NAME(always_available, glsl_type::bvec3_type), \
1500 _##NAME(always_available, glsl_type::bvec4_type), \
1502 _##NAME(fp64, glsl_type::dvec2_type), \
1503 _##NAME(fp64, glsl_type::dvec3_type), \
1504 _##NAME(fp64, glsl_type::dvec4_type), \
1505 _##NAME(int64, glsl_type::int64_t_type), \
1506 _##NAME(int64, glsl_type::i64vec2_type), \
1507 _##NAME(int64, glsl_type::i64vec3_type), \
1508 _##NAME(int64, glsl_type::i64vec4_type), \
1509 _##NAME(int64, glsl_type::uint64_t_type), \
1510 _##NAME(int64, glsl_type::u64vec2_type), \
1511 _##NAME(int64, glsl_type::u64vec3_type), \
1512 _##NAME(int64, glsl_type::u64vec4_type), \
1515 #define FIUD2_MIXED(NAME) \
1516 add_function(#NAME, \
1517 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1518 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1519 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1520 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1522 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1523 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1524 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1526 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1527 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1528 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1529 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1531 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1532 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1533 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1535 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1536 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1537 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1538 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1540 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1541 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1542 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1544 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1545 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1546 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1547 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1548 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1549 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1550 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1552 _##NAME(int64, glsl_type::int64_t_type, glsl_type::int64_t_type), \
1553 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::int64_t_type), \
1554 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::int64_t_type), \
1555 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::int64_t_type), \
1556 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::i64vec2_type), \
1557 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::i64vec3_type), \
1558 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::i64vec4_type), \
1559 _##NAME(int64, glsl_type::uint64_t_type, glsl_type::uint64_t_type), \
1560 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::uint64_t_type), \
1561 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::uint64_t_type), \
1562 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::uint64_t_type), \
1563 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::u64vec2_type), \
1564 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::u64vec3_type), \
1565 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::u64vec4_type), \
1576 add_function("atan",
1577 _atan(glsl_type::float_type
),
1578 _atan(glsl_type::vec2_type
),
1579 _atan(glsl_type::vec3_type
),
1580 _atan(glsl_type::vec4_type
),
1581 _atan2(glsl_type::float_type
),
1582 _atan2(glsl_type::vec2_type
),
1583 _atan2(glsl_type::vec3_type
),
1584 _atan2(glsl_type::vec4_type
),
1610 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1611 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1612 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1613 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1615 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1616 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1617 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1619 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1620 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1621 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1622 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1624 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1625 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1626 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1636 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1637 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1638 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1639 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1641 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1642 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1643 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1645 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1646 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1647 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1648 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1650 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1651 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1652 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1654 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1655 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1656 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1657 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1659 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1660 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1661 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1662 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1664 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1665 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1666 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1667 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1669 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1670 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1671 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1672 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1674 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1675 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1676 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1677 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1679 _mix_sel(int64
, glsl_type::int64_t_type
, glsl_type::bool_type
),
1680 _mix_sel(int64
, glsl_type::i64vec2_type
, glsl_type::bvec2_type
),
1681 _mix_sel(int64
, glsl_type::i64vec3_type
, glsl_type::bvec3_type
),
1682 _mix_sel(int64
, glsl_type::i64vec4_type
, glsl_type::bvec4_type
),
1684 _mix_sel(int64
, glsl_type::uint64_t_type
, glsl_type::bool_type
),
1685 _mix_sel(int64
, glsl_type::u64vec2_type
, glsl_type::bvec2_type
),
1686 _mix_sel(int64
, glsl_type::u64vec3_type
, glsl_type::bvec3_type
),
1687 _mix_sel(int64
, glsl_type::u64vec4_type
, glsl_type::bvec4_type
),
1690 add_function("step",
1691 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1692 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1693 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1694 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1696 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1697 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1698 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1699 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1700 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1701 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1702 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1704 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1705 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1706 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1709 add_function("smoothstep",
1710 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1711 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1712 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1713 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1715 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1716 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1717 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1718 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1719 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1720 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1721 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1723 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1724 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1725 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1733 add_function("intBitsToFloat",
1734 _intBitsToFloat(glsl_type::int_type
),
1735 _intBitsToFloat(glsl_type::ivec2_type
),
1736 _intBitsToFloat(glsl_type::ivec3_type
),
1737 _intBitsToFloat(glsl_type::ivec4_type
),
1739 add_function("uintBitsToFloat",
1740 _uintBitsToFloat(glsl_type::uint_type
),
1741 _uintBitsToFloat(glsl_type::uvec2_type
),
1742 _uintBitsToFloat(glsl_type::uvec3_type
),
1743 _uintBitsToFloat(glsl_type::uvec4_type
),
1746 add_function("doubleBitsToInt64",
1747 _doubleBitsToInt64(int64_fp64
, glsl_type::double_type
),
1748 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec2_type
),
1749 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec3_type
),
1750 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec4_type
),
1753 add_function("doubleBitsToUint64",
1754 _doubleBitsToUint64(int64_fp64
, glsl_type::double_type
),
1755 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec2_type
),
1756 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec3_type
),
1757 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec4_type
),
1760 add_function("int64BitsToDouble",
1761 _int64BitsToDouble(int64_fp64
, glsl_type::int64_t_type
),
1762 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec2_type
),
1763 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec3_type
),
1764 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec4_type
),
1767 add_function("uint64BitsToDouble",
1768 _uint64BitsToDouble(int64_fp64
, glsl_type::uint64_t_type
),
1769 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec2_type
),
1770 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec3_type
),
1771 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec4_type
),
1774 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1775 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1776 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1777 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1778 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1779 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1780 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1781 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1782 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1783 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1784 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1785 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1787 add_function("packInt2x32", _packInt2x32(int64
), NULL
);
1788 add_function("unpackInt2x32", _unpackInt2x32(int64
), NULL
);
1789 add_function("packUint2x32", _packUint2x32(int64
), NULL
);
1790 add_function("unpackUint2x32", _unpackUint2x32(int64
), NULL
);
1796 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1797 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1800 add_function("ftransform", _ftransform(), NULL
);
1805 add_function("matrixCompMult",
1806 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1807 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1808 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1809 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1810 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1811 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1812 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1813 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1814 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1815 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1816 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1817 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1818 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1819 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1820 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1821 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1822 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1823 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1825 add_function("outerProduct",
1826 _outerProduct(v120
, glsl_type::mat2_type
),
1827 _outerProduct(v120
, glsl_type::mat3_type
),
1828 _outerProduct(v120
, glsl_type::mat4_type
),
1829 _outerProduct(v120
, glsl_type::mat2x3_type
),
1830 _outerProduct(v120
, glsl_type::mat2x4_type
),
1831 _outerProduct(v120
, glsl_type::mat3x2_type
),
1832 _outerProduct(v120
, glsl_type::mat3x4_type
),
1833 _outerProduct(v120
, glsl_type::mat4x2_type
),
1834 _outerProduct(v120
, glsl_type::mat4x3_type
),
1835 _outerProduct(fp64
, glsl_type::dmat2_type
),
1836 _outerProduct(fp64
, glsl_type::dmat3_type
),
1837 _outerProduct(fp64
, glsl_type::dmat4_type
),
1838 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1839 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1840 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1841 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1842 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1843 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1845 add_function("determinant",
1846 _determinant_mat2(v120
, glsl_type::mat2_type
),
1847 _determinant_mat3(v120
, glsl_type::mat3_type
),
1848 _determinant_mat4(v120
, glsl_type::mat4_type
),
1849 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1850 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1851 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1854 add_function("inverse",
1855 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1856 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1857 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1858 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1859 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1860 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1862 add_function("transpose",
1863 _transpose(v120
, glsl_type::mat2_type
),
1864 _transpose(v120
, glsl_type::mat3_type
),
1865 _transpose(v120
, glsl_type::mat4_type
),
1866 _transpose(v120
, glsl_type::mat2x3_type
),
1867 _transpose(v120
, glsl_type::mat2x4_type
),
1868 _transpose(v120
, glsl_type::mat3x2_type
),
1869 _transpose(v120
, glsl_type::mat3x4_type
),
1870 _transpose(v120
, glsl_type::mat4x2_type
),
1871 _transpose(v120
, glsl_type::mat4x3_type
),
1872 _transpose(fp64
, glsl_type::dmat2_type
),
1873 _transpose(fp64
, glsl_type::dmat3_type
),
1874 _transpose(fp64
, glsl_type::dmat4_type
),
1875 _transpose(fp64
, glsl_type::dmat2x3_type
),
1876 _transpose(fp64
, glsl_type::dmat2x4_type
),
1877 _transpose(fp64
, glsl_type::dmat3x2_type
),
1878 _transpose(fp64
, glsl_type::dmat3x4_type
),
1879 _transpose(fp64
, glsl_type::dmat4x2_type
),
1880 _transpose(fp64
, glsl_type::dmat4x3_type
),
1883 FIUD_VEC(lessThanEqual
)
1884 FIUD_VEC(greaterThan
)
1885 FIUD_VEC(greaterThanEqual
)
1890 _any(glsl_type::bvec2_type
),
1891 _any(glsl_type::bvec3_type
),
1892 _any(glsl_type::bvec4_type
),
1896 _all(glsl_type::bvec2_type
),
1897 _all(glsl_type::bvec3_type
),
1898 _all(glsl_type::bvec4_type
),
1902 _not(glsl_type::bvec2_type
),
1903 _not(glsl_type::bvec3_type
),
1904 _not(glsl_type::bvec4_type
),
1907 add_function("textureSize",
1908 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1909 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1910 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1912 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1913 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1914 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1916 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1917 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1918 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1920 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1921 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1922 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1924 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1925 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1926 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1928 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1929 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1930 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1931 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1932 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1933 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1935 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1936 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1938 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1939 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1940 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1941 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1943 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1944 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1945 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1946 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1948 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1949 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1950 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1951 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1952 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1953 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1955 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1956 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1957 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1960 add_function("textureSamples",
1961 _textureSamples(shader_samples
, glsl_type::sampler2DMS_type
),
1962 _textureSamples(shader_samples
, glsl_type::isampler2DMS_type
),
1963 _textureSamples(shader_samples
, glsl_type::usampler2DMS_type
),
1965 _textureSamples(shader_samples
, glsl_type::sampler2DMSArray_type
),
1966 _textureSamples(shader_samples
, glsl_type::isampler2DMSArray_type
),
1967 _textureSamples(shader_samples
, glsl_type::usampler2DMSArray_type
),
1970 add_function("texture",
1971 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1972 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1973 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1975 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1976 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1977 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1979 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1980 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1981 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1983 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1984 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1985 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1987 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1988 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1989 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1991 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1992 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1993 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1995 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1996 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1997 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1999 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2000 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2001 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2003 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2004 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2005 /* samplerCubeArrayShadow is special; it has an extra parameter
2006 * for the shadow comparator since there is no vec5 type.
2008 _textureCubeArrayShadow(texture_cube_map_array
, glsl_type::samplerCubeArrayShadow_type
),
2010 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2011 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2012 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2014 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2016 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2018 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2019 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2020 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2022 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2023 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2024 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2026 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2027 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2028 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2030 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2031 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2032 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2034 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2035 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2036 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2038 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2039 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2040 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2042 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2043 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2044 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2046 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2047 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2048 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2050 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2053 add_function("textureLod",
2054 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2055 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2056 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2058 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2059 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2060 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2062 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2063 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2064 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2066 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2067 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2068 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2070 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2071 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2073 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2074 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2075 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2077 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2078 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2079 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2081 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2082 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2083 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2085 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2088 add_function("textureOffset",
2089 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2090 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2091 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2093 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2094 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2095 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2097 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2098 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2099 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2101 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2102 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2103 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2105 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2107 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2108 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2110 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2111 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2112 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2114 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2115 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2116 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2118 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2119 /* The next one was forgotten in GLSL 1.30 spec. It's from
2120 * EXT_gpu_shader4 originally. It was added in 4.30 with the
2121 * wrong syntax. This was corrected in 4.40. 4.30 indicates
2122 * that it was intended to be included previously, so allow it
2125 _texture(ir_tex
, v130_desktop
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2127 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2128 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2129 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2131 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2132 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2133 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2135 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2136 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2137 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2139 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2140 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2142 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2143 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2144 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2146 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2147 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2148 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2150 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2153 add_function("textureProj",
2154 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2155 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2156 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2157 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2158 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2159 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2161 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2162 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2163 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2164 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2165 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2166 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2168 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2169 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2170 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2172 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2173 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2175 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2176 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2177 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2178 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2180 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2181 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2182 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2183 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2185 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2187 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2188 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2189 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2190 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2191 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2192 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2194 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2195 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2196 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2197 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2198 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2199 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2201 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2202 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2203 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2205 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2206 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2209 add_function("texelFetch",
2210 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
2211 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
2212 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
2214 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
2215 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
2216 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
2218 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
2219 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
2220 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
2222 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
2223 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
2224 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
2226 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
2227 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
2228 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
2230 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
2231 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
2232 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
2234 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
2235 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
2236 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
2238 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2239 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2240 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2242 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2243 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2244 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2246 _texelFetch(texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::ivec2_type
),
2251 add_function("texelFetchOffset",
2252 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2253 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2254 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2256 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2257 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2258 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2260 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2261 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2262 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2264 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2265 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2266 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2268 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2269 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2270 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2272 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2273 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2274 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2278 add_function("textureProjOffset",
2279 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2280 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2281 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2282 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2283 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2284 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2286 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2287 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2288 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2289 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2290 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2291 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2293 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2294 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2295 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2297 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2298 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2300 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2301 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2302 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2303 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2304 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2305 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2307 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2309 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2310 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2311 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2312 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2313 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2314 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2316 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2317 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2318 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2319 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2320 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2321 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2323 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2324 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2325 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2327 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2328 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2331 add_function("textureLodOffset",
2332 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2333 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2334 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2336 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2337 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2338 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2340 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2341 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2342 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2344 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2345 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2347 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2348 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2349 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2351 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2352 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2353 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2355 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2358 add_function("textureProjLod",
2359 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2360 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2361 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2362 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2363 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2364 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2366 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2367 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2368 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2369 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2370 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2371 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2373 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2374 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2375 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2377 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2378 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2381 add_function("textureProjLodOffset",
2382 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2383 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2384 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2385 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2386 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2387 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2389 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2390 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2391 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2392 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2393 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2394 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2396 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2397 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2398 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2400 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2401 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2404 add_function("textureGrad",
2405 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2406 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2407 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2409 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2410 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2411 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2413 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2414 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2415 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2417 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2418 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2419 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2421 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2422 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2423 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2425 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2427 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2428 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2429 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2431 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2432 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2433 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2435 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2436 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2437 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2439 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2440 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2441 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2443 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2444 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2447 add_function("textureGradOffset",
2448 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2449 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2450 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2452 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2453 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2454 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2456 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2457 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2458 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2460 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2461 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2462 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2464 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2466 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2467 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2469 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2470 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2471 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2473 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2474 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2475 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2477 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2478 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2481 add_function("textureProjGrad",
2482 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2483 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2484 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2485 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2486 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2487 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2489 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2490 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2491 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2492 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2493 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2494 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2496 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2497 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2498 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2500 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2501 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2502 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2503 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2504 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2505 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2507 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2509 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2510 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2513 add_function("textureProjGradOffset",
2514 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2515 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2516 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2517 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2518 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2519 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2521 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2522 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2523 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2524 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2525 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2526 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2528 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2529 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2530 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2532 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2533 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2534 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2535 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2536 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2537 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2539 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2541 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2542 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2545 add_function("EmitVertex", _EmitVertex(), NULL
);
2546 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2547 add_function("EmitStreamVertex",
2548 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2549 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2551 add_function("EndStreamPrimitive",
2552 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2553 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2555 add_function("barrier", _barrier(), NULL
);
2557 add_function("textureQueryLOD",
2558 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2559 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2560 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2562 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2563 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2564 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2566 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2567 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2568 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2570 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2571 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2572 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2574 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2575 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2576 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2578 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2579 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2580 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2582 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2583 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2584 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2586 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2587 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2588 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2589 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2590 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2591 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2594 add_function("textureQueryLod",
2595 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2596 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2597 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2599 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2600 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2601 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2603 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2604 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2605 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2607 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2608 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2609 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2611 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2612 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2613 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2615 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2616 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2617 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2619 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2620 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2621 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2623 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2624 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2625 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2626 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2627 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2628 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2631 add_function("textureQueryLevels",
2632 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1D_type
),
2633 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2D_type
),
2634 _textureQueryLevels(texture_query_levels
, glsl_type::sampler3D_type
),
2635 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCube_type
),
2636 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArray_type
),
2637 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArray_type
),
2638 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArray_type
),
2639 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DShadow_type
),
2640 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DShadow_type
),
2641 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeShadow_type
),
2642 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArrayShadow_type
),
2643 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArrayShadow_type
),
2644 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArrayShadow_type
),
2646 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1D_type
),
2647 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2D_type
),
2648 _textureQueryLevels(texture_query_levels
, glsl_type::isampler3D_type
),
2649 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCube_type
),
2650 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1DArray_type
),
2651 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2DArray_type
),
2652 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCubeArray_type
),
2654 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1D_type
),
2655 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2D_type
),
2656 _textureQueryLevels(texture_query_levels
, glsl_type::usampler3D_type
),
2657 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCube_type
),
2658 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1DArray_type
),
2659 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2DArray_type
),
2660 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCubeArray_type
),
2664 add_function("textureSamplesIdenticalEXT",
2665 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2666 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2667 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2669 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2670 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2671 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2674 add_function("texture1D",
2675 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2676 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2679 add_function("texture1DArray",
2680 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2681 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2684 add_function("texture1DProj",
2685 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2686 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2687 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2688 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2691 add_function("texture1DLod",
2692 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2695 add_function("texture1DArrayLod",
2696 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2699 add_function("texture1DProjLod",
2700 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2701 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2704 add_function("texture2D",
2705 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2706 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2707 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2710 add_function("texture2DArray",
2711 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2712 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2715 add_function("texture2DProj",
2716 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2717 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2718 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2719 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2720 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2721 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2724 add_function("texture2DLod",
2725 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2728 add_function("texture2DArrayLod",
2729 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2732 add_function("texture2DProjLod",
2733 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2734 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2737 add_function("texture3D",
2738 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2739 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2742 add_function("texture3DProj",
2743 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2744 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2747 add_function("texture3DLod",
2748 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2751 add_function("texture3DProjLod",
2752 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2755 add_function("textureCube",
2756 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2757 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2760 add_function("textureCubeLod",
2761 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2764 add_function("texture2DRect",
2765 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2768 add_function("texture2DRectProj",
2769 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2770 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2773 add_function("shadow1D",
2774 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2775 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2778 add_function("shadow1DArray",
2779 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2780 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2783 add_function("shadow2D",
2784 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2785 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2788 add_function("shadow2DArray",
2789 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2790 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2793 add_function("shadow1DProj",
2794 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2795 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2798 add_function("shadow2DProj",
2799 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2800 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2803 add_function("shadow1DLod",
2804 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2807 add_function("shadow2DLod",
2808 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2811 add_function("shadow1DArrayLod",
2812 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2815 add_function("shadow1DProjLod",
2816 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2819 add_function("shadow2DProjLod",
2820 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2823 add_function("shadow2DRect",
2824 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2827 add_function("shadow2DRectProj",
2828 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2831 add_function("texture1DGradARB",
2832 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2835 add_function("texture1DProjGradARB",
2836 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2837 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2840 add_function("texture2DGradARB",
2841 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2844 add_function("texture2DProjGradARB",
2845 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2846 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2849 add_function("texture3DGradARB",
2850 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2853 add_function("texture3DProjGradARB",
2854 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2857 add_function("textureCubeGradARB",
2858 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2861 add_function("shadow1DGradARB",
2862 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2865 add_function("shadow1DProjGradARB",
2866 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2869 add_function("shadow2DGradARB",
2870 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2873 add_function("shadow2DProjGradARB",
2874 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2877 add_function("texture2DRectGradARB",
2878 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2881 add_function("texture2DRectProjGradARB",
2882 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2883 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2886 add_function("shadow2DRectGradARB",
2887 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2890 add_function("shadow2DRectProjGradARB",
2891 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2894 add_function("textureGather",
2895 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2896 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2897 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2899 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2900 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2901 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2903 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2904 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2905 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2907 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2908 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2909 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2911 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2912 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2913 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2915 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2916 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2917 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2919 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2920 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2921 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2923 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2924 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2925 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2927 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2928 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2929 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2931 _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
),
2932 _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
),
2933 _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
),
2935 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2936 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2937 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2938 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2939 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2942 add_function("textureGatherOffset",
2943 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2944 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2945 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2947 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2948 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2949 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2951 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2952 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2953 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2955 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2956 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2957 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2959 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2960 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2961 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2963 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2964 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2965 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2967 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2968 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2969 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2971 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2972 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2973 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2975 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2976 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2977 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2979 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2980 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2981 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2983 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2984 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2985 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2987 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2988 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2991 add_function("textureGatherOffsets",
2992 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2993 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2994 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2996 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2997 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2998 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3000 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3001 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3002 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3004 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3005 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3006 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3008 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3009 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3010 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3012 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3013 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3014 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
3016 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3017 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
3018 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
3043 add_function("ldexp",
3044 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
3045 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
3046 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
3047 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
3048 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
3049 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
3050 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
3051 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
3054 add_function("frexp",
3055 _frexp(glsl_type::float_type
, glsl_type::int_type
),
3056 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
3057 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
3058 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
3059 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
3060 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
3061 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
3062 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
3064 add_function("uaddCarry",
3065 _uaddCarry(glsl_type::uint_type
),
3066 _uaddCarry(glsl_type::uvec2_type
),
3067 _uaddCarry(glsl_type::uvec3_type
),
3068 _uaddCarry(glsl_type::uvec4_type
),
3070 add_function("usubBorrow",
3071 _usubBorrow(glsl_type::uint_type
),
3072 _usubBorrow(glsl_type::uvec2_type
),
3073 _usubBorrow(glsl_type::uvec3_type
),
3074 _usubBorrow(glsl_type::uvec4_type
),
3076 add_function("imulExtended",
3077 _mulExtended(glsl_type::int_type
),
3078 _mulExtended(glsl_type::ivec2_type
),
3079 _mulExtended(glsl_type::ivec3_type
),
3080 _mulExtended(glsl_type::ivec4_type
),
3082 add_function("umulExtended",
3083 _mulExtended(glsl_type::uint_type
),
3084 _mulExtended(glsl_type::uvec2_type
),
3085 _mulExtended(glsl_type::uvec3_type
),
3086 _mulExtended(glsl_type::uvec4_type
),
3088 add_function("interpolateAtCentroid",
3089 _interpolateAtCentroid(glsl_type::float_type
),
3090 _interpolateAtCentroid(glsl_type::vec2_type
),
3091 _interpolateAtCentroid(glsl_type::vec3_type
),
3092 _interpolateAtCentroid(glsl_type::vec4_type
),
3094 add_function("interpolateAtOffset",
3095 _interpolateAtOffset(glsl_type::float_type
),
3096 _interpolateAtOffset(glsl_type::vec2_type
),
3097 _interpolateAtOffset(glsl_type::vec3_type
),
3098 _interpolateAtOffset(glsl_type::vec4_type
),
3100 add_function("interpolateAtSample",
3101 _interpolateAtSample(glsl_type::float_type
),
3102 _interpolateAtSample(glsl_type::vec2_type
),
3103 _interpolateAtSample(glsl_type::vec3_type
),
3104 _interpolateAtSample(glsl_type::vec4_type
),
3107 add_function("atomicCounter",
3108 _atomic_counter_op("__intrinsic_atomic_read",
3109 shader_atomic_counters
),
3111 add_function("atomicCounterIncrement",
3112 _atomic_counter_op("__intrinsic_atomic_increment",
3113 shader_atomic_counters
),
3115 add_function("atomicCounterDecrement",
3116 _atomic_counter_op("__intrinsic_atomic_predecrement",
3117 shader_atomic_counters
),
3120 add_function("atomicCounterAddARB",
3121 _atomic_counter_op1("__intrinsic_atomic_add",
3122 shader_atomic_counter_ops
),
3124 add_function("atomicCounterSubtractARB",
3125 _atomic_counter_op1("__intrinsic_atomic_sub",
3126 shader_atomic_counter_ops
),
3128 add_function("atomicCounterMinARB",
3129 _atomic_counter_op1("__intrinsic_atomic_min",
3130 shader_atomic_counter_ops
),
3132 add_function("atomicCounterMaxARB",
3133 _atomic_counter_op1("__intrinsic_atomic_max",
3134 shader_atomic_counter_ops
),
3136 add_function("atomicCounterAndARB",
3137 _atomic_counter_op1("__intrinsic_atomic_and",
3138 shader_atomic_counter_ops
),
3140 add_function("atomicCounterOrARB",
3141 _atomic_counter_op1("__intrinsic_atomic_or",
3142 shader_atomic_counter_ops
),
3144 add_function("atomicCounterXorARB",
3145 _atomic_counter_op1("__intrinsic_atomic_xor",
3146 shader_atomic_counter_ops
),
3148 add_function("atomicCounterExchangeARB",
3149 _atomic_counter_op1("__intrinsic_atomic_exchange",
3150 shader_atomic_counter_ops
),
3152 add_function("atomicCounterCompSwapARB",
3153 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3154 shader_atomic_counter_ops
),
3157 add_function("atomicCounterAdd",
3158 _atomic_counter_op1("__intrinsic_atomic_add",
3161 add_function("atomicCounterSubtract",
3162 _atomic_counter_op1("__intrinsic_atomic_sub",
3165 add_function("atomicCounterMin",
3166 _atomic_counter_op1("__intrinsic_atomic_min",
3169 add_function("atomicCounterMax",
3170 _atomic_counter_op1("__intrinsic_atomic_max",
3173 add_function("atomicCounterAnd",
3174 _atomic_counter_op1("__intrinsic_atomic_and",
3177 add_function("atomicCounterOr",
3178 _atomic_counter_op1("__intrinsic_atomic_or",
3181 add_function("atomicCounterXor",
3182 _atomic_counter_op1("__intrinsic_atomic_xor",
3185 add_function("atomicCounterExchange",
3186 _atomic_counter_op1("__intrinsic_atomic_exchange",
3189 add_function("atomicCounterCompSwap",
3190 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3194 add_function("atomicAdd",
3195 _atomic_op2("__intrinsic_atomic_add",
3196 buffer_atomics_supported
,
3197 glsl_type::uint_type
),
3198 _atomic_op2("__intrinsic_atomic_add",
3199 buffer_atomics_supported
,
3200 glsl_type::int_type
),
3201 _atomic_op2("__intrinsic_atomic_add",
3202 shader_atomic_float_add
,
3203 glsl_type::float_type
),
3205 add_function("atomicMin",
3206 _atomic_op2("__intrinsic_atomic_min",
3207 buffer_atomics_supported
,
3208 glsl_type::uint_type
),
3209 _atomic_op2("__intrinsic_atomic_min",
3210 buffer_atomics_supported
,
3211 glsl_type::int_type
),
3212 _atomic_op2("__intrinsic_atomic_min",
3213 shader_atomic_float_minmax
,
3214 glsl_type::float_type
),
3216 add_function("atomicMax",
3217 _atomic_op2("__intrinsic_atomic_max",
3218 buffer_atomics_supported
,
3219 glsl_type::uint_type
),
3220 _atomic_op2("__intrinsic_atomic_max",
3221 buffer_atomics_supported
,
3222 glsl_type::int_type
),
3223 _atomic_op2("__intrinsic_atomic_max",
3224 shader_atomic_float_minmax
,
3225 glsl_type::float_type
),
3227 add_function("atomicAnd",
3228 _atomic_op2("__intrinsic_atomic_and",
3229 buffer_atomics_supported
,
3230 glsl_type::uint_type
),
3231 _atomic_op2("__intrinsic_atomic_and",
3232 buffer_atomics_supported
,
3233 glsl_type::int_type
),
3235 add_function("atomicOr",
3236 _atomic_op2("__intrinsic_atomic_or",
3237 buffer_atomics_supported
,
3238 glsl_type::uint_type
),
3239 _atomic_op2("__intrinsic_atomic_or",
3240 buffer_atomics_supported
,
3241 glsl_type::int_type
),
3243 add_function("atomicXor",
3244 _atomic_op2("__intrinsic_atomic_xor",
3245 buffer_atomics_supported
,
3246 glsl_type::uint_type
),
3247 _atomic_op2("__intrinsic_atomic_xor",
3248 buffer_atomics_supported
,
3249 glsl_type::int_type
),
3251 add_function("atomicExchange",
3252 _atomic_op2("__intrinsic_atomic_exchange",
3253 buffer_atomics_supported
,
3254 glsl_type::uint_type
),
3255 _atomic_op2("__intrinsic_atomic_exchange",
3256 buffer_atomics_supported
,
3257 glsl_type::int_type
),
3258 _atomic_op2("__intrinsic_atomic_exchange",
3259 shader_atomic_float_exchange
,
3260 glsl_type::float_type
),
3262 add_function("atomicCompSwap",
3263 _atomic_op3("__intrinsic_atomic_comp_swap",
3264 buffer_atomics_supported
,
3265 glsl_type::uint_type
),
3266 _atomic_op3("__intrinsic_atomic_comp_swap",
3267 buffer_atomics_supported
,
3268 glsl_type::int_type
),
3269 _atomic_op3("__intrinsic_atomic_comp_swap",
3270 shader_atomic_float_minmax
,
3271 glsl_type::float_type
),
3274 add_function("min3",
3275 _min3(glsl_type::float_type
),
3276 _min3(glsl_type::vec2_type
),
3277 _min3(glsl_type::vec3_type
),
3278 _min3(glsl_type::vec4_type
),
3280 _min3(glsl_type::int_type
),
3281 _min3(glsl_type::ivec2_type
),
3282 _min3(glsl_type::ivec3_type
),
3283 _min3(glsl_type::ivec4_type
),
3285 _min3(glsl_type::uint_type
),
3286 _min3(glsl_type::uvec2_type
),
3287 _min3(glsl_type::uvec3_type
),
3288 _min3(glsl_type::uvec4_type
),
3291 add_function("max3",
3292 _max3(glsl_type::float_type
),
3293 _max3(glsl_type::vec2_type
),
3294 _max3(glsl_type::vec3_type
),
3295 _max3(glsl_type::vec4_type
),
3297 _max3(glsl_type::int_type
),
3298 _max3(glsl_type::ivec2_type
),
3299 _max3(glsl_type::ivec3_type
),
3300 _max3(glsl_type::ivec4_type
),
3302 _max3(glsl_type::uint_type
),
3303 _max3(glsl_type::uvec2_type
),
3304 _max3(glsl_type::uvec3_type
),
3305 _max3(glsl_type::uvec4_type
),
3308 add_function("mid3",
3309 _mid3(glsl_type::float_type
),
3310 _mid3(glsl_type::vec2_type
),
3311 _mid3(glsl_type::vec3_type
),
3312 _mid3(glsl_type::vec4_type
),
3314 _mid3(glsl_type::int_type
),
3315 _mid3(glsl_type::ivec2_type
),
3316 _mid3(glsl_type::ivec3_type
),
3317 _mid3(glsl_type::ivec4_type
),
3319 _mid3(glsl_type::uint_type
),
3320 _mid3(glsl_type::uvec2_type
),
3321 _mid3(glsl_type::uvec3_type
),
3322 _mid3(glsl_type::uvec4_type
),
3325 add_image_functions(true);
3327 add_function("memoryBarrier",
3328 _memory_barrier("__intrinsic_memory_barrier",
3329 shader_image_load_store
),
3331 add_function("groupMemoryBarrier",
3332 _memory_barrier("__intrinsic_group_memory_barrier",
3335 add_function("memoryBarrierAtomicCounter",
3336 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
3337 compute_shader_supported
),
3339 add_function("memoryBarrierBuffer",
3340 _memory_barrier("__intrinsic_memory_barrier_buffer",
3341 compute_shader_supported
),
3343 add_function("memoryBarrierImage",
3344 _memory_barrier("__intrinsic_memory_barrier_image",
3345 compute_shader_supported
),
3347 add_function("memoryBarrierShared",
3348 _memory_barrier("__intrinsic_memory_barrier_shared",
3352 add_function("ballotARB", _ballot(), NULL
);
3354 add_function("readInvocationARB",
3355 _read_invocation(glsl_type::float_type
),
3356 _read_invocation(glsl_type::vec2_type
),
3357 _read_invocation(glsl_type::vec3_type
),
3358 _read_invocation(glsl_type::vec4_type
),
3360 _read_invocation(glsl_type::int_type
),
3361 _read_invocation(glsl_type::ivec2_type
),
3362 _read_invocation(glsl_type::ivec3_type
),
3363 _read_invocation(glsl_type::ivec4_type
),
3365 _read_invocation(glsl_type::uint_type
),
3366 _read_invocation(glsl_type::uvec2_type
),
3367 _read_invocation(glsl_type::uvec3_type
),
3368 _read_invocation(glsl_type::uvec4_type
),
3371 add_function("readFirstInvocationARB",
3372 _read_first_invocation(glsl_type::float_type
),
3373 _read_first_invocation(glsl_type::vec2_type
),
3374 _read_first_invocation(glsl_type::vec3_type
),
3375 _read_first_invocation(glsl_type::vec4_type
),
3377 _read_first_invocation(glsl_type::int_type
),
3378 _read_first_invocation(glsl_type::ivec2_type
),
3379 _read_first_invocation(glsl_type::ivec3_type
),
3380 _read_first_invocation(glsl_type::ivec4_type
),
3382 _read_first_invocation(glsl_type::uint_type
),
3383 _read_first_invocation(glsl_type::uvec2_type
),
3384 _read_first_invocation(glsl_type::uvec3_type
),
3385 _read_first_invocation(glsl_type::uvec4_type
),
3388 add_function("clock2x32ARB",
3389 _shader_clock(shader_clock
,
3390 glsl_type::uvec2_type
),
3393 add_function("clockARB",
3394 _shader_clock(shader_clock_int64
,
3395 glsl_type::uint64_t_type
),
3398 add_function("beginInvocationInterlockARB",
3399 _invocation_interlock(
3400 "__intrinsic_begin_invocation_interlock",
3401 supports_arb_fragment_shader_interlock
),
3404 add_function("endInvocationInterlockARB",
3405 _invocation_interlock(
3406 "__intrinsic_end_invocation_interlock",
3407 supports_arb_fragment_shader_interlock
),
3410 add_function("beginInvocationInterlockNV",
3411 _invocation_interlock(
3412 "__intrinsic_begin_invocation_interlock",
3413 supports_nv_fragment_shader_interlock
),
3416 add_function("endInvocationInterlockNV",
3417 _invocation_interlock(
3418 "__intrinsic_end_invocation_interlock",
3419 supports_nv_fragment_shader_interlock
),
3422 add_function("anyInvocationARB",
3423 _vote("__intrinsic_vote_any", vote
),
3426 add_function("allInvocationsARB",
3427 _vote("__intrinsic_vote_all", vote
),
3430 add_function("allInvocationsEqualARB",
3431 _vote("__intrinsic_vote_eq", vote
),
3434 add_function("anyInvocation",
3435 _vote("__intrinsic_vote_any", v460_desktop
),
3438 add_function("allInvocations",
3439 _vote("__intrinsic_vote_all", v460_desktop
),
3442 add_function("allInvocationsEqual",
3443 _vote("__intrinsic_vote_eq", v460_desktop
),
3446 add_function("__builtin_idiv64",
3447 generate_ir::idiv64(mem_ctx
, integer_functions_supported
),
3450 add_function("__builtin_imod64",
3451 generate_ir::imod64(mem_ctx
, integer_functions_supported
),
3454 add_function("__builtin_sign64",
3455 generate_ir::sign64(mem_ctx
, integer_functions_supported
),
3458 add_function("__builtin_udiv64",
3459 generate_ir::udiv64(mem_ctx
, integer_functions_supported
),
3462 add_function("__builtin_umod64",
3463 generate_ir::umod64(mem_ctx
, integer_functions_supported
),
3466 add_function("__builtin_umul64",
3467 generate_ir::umul64(mem_ctx
, integer_functions_supported
),
3478 builtin_builder::add_function(const char *name
, ...)
3482 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3486 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
3492 stuff
.push_tail(sig
);
3493 validate_ir_tree(&stuff
);
3496 f
->add_signature(sig
);
3500 shader
->symbols
->add_function(f
);
3504 builtin_builder::add_image_function(const char *name
,
3505 const char *intrinsic_name
,
3506 image_prototype_ctr prototype
,
3507 unsigned num_arguments
,
3509 enum ir_intrinsic_id intrinsic_id
)
3511 static const glsl_type
*const types
[] = {
3512 glsl_type::image1D_type
,
3513 glsl_type::image2D_type
,
3514 glsl_type::image3D_type
,
3515 glsl_type::image2DRect_type
,
3516 glsl_type::imageCube_type
,
3517 glsl_type::imageBuffer_type
,
3518 glsl_type::image1DArray_type
,
3519 glsl_type::image2DArray_type
,
3520 glsl_type::imageCubeArray_type
,
3521 glsl_type::image2DMS_type
,
3522 glsl_type::image2DMSArray_type
,
3523 glsl_type::iimage1D_type
,
3524 glsl_type::iimage2D_type
,
3525 glsl_type::iimage3D_type
,
3526 glsl_type::iimage2DRect_type
,
3527 glsl_type::iimageCube_type
,
3528 glsl_type::iimageBuffer_type
,
3529 glsl_type::iimage1DArray_type
,
3530 glsl_type::iimage2DArray_type
,
3531 glsl_type::iimageCubeArray_type
,
3532 glsl_type::iimage2DMS_type
,
3533 glsl_type::iimage2DMSArray_type
,
3534 glsl_type::uimage1D_type
,
3535 glsl_type::uimage2D_type
,
3536 glsl_type::uimage3D_type
,
3537 glsl_type::uimage2DRect_type
,
3538 glsl_type::uimageCube_type
,
3539 glsl_type::uimageBuffer_type
,
3540 glsl_type::uimage1DArray_type
,
3541 glsl_type::uimage2DArray_type
,
3542 glsl_type::uimageCubeArray_type
,
3543 glsl_type::uimage2DMS_type
,
3544 glsl_type::uimage2DMSArray_type
3547 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3549 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3550 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3551 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3552 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3553 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3554 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3555 num_arguments
, flags
, intrinsic_id
));
3558 shader
->symbols
->add_function(f
);
3562 builtin_builder::add_image_functions(bool glsl
)
3564 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3566 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3567 "__intrinsic_image_load",
3568 &builtin_builder::_image_prototype
, 0,
3569 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3570 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3571 IMAGE_FUNCTION_READ_ONLY
),
3572 ir_intrinsic_image_load
);
3574 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3575 "__intrinsic_image_store",
3576 &builtin_builder::_image_prototype
, 1,
3577 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3578 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3579 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3580 IMAGE_FUNCTION_WRITE_ONLY
),
3581 ir_intrinsic_image_store
);
3583 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3585 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3586 "__intrinsic_image_atomic_add",
3587 &builtin_builder::_image_prototype
, 1,
3588 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
|
3589 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3590 ir_intrinsic_image_atomic_add
);
3592 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3593 "__intrinsic_image_atomic_min",
3594 &builtin_builder::_image_prototype
, 1, atom_flags
,
3595 ir_intrinsic_image_atomic_min
);
3597 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3598 "__intrinsic_image_atomic_max",
3599 &builtin_builder::_image_prototype
, 1, atom_flags
,
3600 ir_intrinsic_image_atomic_max
);
3602 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3603 "__intrinsic_image_atomic_and",
3604 &builtin_builder::_image_prototype
, 1, atom_flags
,
3605 ir_intrinsic_image_atomic_and
);
3607 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3608 "__intrinsic_image_atomic_or",
3609 &builtin_builder::_image_prototype
, 1, atom_flags
,
3610 ir_intrinsic_image_atomic_or
);
3612 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3613 "__intrinsic_image_atomic_xor",
3614 &builtin_builder::_image_prototype
, 1, atom_flags
,
3615 ir_intrinsic_image_atomic_xor
);
3617 add_image_function((glsl
? "imageAtomicExchange" :
3618 "__intrinsic_image_atomic_exchange"),
3619 "__intrinsic_image_atomic_exchange",
3620 &builtin_builder::_image_prototype
, 1,
3621 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3622 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3623 ir_intrinsic_image_atomic_exchange
);
3625 add_image_function((glsl
? "imageAtomicCompSwap" :
3626 "__intrinsic_image_atomic_comp_swap"),
3627 "__intrinsic_image_atomic_comp_swap",
3628 &builtin_builder::_image_prototype
, 2, atom_flags
,
3629 ir_intrinsic_image_atomic_comp_swap
);
3631 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3632 "__intrinsic_image_size",
3633 &builtin_builder::_image_size_prototype
, 1,
3634 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
,
3635 ir_intrinsic_image_size
);
3637 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3638 "__intrinsic_image_samples",
3639 &builtin_builder::_image_samples_prototype
, 1,
3640 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3641 IMAGE_FUNCTION_MS_ONLY
,
3642 ir_intrinsic_image_samples
);
3646 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3648 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3652 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3654 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3658 builtin_builder::imm(bool b
, unsigned vector_elements
)
3660 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3664 builtin_builder::imm(float f
, unsigned vector_elements
)
3666 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3670 builtin_builder::imm(int i
, unsigned vector_elements
)
3672 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3676 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3678 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3682 builtin_builder::imm(double d
, unsigned vector_elements
)
3684 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3688 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3690 return new(mem_ctx
) ir_constant(type
, &data
);
3693 #define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)
3695 ir_dereference_variable
*
3696 builtin_builder::var_ref(ir_variable
*var
)
3698 return new(mem_ctx
) ir_dereference_variable(var
);
3701 ir_dereference_array
*
3702 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3704 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3707 /** Return an element of a matrix */
3709 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3711 return swizzle(array_ref(var
, column
), row
, 1);
3715 * Implementations of built-in functions:
3718 ir_function_signature
*
3719 builtin_builder::new_sig(const glsl_type
*return_type
,
3720 builtin_available_predicate avail
,
3726 ir_function_signature
*sig
=
3727 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3730 va_start(ap
, num_params
);
3731 for (int i
= 0; i
< num_params
; i
++) {
3732 plist
.push_tail(va_arg(ap
, ir_variable
*));
3736 sig
->replace_parameters(&plist
);
3740 #define MAKE_SIG(return_type, avail, ...) \
3741 ir_function_signature *sig = \
3742 new_sig(return_type, avail, __VA_ARGS__); \
3743 ir_factory body(&sig->body, mem_ctx); \
3744 sig->is_defined = true;
3746 #define MAKE_INTRINSIC(return_type, id, avail, ...) \
3747 ir_function_signature *sig = \
3748 new_sig(return_type, avail, __VA_ARGS__); \
3749 sig->intrinsic_id = id;
3751 ir_function_signature
*
3752 builtin_builder::unop(builtin_available_predicate avail
,
3753 ir_expression_operation opcode
,
3754 const glsl_type
*return_type
,
3755 const glsl_type
*param_type
)
3757 ir_variable
*x
= in_var(param_type
, "x");
3758 MAKE_SIG(return_type
, avail
, 1, x
);
3759 body
.emit(ret(expr(opcode
, x
)));
3763 #define UNOP(NAME, OPCODE, AVAIL) \
3764 ir_function_signature * \
3765 builtin_builder::_##NAME(const glsl_type *type) \
3767 return unop(&AVAIL, OPCODE, type, type); \
3770 #define UNOPA(NAME, OPCODE) \
3771 ir_function_signature * \
3772 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3774 return unop(avail, OPCODE, type, type); \
3777 ir_function_signature
*
3778 builtin_builder::binop(builtin_available_predicate avail
,
3779 ir_expression_operation opcode
,
3780 const glsl_type
*return_type
,
3781 const glsl_type
*param0_type
,
3782 const glsl_type
*param1_type
,
3785 ir_variable
*x
= in_var(param0_type
, "x");
3786 ir_variable
*y
= in_var(param1_type
, "y");
3787 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3790 body
.emit(ret(expr(opcode
, y
, x
)));
3792 body
.emit(ret(expr(opcode
, x
, y
)));
3797 #define BINOP(NAME, OPCODE, AVAIL) \
3798 ir_function_signature * \
3799 builtin_builder::_##NAME(const glsl_type *return_type, \
3800 const glsl_type *param0_type, \
3801 const glsl_type *param1_type) \
3803 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3807 * Angle and Trigonometry Functions @{
3810 ir_function_signature
*
3811 builtin_builder::_radians(const glsl_type
*type
)
3813 ir_variable
*degrees
= in_var(type
, "degrees");
3814 MAKE_SIG(type
, always_available
, 1, degrees
);
3815 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3819 ir_function_signature
*
3820 builtin_builder::_degrees(const glsl_type
*type
)
3822 ir_variable
*radians
= in_var(type
, "radians");
3823 MAKE_SIG(type
, always_available
, 1, radians
);
3824 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3828 UNOP(sin
, ir_unop_sin
, always_available
)
3829 UNOP(cos
, ir_unop_cos
, always_available
)
3831 ir_function_signature
*
3832 builtin_builder::_tan(const glsl_type
*type
)
3834 ir_variable
*theta
= in_var(type
, "theta");
3835 MAKE_SIG(type
, always_available
, 1, theta
);
3836 body
.emit(ret(div(sin(theta
), cos(theta
))));
3841 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3845 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3848 add(imm(M_PI_4f
- 1.0f
),
3851 mul(abs(x
), imm(p1
))))))))));
3855 * Generate a ir_call to a function with a set of parameters
3857 * The input \c params can either be a list of \c ir_variable or a list of
3858 * \c ir_dereference_variable. In the latter case, all nodes will be removed
3859 * from \c params and used directly as the parameters to the generated
3863 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3865 exec_list actual_params
;
3867 foreach_in_list_safe(ir_instruction
, ir
, ¶ms
) {
3868 ir_dereference_variable
*d
= ir
->as_dereference_variable();
3871 actual_params
.push_tail(d
);
3873 ir_variable
*var
= ir
->as_variable();
3874 assert(var
!= NULL
);
3875 actual_params
.push_tail(var_ref(var
));
3879 ir_function_signature
*sig
=
3880 f
->exact_matching_signature(NULL
, &actual_params
);
3884 ir_dereference_variable
*deref
=
3885 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3887 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3890 ir_function_signature
*
3891 builtin_builder::_asin(const glsl_type
*type
)
3893 ir_variable
*x
= in_var(type
, "x");
3894 MAKE_SIG(type
, always_available
, 1, x
);
3896 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3901 ir_function_signature
*
3902 builtin_builder::_acos(const glsl_type
*type
)
3904 ir_variable
*x
= in_var(type
, "x");
3905 MAKE_SIG(type
, always_available
, 1, x
);
3907 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3912 ir_function_signature
*
3913 builtin_builder::_atan2(const glsl_type
*type
)
3915 const unsigned n
= type
->vector_elements
;
3916 ir_variable
*y
= in_var(type
, "y");
3917 ir_variable
*x
= in_var(type
, "x");
3918 MAKE_SIG(type
, always_available
, 2, y
, x
);
3920 /* If we're on the left half-plane rotate the coordinates π/2 clock-wise
3921 * for the y=0 discontinuity to end up aligned with the vertical
3922 * discontinuity of atan(s/t) along t=0. This also makes sure that we
3923 * don't attempt to divide by zero along the vertical line, which may give
3924 * unspecified results on non-GLSL 4.1-capable hardware.
3926 ir_variable
*flip
= body
.make_temp(glsl_type::bvec(n
), "flip");
3927 body
.emit(assign(flip
, gequal(imm(0.0f
, n
), x
)));
3928 ir_variable
*s
= body
.make_temp(type
, "s");
3929 body
.emit(assign(s
, csel(flip
, abs(x
), y
)));
3930 ir_variable
*t
= body
.make_temp(type
, "t");
3931 body
.emit(assign(t
, csel(flip
, y
, abs(x
))));
3933 /* If the magnitude of the denominator exceeds some huge value, scale down
3934 * the arguments in order to prevent the reciprocal operation from flushing
3935 * its result to zero, which would cause precision problems, and for s
3936 * infinite would cause us to return a NaN instead of the correct finite
3939 * If fmin and fmax are respectively the smallest and largest positive
3940 * normalized floating point values representable by the implementation,
3941 * the constants below should be in agreement with:
3944 * scale <= 1 / fmin / fmax (for |t| >= huge)
3946 * In addition scale should be a negative power of two in order to avoid
3947 * loss of precision. The values chosen below should work for most usual
3948 * floating point representations with at least the dynamic range of ATI's
3949 * 24-bit representation.
3951 ir_constant
*huge
= imm(1e18f
, n
);
3952 ir_variable
*scale
= body
.make_temp(type
, "scale");
3953 body
.emit(assign(scale
, csel(gequal(abs(t
), huge
),
3954 imm(0.25f
, n
), imm(1.0f
, n
))));
3955 ir_variable
*rcp_scaled_t
= body
.make_temp(type
, "rcp_scaled_t");
3956 body
.emit(assign(rcp_scaled_t
, rcp(mul(t
, scale
))));
3957 ir_expression
*s_over_t
= mul(mul(s
, scale
), rcp_scaled_t
);
3959 /* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily
3960 * that ∞/∞ = 1) in order to comply with the rather artificial rules
3961 * inherited from IEEE 754-2008, namely:
3963 * "atan2(±∞, −∞) is ±3π/4
3964 * atan2(±∞, +∞) is ±π/4"
3966 * Note that this is inconsistent with the rules for the neighborhood of
3967 * zero that are based on iterated limits:
3969 * "atan2(±0, −0) is ±π
3970 * atan2(±0, +0) is ±0"
3972 * but GLSL specifically allows implementations to deviate from IEEE rules
3973 * at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as
3976 ir_expression
*tan
= csel(equal(abs(x
), abs(y
)),
3977 imm(1.0f
, n
), abs(s_over_t
));
3979 /* Calculate the arctangent and fix up the result if we had flipped the
3980 * coordinate system.
3982 ir_variable
*arc
= body
.make_temp(type
, "arc");
3983 do_atan(body
, type
, arc
, tan
);
3984 body
.emit(assign(arc
, add(arc
, mul(b2f(flip
), imm(M_PI_2f
)))));
3986 /* Rather convoluted calculation of the sign of the result. When x < 0 we
3987 * cannot use fsign because we need to be able to distinguish between
3988 * negative and positive zero. Unfortunately we cannot use bitwise
3989 * arithmetic tricks either because of back-ends without integer support.
3990 * When x >= 0 rcp_scaled_t will always be non-negative so this won't be
3991 * able to distinguish between negative and positive zero, but we don't
3992 * care because atan2 is continuous along the whole positive y = 0
3993 * half-line, so it won't affect the result significantly.
3995 body
.emit(ret(csel(less(min2(y
, rcp_scaled_t
), imm(0.0f
, n
)),
4002 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
4005 * range-reduction, first step:
4007 * / y_over_x if |y_over_x| <= 1.0;
4009 * \ 1.0 / y_over_x otherwise
4011 ir_variable
*x
= body
.make_temp(type
, "atan_x");
4012 body
.emit(assign(x
, div(min2(abs(y_over_x
),
4018 * approximate atan by evaluating polynomial:
4020 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
4021 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
4022 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
4024 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
4025 body
.emit(assign(tmp
, mul(x
, x
)));
4026 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
4028 imm(0.0536813784310406f
)),
4030 imm(0.1173503194786851f
)),
4032 imm(0.1938924977115610f
)),
4034 imm(0.3326756418091246f
)),
4036 imm(0.9999793128310355f
)),
4039 /* range-reduction fixup */
4040 body
.emit(assign(tmp
, add(tmp
,
4041 mul(b2f(greater(abs(y_over_x
),
4042 imm(1.0f
, type
->components()))),
4048 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
4051 ir_function_signature
*
4052 builtin_builder::_atan(const glsl_type
*type
)
4054 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
4055 MAKE_SIG(type
, always_available
, 1, y_over_x
);
4057 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
4058 do_atan(body
, type
, tmp
, y_over_x
);
4059 body
.emit(ret(tmp
));
4064 ir_function_signature
*
4065 builtin_builder::_sinh(const glsl_type
*type
)
4067 ir_variable
*x
= in_var(type
, "x");
4068 MAKE_SIG(type
, v130
, 1, x
);
4070 /* 0.5 * (e^x - e^(-x)) */
4071 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
4076 ir_function_signature
*
4077 builtin_builder::_cosh(const glsl_type
*type
)
4079 ir_variable
*x
= in_var(type
, "x");
4080 MAKE_SIG(type
, v130
, 1, x
);
4082 /* 0.5 * (e^x + e^(-x)) */
4083 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
4088 ir_function_signature
*
4089 builtin_builder::_tanh(const glsl_type
*type
)
4091 ir_variable
*x
= in_var(type
, "x");
4092 MAKE_SIG(type
, v130
, 1, x
);
4094 /* tanh(x) := (0.5 * (e^x - e^(-x))) / (0.5 * (e^x + e^(-x)))
4096 * With a little algebra this reduces to (e^2x - 1) / (e^2x + 1)
4098 * Clamp x to (-inf, +10] to avoid precision problems. When x > 10, e^2x
4099 * is so much larger than 1.0 that 1.0 gets flushed to zero in the
4100 * computation e^2x +/- 1 so it can be ignored.
4102 ir_variable
*t
= body
.make_temp(type
, "tmp");
4103 body
.emit(assign(t
, min2(x
, imm(10.0f
))));
4105 body
.emit(ret(div(sub(exp(mul(t
, imm(2.0f
))), imm(1.0f
)),
4106 add(exp(mul(t
, imm(2.0f
))), imm(1.0f
)))));
4111 ir_function_signature
*
4112 builtin_builder::_asinh(const glsl_type
*type
)
4114 ir_variable
*x
= in_var(type
, "x");
4115 MAKE_SIG(type
, v130
, 1, x
);
4117 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
4122 ir_function_signature
*
4123 builtin_builder::_acosh(const glsl_type
*type
)
4125 ir_variable
*x
= in_var(type
, "x");
4126 MAKE_SIG(type
, v130
, 1, x
);
4128 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
4132 ir_function_signature
*
4133 builtin_builder::_atanh(const glsl_type
*type
)
4135 ir_variable
*x
= in_var(type
, "x");
4136 MAKE_SIG(type
, v130
, 1, x
);
4138 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
4139 sub(imm(1.0f
), x
))))));
4145 * Exponential Functions @{
4148 ir_function_signature
*
4149 builtin_builder::_pow(const glsl_type
*type
)
4151 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
4154 UNOP(exp
, ir_unop_exp
, always_available
)
4155 UNOP(log
, ir_unop_log
, always_available
)
4156 UNOP(exp2
, ir_unop_exp2
, always_available
)
4157 UNOP(log2
, ir_unop_log2
, always_available
)
4158 UNOPA(sqrt
, ir_unop_sqrt
)
4159 UNOPA(inversesqrt
, ir_unop_rsq
)
4163 UNOPA(abs
, ir_unop_abs
)
4164 UNOPA(sign
, ir_unop_sign
)
4165 UNOPA(floor
, ir_unop_floor
)
4166 UNOPA(trunc
, ir_unop_trunc
)
4167 UNOPA(round
, ir_unop_round_even
)
4168 UNOPA(roundEven
, ir_unop_round_even
)
4169 UNOPA(ceil
, ir_unop_ceil
)
4170 UNOPA(fract
, ir_unop_fract
)
4172 ir_function_signature
*
4173 builtin_builder::_mod(builtin_available_predicate avail
,
4174 const glsl_type
*x_type
, const glsl_type
*y_type
)
4176 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
4179 ir_function_signature
*
4180 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
4182 ir_variable
*x
= in_var(type
, "x");
4183 ir_variable
*i
= out_var(type
, "i");
4184 MAKE_SIG(type
, avail
, 2, x
, i
);
4186 ir_variable
*t
= body
.make_temp(type
, "t");
4187 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
4188 body
.emit(assign(i
, t
));
4189 body
.emit(ret(sub(x
, t
)));
4194 ir_function_signature
*
4195 builtin_builder::_min(builtin_available_predicate avail
,
4196 const glsl_type
*x_type
, const glsl_type
*y_type
)
4198 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
4201 ir_function_signature
*
4202 builtin_builder::_max(builtin_available_predicate avail
,
4203 const glsl_type
*x_type
, const glsl_type
*y_type
)
4205 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
4208 ir_function_signature
*
4209 builtin_builder::_clamp(builtin_available_predicate avail
,
4210 const glsl_type
*val_type
, const glsl_type
*bound_type
)
4212 ir_variable
*x
= in_var(val_type
, "x");
4213 ir_variable
*minVal
= in_var(bound_type
, "minVal");
4214 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
4215 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
4217 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
4222 ir_function_signature
*
4223 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
4225 ir_variable
*x
= in_var(val_type
, "x");
4226 ir_variable
*y
= in_var(val_type
, "y");
4227 ir_variable
*a
= in_var(blend_type
, "a");
4228 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4230 body
.emit(ret(lrp(x
, y
, a
)));
4235 ir_function_signature
*
4236 builtin_builder::_mix_sel(builtin_available_predicate avail
,
4237 const glsl_type
*val_type
,
4238 const glsl_type
*blend_type
)
4240 ir_variable
*x
= in_var(val_type
, "x");
4241 ir_variable
*y
= in_var(val_type
, "y");
4242 ir_variable
*a
= in_var(blend_type
, "a");
4243 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4245 /* csel matches the ternary operator in that a selector of true choses the
4246 * first argument. This differs from mix(x, y, false) which choses the
4247 * second argument (to remain consistent with the interpolating version of
4248 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
4250 * To handle the behavior mismatch, reverse the x and y arguments.
4252 body
.emit(ret(csel(a
, y
, x
)));
4257 ir_function_signature
*
4258 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4260 ir_variable
*edge
= in_var(edge_type
, "edge");
4261 ir_variable
*x
= in_var(x_type
, "x");
4262 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
4264 ir_variable
*t
= body
.make_temp(x_type
, "t");
4265 if (x_type
->vector_elements
== 1) {
4266 /* Both are floats */
4267 if (edge_type
->is_double())
4268 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
4270 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
4271 } else if (edge_type
->vector_elements
== 1) {
4272 /* x is a vector but edge is a float */
4273 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4274 if (edge_type
->is_double())
4275 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
4277 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
4280 /* Both are vectors */
4281 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4282 if (edge_type
->is_double())
4283 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
4286 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
4296 ir_function_signature
*
4297 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4299 ir_variable
*edge0
= in_var(edge_type
, "edge0");
4300 ir_variable
*edge1
= in_var(edge_type
, "edge1");
4301 ir_variable
*x
= in_var(x_type
, "x");
4302 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
4304 /* From the GLSL 1.10 specification:
4307 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
4308 * return t * t * (3 - 2 * t);
4311 ir_variable
*t
= body
.make_temp(x_type
, "t");
4312 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
4313 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
4315 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
4320 ir_function_signature
*
4321 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
4323 ir_variable
*x
= in_var(type
, "x");
4324 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4326 body
.emit(ret(nequal(x
, x
)));
4331 ir_function_signature
*
4332 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
4334 ir_variable
*x
= in_var(type
, "x");
4335 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4337 ir_constant_data infinities
;
4338 for (int i
= 0; i
< type
->vector_elements
; i
++) {
4339 switch (type
->base_type
) {
4340 case GLSL_TYPE_FLOAT
:
4341 infinities
.f
[i
] = INFINITY
;
4343 case GLSL_TYPE_DOUBLE
:
4344 infinities
.d
[i
] = INFINITY
;
4347 unreachable("unknown type");
4351 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
4356 ir_function_signature
*
4357 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
4359 ir_variable
*x
= in_var(type
, "x");
4360 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4361 body
.emit(ret(bitcast_f2i(x
)));
4365 ir_function_signature
*
4366 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
4368 ir_variable
*x
= in_var(type
, "x");
4369 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4370 body
.emit(ret(bitcast_f2u(x
)));
4374 ir_function_signature
*
4375 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
4377 ir_variable
*x
= in_var(type
, "x");
4378 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4379 body
.emit(ret(bitcast_i2f(x
)));
4383 ir_function_signature
*
4384 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
4386 ir_variable
*x
= in_var(type
, "x");
4387 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4388 body
.emit(ret(bitcast_u2f(x
)));
4392 ir_function_signature
*
4393 builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail
, const glsl_type
*type
)
4395 ir_variable
*x
= in_var(type
, "x");
4396 MAKE_SIG(glsl_type::i64vec(type
->vector_elements
), avail
, 1, x
);
4397 body
.emit(ret(bitcast_d2i64(x
)));
4401 ir_function_signature
*
4402 builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail
, const glsl_type
*type
)
4404 ir_variable
*x
= in_var(type
, "x");
4405 MAKE_SIG(glsl_type::u64vec(type
->vector_elements
), avail
, 1, x
);
4406 body
.emit(ret(bitcast_d2u64(x
)));
4410 ir_function_signature
*
4411 builtin_builder::_int64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4413 ir_variable
*x
= in_var(type
, "x");
4414 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4415 body
.emit(ret(bitcast_i642d(x
)));
4419 ir_function_signature
*
4420 builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4422 ir_variable
*x
= in_var(type
, "x");
4423 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4424 body
.emit(ret(bitcast_u642d(x
)));
4428 ir_function_signature
*
4429 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
4431 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4432 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4433 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
4437 ir_function_signature
*
4438 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
4440 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4441 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4442 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
4446 ir_function_signature
*
4447 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
4449 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4450 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4451 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
4455 ir_function_signature
*
4456 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
4458 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4459 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4460 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
4464 ir_function_signature
*
4465 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
4467 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4468 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4469 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
4473 ir_function_signature
*
4474 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
4476 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4477 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4478 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
4483 ir_function_signature
*
4484 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
4486 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4487 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4488 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
4492 ir_function_signature
*
4493 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
4495 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4496 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4497 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
4501 ir_function_signature
*
4502 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
4504 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4505 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4506 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
4510 ir_function_signature
*
4511 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
4513 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4514 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4515 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
4519 ir_function_signature
*
4520 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
4522 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4523 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
4524 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
4528 ir_function_signature
*
4529 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
4531 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
4532 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4533 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
4537 ir_function_signature
*
4538 builtin_builder::_packInt2x32(builtin_available_predicate avail
)
4540 ir_variable
*v
= in_var(glsl_type::ivec2_type
, "v");
4541 MAKE_SIG(glsl_type::int64_t_type
, avail
, 1, v
);
4542 body
.emit(ret(expr(ir_unop_pack_int_2x32
, v
)));
4546 ir_function_signature
*
4547 builtin_builder::_unpackInt2x32(builtin_available_predicate avail
)
4549 ir_variable
*p
= in_var(glsl_type::int64_t_type
, "p");
4550 MAKE_SIG(glsl_type::ivec2_type
, avail
, 1, p
);
4551 body
.emit(ret(expr(ir_unop_unpack_int_2x32
, p
)));
4555 ir_function_signature
*
4556 builtin_builder::_packUint2x32(builtin_available_predicate avail
)
4558 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4559 MAKE_SIG(glsl_type::uint64_t_type
, avail
, 1, v
);
4560 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, v
)));
4564 ir_function_signature
*
4565 builtin_builder::_unpackUint2x32(builtin_available_predicate avail
)
4567 ir_variable
*p
= in_var(glsl_type::uint64_t_type
, "p");
4568 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4569 body
.emit(ret(expr(ir_unop_unpack_uint_2x32
, p
)));
4573 ir_function_signature
*
4574 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
4576 ir_variable
*x
= in_var(type
, "x");
4577 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
4579 body
.emit(ret(sqrt(dot(x
, x
))));
4584 ir_function_signature
*
4585 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
4587 ir_variable
*p0
= in_var(type
, "p0");
4588 ir_variable
*p1
= in_var(type
, "p1");
4589 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
4591 if (type
->vector_elements
== 1) {
4592 body
.emit(ret(abs(sub(p0
, p1
))));
4594 ir_variable
*p
= body
.make_temp(type
, "p");
4595 body
.emit(assign(p
, sub(p0
, p1
)));
4596 body
.emit(ret(sqrt(dot(p
, p
))));
4602 ir_function_signature
*
4603 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
4605 if (type
->vector_elements
== 1)
4606 return binop(avail
, ir_binop_mul
, type
, type
, type
);
4608 return binop(avail
, ir_binop_dot
,
4609 type
->get_base_type(), type
, type
);
4612 ir_function_signature
*
4613 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
4615 ir_variable
*a
= in_var(type
, "a");
4616 ir_variable
*b
= in_var(type
, "b");
4617 MAKE_SIG(type
, avail
, 2, a
, b
);
4619 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
4620 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
4622 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
4623 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
4628 ir_function_signature
*
4629 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
4631 ir_variable
*x
= in_var(type
, "x");
4632 MAKE_SIG(type
, avail
, 1, x
);
4634 if (type
->vector_elements
== 1) {
4635 body
.emit(ret(sign(x
)));
4637 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
4643 ir_function_signature
*
4644 builtin_builder::_ftransform()
4646 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
4648 /* ftransform() refers to global variables, and is always emitted
4649 * directly by ast_function.cpp. Just emit a prototype here so we
4650 * can recognize calls to it.
4655 ir_function_signature
*
4656 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
4658 ir_variable
*N
= in_var(type
, "N");
4659 ir_variable
*I
= in_var(type
, "I");
4660 ir_variable
*Nref
= in_var(type
, "Nref");
4661 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
4663 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
4664 ret(N
), ret(neg(N
))));
4669 ir_function_signature
*
4670 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
4672 ir_variable
*I
= in_var(type
, "I");
4673 ir_variable
*N
= in_var(type
, "N");
4674 MAKE_SIG(type
, avail
, 2, I
, N
);
4676 /* I - 2 * dot(N, I) * N */
4677 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
4682 ir_function_signature
*
4683 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
4685 ir_variable
*I
= in_var(type
, "I");
4686 ir_variable
*N
= in_var(type
, "N");
4687 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
4688 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4690 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4691 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4693 /* From the GLSL 1.10 specification:
4694 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4696 * return genType(0.0)
4698 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4700 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4701 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4702 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4703 mul(n_dot_i
, n_dot_i
)))))));
4704 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4705 ret(ir_constant::zero(mem_ctx
, type
)),
4706 ret(sub(mul(eta
, I
),
4707 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4712 ir_function_signature
*
4713 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4715 ir_variable
*x
= in_var(type
, "x");
4716 ir_variable
*y
= in_var(type
, "y");
4717 MAKE_SIG(type
, avail
, 2, x
, y
);
4719 ir_variable
*z
= body
.make_temp(type
, "z");
4720 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4721 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4728 ir_function_signature
*
4729 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4734 if (type
->is_double()) {
4735 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4736 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4738 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4739 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4741 MAKE_SIG(type
, avail
, 2, c
, r
);
4743 ir_variable
*m
= body
.make_temp(type
, "m");
4744 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4745 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4752 ir_function_signature
*
4753 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4755 const glsl_type
*transpose_type
=
4756 glsl_type::get_instance(orig_type
->base_type
,
4757 orig_type
->matrix_columns
,
4758 orig_type
->vector_elements
);
4760 ir_variable
*m
= in_var(orig_type
, "m");
4761 MAKE_SIG(transpose_type
, avail
, 1, m
);
4763 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4764 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4765 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4766 body
.emit(assign(array_ref(t
, j
),
4767 matrix_elt(m
, i
, j
),
4776 ir_function_signature
*
4777 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4779 ir_variable
*m
= in_var(type
, "m");
4780 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4782 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4783 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4788 ir_function_signature
*
4789 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4791 ir_variable
*m
= in_var(type
, "m");
4792 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4795 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4796 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4799 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4800 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4803 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4804 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4806 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4807 mul(matrix_elt(m
, 0, 1), f2
)),
4808 mul(matrix_elt(m
, 0, 2), f3
))));
4813 ir_function_signature
*
4814 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4816 ir_variable
*m
= in_var(type
, "m");
4817 const glsl_type
*btype
= type
->get_base_type();
4818 MAKE_SIG(btype
, avail
, 1, m
);
4820 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4821 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4822 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4823 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4824 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4825 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4826 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4827 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4828 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4829 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4830 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4831 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4832 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4833 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4834 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4835 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4836 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4837 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4838 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4840 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)))));
4841 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)))));
4842 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)))));
4843 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)))));
4844 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)))));
4845 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)))));
4846 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)))));
4847 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)))));
4848 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)))));
4849 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)))));
4850 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)))));
4851 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)))));
4852 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)))));
4853 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)))));
4854 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)))));
4855 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)))));
4856 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)))));
4857 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)))));
4858 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)))));
4860 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4862 body
.emit(assign(adj_0
,
4863 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4864 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4865 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4867 body
.emit(assign(adj_0
, neg(
4868 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4869 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4870 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4872 body
.emit(assign(adj_0
,
4873 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4874 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4875 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4877 body
.emit(assign(adj_0
, neg(
4878 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4879 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4880 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4883 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4888 ir_function_signature
*
4889 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4891 ir_variable
*m
= in_var(type
, "m");
4892 MAKE_SIG(type
, avail
, 1, m
);
4894 ir_variable
*adj
= body
.make_temp(type
, "adj");
4895 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4896 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4897 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4898 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4900 ir_expression
*det
=
4901 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4902 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4904 body
.emit(ret(div(adj
, det
)));
4908 ir_function_signature
*
4909 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4911 ir_variable
*m
= in_var(type
, "m");
4912 const glsl_type
*btype
= type
->get_base_type();
4913 MAKE_SIG(type
, avail
, 1, m
);
4915 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4916 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4917 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4919 body
.emit(assign(f11_22_21_12
,
4920 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4921 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4922 body
.emit(assign(f10_22_20_12
,
4923 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4924 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4925 body
.emit(assign(f10_21_20_11
,
4926 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4927 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4929 ir_variable
*adj
= body
.make_temp(type
, "adj");
4930 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4931 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4932 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4934 body
.emit(assign(array_ref(adj
, 0), neg(
4935 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4936 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4938 body
.emit(assign(array_ref(adj
, 1),
4939 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4940 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4942 body
.emit(assign(array_ref(adj
, 2), neg(
4943 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4944 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4947 body
.emit(assign(array_ref(adj
, 0),
4948 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4949 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4951 body
.emit(assign(array_ref(adj
, 1), neg(
4952 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4953 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4955 body
.emit(assign(array_ref(adj
, 2),
4956 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4957 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4960 ir_expression
*det
=
4961 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4962 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4963 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4965 body
.emit(ret(div(adj
, det
)));
4970 ir_function_signature
*
4971 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4973 ir_variable
*m
= in_var(type
, "m");
4974 const glsl_type
*btype
= type
->get_base_type();
4975 MAKE_SIG(type
, avail
, 1, m
);
4977 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4978 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4979 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4980 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4981 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4982 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4983 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4984 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4985 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4986 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4987 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4988 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4989 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4990 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4991 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4992 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4993 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4994 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4995 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4997 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)))));
4998 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)))));
4999 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)))));
5000 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)))));
5001 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)))));
5002 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)))));
5003 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)))));
5004 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)))));
5005 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)))));
5006 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)))));
5007 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)))));
5008 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)))));
5009 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)))));
5010 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)))));
5011 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)))));
5012 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)))));
5013 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)))));
5014 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)))));
5015 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)))));
5017 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
5018 body
.emit(assign(array_ref(adj
, 0),
5019 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
5020 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
5021 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
5023 body
.emit(assign(array_ref(adj
, 1), neg(
5024 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
5025 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
5026 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
5028 body
.emit(assign(array_ref(adj
, 2),
5029 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
5030 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
5031 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
5033 body
.emit(assign(array_ref(adj
, 3), neg(
5034 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
5035 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
5036 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
5039 body
.emit(assign(array_ref(adj
, 0), neg(
5040 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
5041 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
5042 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
5044 body
.emit(assign(array_ref(adj
, 1),
5045 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
5046 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
5047 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
5049 body
.emit(assign(array_ref(adj
, 2), neg(
5050 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
5051 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
5052 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
5054 body
.emit(assign(array_ref(adj
, 3),
5055 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
5056 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
5057 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
5060 body
.emit(assign(array_ref(adj
, 0),
5061 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
5062 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
5063 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
5065 body
.emit(assign(array_ref(adj
, 1), neg(
5066 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
5067 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
5068 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
5070 body
.emit(assign(array_ref(adj
, 2),
5071 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
5072 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
5073 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
5075 body
.emit(assign(array_ref(adj
, 3), neg(
5076 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
5077 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
5078 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
5081 body
.emit(assign(array_ref(adj
, 0), neg(
5082 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
5083 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
5084 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
5086 body
.emit(assign(array_ref(adj
, 1),
5087 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
5088 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
5089 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
5091 body
.emit(assign(array_ref(adj
, 2), neg(
5092 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
5093 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
5094 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
5096 body
.emit(assign(array_ref(adj
, 3),
5097 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
5098 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
5099 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
5102 ir_expression
*det
=
5103 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
5104 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
5105 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
5106 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
5108 body
.emit(ret(div(adj
, det
)));
5114 ir_function_signature
*
5115 builtin_builder::_lessThan(builtin_available_predicate avail
,
5116 const glsl_type
*type
)
5118 return binop(avail
, ir_binop_less
,
5119 glsl_type::bvec(type
->vector_elements
), type
, type
);
5122 ir_function_signature
*
5123 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
5124 const glsl_type
*type
)
5126 return binop(avail
, ir_binop_gequal
,
5127 glsl_type::bvec(type
->vector_elements
), type
, type
,
5131 ir_function_signature
*
5132 builtin_builder::_greaterThan(builtin_available_predicate avail
,
5133 const glsl_type
*type
)
5135 return binop(avail
, ir_binop_less
,
5136 glsl_type::bvec(type
->vector_elements
), type
, type
,
5140 ir_function_signature
*
5141 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
5142 const glsl_type
*type
)
5144 return binop(avail
, ir_binop_gequal
,
5145 glsl_type::bvec(type
->vector_elements
), type
, type
);
5148 ir_function_signature
*
5149 builtin_builder::_equal(builtin_available_predicate avail
,
5150 const glsl_type
*type
)
5152 return binop(avail
, ir_binop_equal
,
5153 glsl_type::bvec(type
->vector_elements
), type
, type
);
5156 ir_function_signature
*
5157 builtin_builder::_notEqual(builtin_available_predicate avail
,
5158 const glsl_type
*type
)
5160 return binop(avail
, ir_binop_nequal
,
5161 glsl_type::bvec(type
->vector_elements
), type
, type
);
5164 ir_function_signature
*
5165 builtin_builder::_any(const glsl_type
*type
)
5167 ir_variable
*v
= in_var(type
, "v");
5168 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5170 const unsigned vec_elem
= v
->type
->vector_elements
;
5171 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
5176 ir_function_signature
*
5177 builtin_builder::_all(const glsl_type
*type
)
5179 ir_variable
*v
= in_var(type
, "v");
5180 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5182 const unsigned vec_elem
= v
->type
->vector_elements
;
5183 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
5188 UNOP(not, ir_unop_logic_not
, always_available
)
5191 has_lod(const glsl_type
*sampler_type
)
5193 assert(sampler_type
->is_sampler());
5195 switch (sampler_type
->sampler_dimensionality
) {
5196 case GLSL_SAMPLER_DIM_RECT
:
5197 case GLSL_SAMPLER_DIM_BUF
:
5198 case GLSL_SAMPLER_DIM_MS
:
5205 ir_function_signature
*
5206 builtin_builder::_textureSize(builtin_available_predicate avail
,
5207 const glsl_type
*return_type
,
5208 const glsl_type
*sampler_type
)
5210 ir_variable
*s
= in_var(sampler_type
, "sampler");
5211 /* The sampler always exists; add optional lod later. */
5212 MAKE_SIG(return_type
, avail
, 1, s
);
5214 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
5215 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
5217 if (has_lod(sampler_type
)) {
5218 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5219 sig
->parameters
.push_tail(lod
);
5220 tex
->lod_info
.lod
= var_ref(lod
);
5222 tex
->lod_info
.lod
= imm(0u);
5225 body
.emit(ret(tex
));
5230 ir_function_signature
*
5231 builtin_builder::_textureSamples(builtin_available_predicate avail
,
5232 const glsl_type
*sampler_type
)
5234 ir_variable
*s
= in_var(sampler_type
, "sampler");
5235 MAKE_SIG(glsl_type::int_type
, avail
, 1, s
);
5237 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
5238 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
5239 body
.emit(ret(tex
));
5244 ir_function_signature
*
5245 builtin_builder::_texture(ir_texture_opcode opcode
,
5246 builtin_available_predicate avail
,
5247 const glsl_type
*return_type
,
5248 const glsl_type
*sampler_type
,
5249 const glsl_type
*coord_type
,
5252 ir_variable
*s
= in_var(sampler_type
, "sampler");
5253 ir_variable
*P
= in_var(coord_type
, "P");
5254 /* The sampler and coordinate always exist; add optional parameters later. */
5255 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5257 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
5258 tex
->set_sampler(var_ref(s
), return_type
);
5260 const int coord_size
= sampler_type
->coordinate_components();
5262 if (coord_size
== coord_type
->vector_elements
) {
5263 tex
->coordinate
= var_ref(P
);
5265 /* The incoming coordinate also has the projector or shadow comparator,
5266 * so we need to swizzle those away.
5268 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
5271 /* The projector is always in the last component. */
5272 if (flags
& TEX_PROJECT
)
5273 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
5275 if (sampler_type
->sampler_shadow
) {
5276 if (opcode
== ir_tg4
) {
5277 /* gather has refz as a separate parameter, immediately after the
5280 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
5281 sig
->parameters
.push_tail(refz
);
5282 tex
->shadow_comparator
= var_ref(refz
);
5284 /* The shadow comparator is normally in the Z component, but a few types
5285 * have sufficiently large coordinates that it's in W.
5287 tex
->shadow_comparator
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
5291 if (opcode
== ir_txl
) {
5292 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
5293 sig
->parameters
.push_tail(lod
);
5294 tex
->lod_info
.lod
= var_ref(lod
);
5295 } else if (opcode
== ir_txd
) {
5296 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5297 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
5298 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
5299 sig
->parameters
.push_tail(dPdx
);
5300 sig
->parameters
.push_tail(dPdy
);
5301 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
5302 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
5305 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
5306 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5307 ir_variable
*offset
=
5308 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
5309 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
5310 sig
->parameters
.push_tail(offset
);
5311 tex
->offset
= var_ref(offset
);
5314 if (flags
& TEX_OFFSET_ARRAY
) {
5315 ir_variable
*offsets
=
5316 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
5317 "offsets", ir_var_const_in
);
5318 sig
->parameters
.push_tail(offsets
);
5319 tex
->offset
= var_ref(offsets
);
5322 if (opcode
== ir_tg4
) {
5323 if (flags
& TEX_COMPONENT
) {
5324 ir_variable
*component
=
5325 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
5326 sig
->parameters
.push_tail(component
);
5327 tex
->lod_info
.component
= var_ref(component
);
5330 tex
->lod_info
.component
= imm(0);
5334 /* The "bias" parameter comes /after/ the "offset" parameter, which is
5335 * inconsistent with both textureLodOffset and textureGradOffset.
5337 if (opcode
== ir_txb
) {
5338 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
5339 sig
->parameters
.push_tail(bias
);
5340 tex
->lod_info
.bias
= var_ref(bias
);
5343 body
.emit(ret(tex
));
5348 ir_function_signature
*
5349 builtin_builder::_textureCubeArrayShadow(builtin_available_predicate avail
,
5350 const glsl_type
*sampler_type
)
5352 ir_variable
*s
= in_var(sampler_type
, "sampler");
5353 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
5354 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
5355 MAKE_SIG(glsl_type::float_type
, avail
, 3, s
, P
, compare
);
5357 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
5358 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
5360 tex
->coordinate
= var_ref(P
);
5361 tex
->shadow_comparator
= var_ref(compare
);
5363 body
.emit(ret(tex
));
5368 ir_function_signature
*
5369 builtin_builder::_texelFetch(builtin_available_predicate avail
,
5370 const glsl_type
*return_type
,
5371 const glsl_type
*sampler_type
,
5372 const glsl_type
*coord_type
,
5373 const glsl_type
*offset_type
)
5375 ir_variable
*s
= in_var(sampler_type
, "sampler");
5376 ir_variable
*P
= in_var(coord_type
, "P");
5377 /* The sampler and coordinate always exist; add optional parameters later. */
5378 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5380 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
5381 tex
->coordinate
= var_ref(P
);
5382 tex
->set_sampler(var_ref(s
), return_type
);
5384 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
5385 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
5386 sig
->parameters
.push_tail(sample
);
5387 tex
->lod_info
.sample_index
= var_ref(sample
);
5388 tex
->op
= ir_txf_ms
;
5389 } else if (has_lod(sampler_type
)) {
5390 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5391 sig
->parameters
.push_tail(lod
);
5392 tex
->lod_info
.lod
= var_ref(lod
);
5394 tex
->lod_info
.lod
= imm(0u);
5397 if (offset_type
!= NULL
) {
5398 ir_variable
*offset
=
5399 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
5400 sig
->parameters
.push_tail(offset
);
5401 tex
->offset
= var_ref(offset
);
5404 body
.emit(ret(tex
));
5409 ir_function_signature
*
5410 builtin_builder::_EmitVertex()
5412 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5414 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5415 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
5420 ir_function_signature
*
5421 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
5422 const glsl_type
*stream_type
)
5424 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5426 * "Emit the current values of output variables to the current output
5427 * primitive on stream stream. The argument to stream must be a constant
5428 * integral expression."
5430 ir_variable
*stream
=
5431 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5433 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5435 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
5440 ir_function_signature
*
5441 builtin_builder::_EndPrimitive()
5443 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5445 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5446 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
5451 ir_function_signature
*
5452 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
5453 const glsl_type
*stream_type
)
5455 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5457 * "Completes the current output primitive on stream stream and starts
5458 * a new one. The argument to stream must be a constant integral
5461 ir_variable
*stream
=
5462 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5464 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5466 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
5471 ir_function_signature
*
5472 builtin_builder::_barrier()
5474 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
5476 body
.emit(new(mem_ctx
) ir_barrier());
5480 ir_function_signature
*
5481 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
5482 const glsl_type
*sampler_type
,
5483 const glsl_type
*coord_type
)
5485 ir_variable
*s
= in_var(sampler_type
, "sampler");
5486 ir_variable
*coord
= in_var(coord_type
, "coord");
5487 /* The sampler and coordinate always exist; add optional parameters later. */
5488 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
5490 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
5491 tex
->coordinate
= var_ref(coord
);
5492 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
5494 body
.emit(ret(tex
));
5499 ir_function_signature
*
5500 builtin_builder::_textureQueryLevels(builtin_available_predicate avail
,
5501 const glsl_type
*sampler_type
)
5503 ir_variable
*s
= in_var(sampler_type
, "sampler");
5504 const glsl_type
*return_type
= glsl_type::int_type
;
5505 MAKE_SIG(return_type
, avail
, 1, s
);
5507 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
5508 tex
->set_sampler(var_ref(s
), return_type
);
5510 body
.emit(ret(tex
));
5515 ir_function_signature
*
5516 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
5517 const glsl_type
*sampler_type
,
5518 const glsl_type
*coord_type
)
5520 ir_variable
*s
= in_var(sampler_type
, "sampler");
5521 ir_variable
*P
= in_var(coord_type
, "P");
5522 const glsl_type
*return_type
= glsl_type::bool_type
;
5523 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5525 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
5526 tex
->coordinate
= var_ref(P
);
5527 tex
->set_sampler(var_ref(s
), return_type
);
5529 body
.emit(ret(tex
));
5534 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
5535 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
5536 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
5537 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
5538 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
5539 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
5541 ir_function_signature
*
5542 builtin_builder::_fwidth(const glsl_type
*type
)
5544 ir_variable
*p
= in_var(type
, "p");
5545 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
5547 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
5552 ir_function_signature
*
5553 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
5555 ir_variable
*p
= in_var(type
, "p");
5556 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5558 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
5559 abs(expr(ir_unop_dFdy_coarse
, p
)))));
5564 ir_function_signature
*
5565 builtin_builder::_fwidthFine(const glsl_type
*type
)
5567 ir_variable
*p
= in_var(type
, "p");
5568 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5570 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
5571 abs(expr(ir_unop_dFdy_fine
, p
)))));
5576 ir_function_signature
*
5577 builtin_builder::_noise1(const glsl_type
*type
)
5579 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
5582 ir_function_signature
*
5583 builtin_builder::_noise2(const glsl_type
*type
)
5585 ir_variable
*p
= in_var(type
, "p");
5586 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
5588 ir_constant_data b_offset
;
5589 b_offset
.f
[0] = 601.0f
;
5590 b_offset
.f
[1] = 313.0f
;
5591 b_offset
.f
[2] = 29.0f
;
5592 b_offset
.f
[3] = 277.0f
;
5594 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5595 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5596 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
5597 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5598 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5599 body
.emit(assign(t
, a
, WRITEMASK_X
));
5600 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5606 ir_function_signature
*
5607 builtin_builder::_noise3(const glsl_type
*type
)
5609 ir_variable
*p
= in_var(type
, "p");
5610 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
5612 ir_constant_data b_offset
;
5613 b_offset
.f
[0] = 601.0f
;
5614 b_offset
.f
[1] = 313.0f
;
5615 b_offset
.f
[2] = 29.0f
;
5616 b_offset
.f
[3] = 277.0f
;
5618 ir_constant_data c_offset
;
5619 c_offset
.f
[0] = 1559.0f
;
5620 c_offset
.f
[1] = 113.0f
;
5621 c_offset
.f
[2] = 1861.0f
;
5622 c_offset
.f
[3] = 797.0f
;
5624 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5625 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5626 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5627 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
5628 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5629 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5630 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
5631 body
.emit(assign(t
, a
, WRITEMASK_X
));
5632 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5633 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5639 ir_function_signature
*
5640 builtin_builder::_noise4(const glsl_type
*type
)
5642 ir_variable
*p
= in_var(type
, "p");
5643 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
5645 ir_variable
*_p
= body
.make_temp(type
, "_p");
5647 ir_constant_data p_offset
;
5648 p_offset
.f
[0] = 1559.0f
;
5649 p_offset
.f
[1] = 113.0f
;
5650 p_offset
.f
[2] = 1861.0f
;
5651 p_offset
.f
[3] = 797.0f
;
5653 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
5655 ir_constant_data offset
;
5656 offset
.f
[0] = 601.0f
;
5657 offset
.f
[1] = 313.0f
;
5658 offset
.f
[2] = 29.0f
;
5659 offset
.f
[3] = 277.0f
;
5661 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5662 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5663 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5664 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
5665 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
5666 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5667 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
5668 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
5669 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
5670 body
.emit(assign(t
, a
, WRITEMASK_X
));
5671 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5672 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5673 body
.emit(assign(t
, d
, WRITEMASK_W
));
5679 ir_function_signature
*
5680 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
5682 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5683 ir_variable
*value
= in_var(type
, "value");
5684 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5685 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5686 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, value
, offset
,
5689 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5690 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5692 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
5693 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5694 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5699 ir_function_signature
*
5700 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5702 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5703 ir_variable
*base
= in_var(type
, "base");
5704 ir_variable
*insert
= in_var(type
, "insert");
5705 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5706 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5707 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 4, base
, insert
,
5710 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5711 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5713 body
.emit(ret(bitfield_insert(base
, insert
,
5714 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5715 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5720 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31_or_integer_functions
)
5722 ir_function_signature
*
5723 builtin_builder::_bitCount(const glsl_type
*type
)
5725 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_bit_count
,
5726 glsl_type::ivec(type
->vector_elements
), type
);
5729 ir_function_signature
*
5730 builtin_builder::_findLSB(const glsl_type
*type
)
5732 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_lsb
,
5733 glsl_type::ivec(type
->vector_elements
), type
);
5736 ir_function_signature
*
5737 builtin_builder::_findMSB(const glsl_type
*type
)
5739 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_msb
,
5740 glsl_type::ivec(type
->vector_elements
), type
);
5743 ir_function_signature
*
5744 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5746 ir_variable
*a
= in_var(type
, "a");
5747 ir_variable
*b
= in_var(type
, "b");
5748 ir_variable
*c
= in_var(type
, "c");
5749 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5751 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5756 ir_function_signature
*
5757 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5759 return binop(x_type
->is_double() ? fp64
: gpu_shader5_or_es31_or_integer_functions
,
5760 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5763 ir_function_signature
*
5764 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5766 ir_variable
*x
= in_var(x_type
, "x");
5767 ir_variable
*exponent
= out_var(exp_type
, "exp");
5768 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5770 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5772 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5776 ir_function_signature
*
5777 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5779 ir_variable
*x
= in_var(x_type
, "x");
5780 ir_variable
*exponent
= out_var(exp_type
, "exp");
5781 MAKE_SIG(x_type
, gpu_shader5_or_es31_or_integer_functions
, 2, x
, exponent
);
5783 const unsigned vec_elem
= x_type
->vector_elements
;
5784 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5785 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5787 /* Single-precision floating-point values are stored as
5792 * An exponent shift of 23 will shift the mantissa out, leaving only the
5793 * exponent and sign bit (which itself may be zero, if the absolute value
5794 * was taken before the bitcast and shift.
5796 ir_constant
*exponent_shift
= imm(23);
5797 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5799 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5801 /* Exponent of floating-point values in the range [0.5, 1.0). */
5802 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5804 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5805 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5807 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5808 * to unsigned integers to ensure that 1 bits aren't shifted in.
5810 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5811 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5812 imm(0, vec_elem
)))));
5814 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5815 body
.emit(assign(bits
, bitcast_f2u(x
)));
5816 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5817 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5818 imm(0u, vec_elem
)))));
5819 body
.emit(ret(bitcast_u2f(bits
)));
5824 ir_function_signature
*
5825 builtin_builder::_uaddCarry(const glsl_type
*type
)
5827 ir_variable
*x
= in_var(type
, "x");
5828 ir_variable
*y
= in_var(type
, "y");
5829 ir_variable
*carry
= out_var(type
, "carry");
5830 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, carry
);
5832 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5833 body
.emit(ret(add(x
, y
)));
5838 ir_function_signature
*
5839 builtin_builder::_usubBorrow(const glsl_type
*type
)
5841 ir_variable
*x
= in_var(type
, "x");
5842 ir_variable
*y
= in_var(type
, "y");
5843 ir_variable
*borrow
= out_var(type
, "borrow");
5844 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, borrow
);
5846 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5847 body
.emit(ret(sub(x
, y
)));
5853 * For both imulExtended() and umulExtended() built-ins.
5855 ir_function_signature
*
5856 builtin_builder::_mulExtended(const glsl_type
*type
)
5858 ir_variable
*x
= in_var(type
, "x");
5859 ir_variable
*y
= in_var(type
, "y");
5860 ir_variable
*msb
= out_var(type
, "msb");
5861 ir_variable
*lsb
= out_var(type
, "lsb");
5862 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31_or_integer_functions
, 4, x
, y
, msb
, lsb
);
5864 body
.emit(assign(msb
, imul_high(x
, y
)));
5865 body
.emit(assign(lsb
, mul(x
, y
)));
5870 ir_function_signature
*
5871 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5873 ir_variable
*interpolant
= in_var(type
, "interpolant");
5874 interpolant
->data
.must_be_shader_input
= 1;
5875 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5877 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5882 ir_function_signature
*
5883 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5885 ir_variable
*interpolant
= in_var(type
, "interpolant");
5886 interpolant
->data
.must_be_shader_input
= 1;
5887 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5888 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5890 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5895 ir_function_signature
*
5896 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5898 ir_variable
*interpolant
= in_var(type
, "interpolant");
5899 interpolant
->data
.must_be_shader_input
= 1;
5900 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5901 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5903 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5908 ir_function_signature
*
5909 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
,
5910 enum ir_intrinsic_id id
)
5912 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5913 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 1, counter
);
5917 ir_function_signature
*
5918 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
,
5919 enum ir_intrinsic_id id
)
5921 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5922 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5923 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 2, counter
, data
);
5927 ir_function_signature
*
5928 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
,
5929 enum ir_intrinsic_id id
)
5931 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5932 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5933 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5934 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 3, counter
, compare
, data
);
5938 ir_function_signature
*
5939 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5940 const glsl_type
*type
,
5941 enum ir_intrinsic_id id
)
5943 ir_variable
*atomic
= in_var(type
, "atomic");
5944 ir_variable
*data
= in_var(type
, "data");
5945 MAKE_INTRINSIC(type
, id
, avail
, 2, atomic
, data
);
5949 ir_function_signature
*
5950 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5951 const glsl_type
*type
,
5952 enum ir_intrinsic_id id
)
5954 ir_variable
*atomic
= in_var(type
, "atomic");
5955 ir_variable
*data1
= in_var(type
, "data1");
5956 ir_variable
*data2
= in_var(type
, "data2");
5957 MAKE_INTRINSIC(type
, id
, avail
, 3, atomic
, data1
, data2
);
5961 ir_function_signature
*
5962 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5963 builtin_available_predicate avail
)
5965 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5966 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5968 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5969 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5971 body
.emit(ret(retval
));
5975 ir_function_signature
*
5976 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5977 builtin_available_predicate avail
)
5979 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5980 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5981 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5983 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5985 /* Instead of generating an __intrinsic_atomic_sub, generate an
5986 * __intrinsic_atomic_add with the data parameter negated.
5988 if (strcmp("__intrinsic_atomic_sub", intrinsic
) == 0) {
5989 ir_variable
*const neg_data
=
5990 body
.make_temp(glsl_type::uint_type
, "neg_data");
5992 body
.emit(assign(neg_data
, neg(data
)));
5994 exec_list parameters
;
5996 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(counter
));
5997 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(neg_data
));
5999 ir_function
*const func
=
6000 shader
->symbols
->get_function("__intrinsic_atomic_add");
6001 ir_instruction
*const c
= call(func
, retval
, parameters
);
6004 assert(parameters
.is_empty());
6008 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6012 body
.emit(ret(retval
));
6016 ir_function_signature
*
6017 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
6018 builtin_available_predicate avail
)
6020 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
6021 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
6022 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
6023 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
6025 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
6026 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6028 body
.emit(ret(retval
));
6032 ir_function_signature
*
6033 builtin_builder::_atomic_op2(const char *intrinsic
,
6034 builtin_available_predicate avail
,
6035 const glsl_type
*type
)
6037 ir_variable
*atomic
= in_var(type
, "atomic_var");
6038 ir_variable
*data
= in_var(type
, "atomic_data");
6039 MAKE_SIG(type
, avail
, 2, atomic
, data
);
6041 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
6042 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6044 body
.emit(ret(retval
));
6048 ir_function_signature
*
6049 builtin_builder::_atomic_op3(const char *intrinsic
,
6050 builtin_available_predicate avail
,
6051 const glsl_type
*type
)
6053 ir_variable
*atomic
= in_var(type
, "atomic_var");
6054 ir_variable
*data1
= in_var(type
, "atomic_data1");
6055 ir_variable
*data2
= in_var(type
, "atomic_data2");
6056 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
6058 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
6059 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
6061 body
.emit(ret(retval
));
6065 ir_function_signature
*
6066 builtin_builder::_min3(const glsl_type
*type
)
6068 ir_variable
*x
= in_var(type
, "x");
6069 ir_variable
*y
= in_var(type
, "y");
6070 ir_variable
*z
= in_var(type
, "z");
6071 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6073 ir_expression
*min3
= min2(x
, min2(y
,z
));
6074 body
.emit(ret(min3
));
6079 ir_function_signature
*
6080 builtin_builder::_max3(const glsl_type
*type
)
6082 ir_variable
*x
= in_var(type
, "x");
6083 ir_variable
*y
= in_var(type
, "y");
6084 ir_variable
*z
= in_var(type
, "z");
6085 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6087 ir_expression
*max3
= max2(x
, max2(y
,z
));
6088 body
.emit(ret(max3
));
6093 ir_function_signature
*
6094 builtin_builder::_mid3(const glsl_type
*type
)
6096 ir_variable
*x
= in_var(type
, "x");
6097 ir_variable
*y
= in_var(type
, "y");
6098 ir_variable
*z
= in_var(type
, "z");
6099 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6101 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
6102 body
.emit(ret(mid3
));
6107 static builtin_available_predicate
6108 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
6110 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
6111 type
->sampled_type
== GLSL_TYPE_FLOAT
)
6112 return shader_image_atomic_exchange_float
;
6114 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
) &&
6115 type
->sampled_type
== GLSL_TYPE_FLOAT
)
6116 return shader_image_atomic_add_float
;
6118 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
6119 IMAGE_FUNCTION_AVAIL_ATOMIC_ADD
|
6120 IMAGE_FUNCTION_AVAIL_ATOMIC
))
6121 return shader_image_atomic
;
6124 return shader_image_load_store
;
6127 ir_function_signature
*
6128 builtin_builder::_image_prototype(const glsl_type
*image_type
,
6129 unsigned num_arguments
,
6132 const glsl_type
*data_type
= glsl_type::get_instance(
6133 image_type
->sampled_type
,
6134 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
6136 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
6137 glsl_type::void_type
: data_type
);
6139 /* Addressing arguments that are always present. */
6140 ir_variable
*image
= in_var(image_type
, "image");
6141 ir_variable
*coord
= in_var(
6142 glsl_type::ivec(image_type
->coordinate_components()), "coord");
6144 ir_function_signature
*sig
= new_sig(
6145 ret_type
, get_image_available_predicate(image_type
, flags
),
6148 /* Sample index for multisample images. */
6149 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
6150 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
6152 /* Data arguments. */
6153 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
6154 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
6155 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
6156 ralloc_free(arg_name
);
6159 /* Set the maximal set of qualifiers allowed for this image
6160 * built-in. Function calls with arguments having fewer
6161 * qualifiers than present in the prototype are allowed by the
6162 * spec, but not with more, i.e. this will make the compiler
6163 * accept everything that needs to be accepted, and reject cases
6164 * like loads from write-only or stores to read-only images.
6166 image
->data
.memory_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
6167 image
->data
.memory_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
6168 image
->data
.memory_coherent
= true;
6169 image
->data
.memory_volatile
= true;
6170 image
->data
.memory_restrict
= true;
6175 ir_function_signature
*
6176 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
6177 unsigned /* num_arguments */,
6178 unsigned /* flags */)
6180 const glsl_type
*ret_type
;
6181 unsigned num_components
= image_type
->coordinate_components();
6183 /* From the ARB_shader_image_size extension:
6184 * "Cube images return the dimensions of one face."
6186 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
6187 !image_type
->sampler_array
) {
6191 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
6192 * supported by mesa.
6194 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
6196 ir_variable
*image
= in_var(image_type
, "image");
6197 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
6199 /* Set the maximal set of qualifiers allowed for this image
6200 * built-in. Function calls with arguments having fewer
6201 * qualifiers than present in the prototype are allowed by the
6202 * spec, but not with more, i.e. this will make the compiler
6203 * accept everything that needs to be accepted, and reject cases
6204 * like loads from write-only or stores to read-only images.
6206 image
->data
.memory_read_only
= true;
6207 image
->data
.memory_write_only
= true;
6208 image
->data
.memory_coherent
= true;
6209 image
->data
.memory_volatile
= true;
6210 image
->data
.memory_restrict
= true;
6215 ir_function_signature
*
6216 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
6217 unsigned /* num_arguments */,
6218 unsigned /* flags */)
6220 ir_variable
*image
= in_var(image_type
, "image");
6221 ir_function_signature
*sig
=
6222 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
6224 /* Set the maximal set of qualifiers allowed for this image
6225 * built-in. Function calls with arguments having fewer
6226 * qualifiers than present in the prototype are allowed by the
6227 * spec, but not with more, i.e. this will make the compiler
6228 * accept everything that needs to be accepted, and reject cases
6229 * like loads from write-only or stores to read-only images.
6231 image
->data
.memory_read_only
= true;
6232 image
->data
.memory_write_only
= true;
6233 image
->data
.memory_coherent
= true;
6234 image
->data
.memory_volatile
= true;
6235 image
->data
.memory_restrict
= true;
6240 ir_function_signature
*
6241 builtin_builder::_image(image_prototype_ctr prototype
,
6242 const glsl_type
*image_type
,
6243 const char *intrinsic_name
,
6244 unsigned num_arguments
,
6246 enum ir_intrinsic_id id
)
6248 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
6249 num_arguments
, flags
);
6251 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
6252 ir_factory
body(&sig
->body
, mem_ctx
);
6253 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
6255 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
6256 body
.emit(call(f
, NULL
, sig
->parameters
));
6258 ir_variable
*ret_val
=
6259 body
.make_temp(sig
->return_type
, "_ret_val");
6260 body
.emit(call(f
, ret_val
, sig
->parameters
));
6261 body
.emit(ret(ret_val
));
6264 sig
->is_defined
= true;
6267 sig
->intrinsic_id
= id
;
6273 ir_function_signature
*
6274 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
,
6275 enum ir_intrinsic_id id
)
6277 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6281 ir_function_signature
*
6282 builtin_builder::_memory_barrier(const char *intrinsic_name
,
6283 builtin_available_predicate avail
)
6285 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6286 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6287 NULL
, sig
->parameters
));
6291 ir_function_signature
*
6292 builtin_builder::_ballot_intrinsic()
6294 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6295 MAKE_INTRINSIC(glsl_type::uint64_t_type
, ir_intrinsic_ballot
, shader_ballot
,
6300 ir_function_signature
*
6301 builtin_builder::_ballot()
6303 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6305 MAKE_SIG(glsl_type::uint64_t_type
, shader_ballot
, 1, value
);
6306 ir_variable
*retval
= body
.make_temp(glsl_type::uint64_t_type
, "retval");
6308 body
.emit(call(shader
->symbols
->get_function("__intrinsic_ballot"),
6309 retval
, sig
->parameters
));
6310 body
.emit(ret(retval
));
6314 ir_function_signature
*
6315 builtin_builder::_read_first_invocation_intrinsic(const glsl_type
*type
)
6317 ir_variable
*value
= in_var(type
, "value");
6318 MAKE_INTRINSIC(type
, ir_intrinsic_read_first_invocation
, shader_ballot
,
6323 ir_function_signature
*
6324 builtin_builder::_read_first_invocation(const glsl_type
*type
)
6326 ir_variable
*value
= in_var(type
, "value");
6328 MAKE_SIG(type
, shader_ballot
, 1, value
);
6329 ir_variable
*retval
= body
.make_temp(type
, "retval");
6331 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_first_invocation"),
6332 retval
, sig
->parameters
));
6333 body
.emit(ret(retval
));
6337 ir_function_signature
*
6338 builtin_builder::_read_invocation_intrinsic(const glsl_type
*type
)
6340 ir_variable
*value
= in_var(type
, "value");
6341 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6342 MAKE_INTRINSIC(type
, ir_intrinsic_read_invocation
, shader_ballot
,
6343 2, value
, invocation
);
6347 ir_function_signature
*
6348 builtin_builder::_read_invocation(const glsl_type
*type
)
6350 ir_variable
*value
= in_var(type
, "value");
6351 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6353 MAKE_SIG(type
, shader_ballot
, 2, value
, invocation
);
6354 ir_variable
*retval
= body
.make_temp(type
, "retval");
6356 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_invocation"),
6357 retval
, sig
->parameters
));
6358 body
.emit(ret(retval
));
6362 ir_function_signature
*
6363 builtin_builder::_invocation_interlock_intrinsic(builtin_available_predicate avail
,
6364 enum ir_intrinsic_id id
)
6366 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6370 ir_function_signature
*
6371 builtin_builder::_invocation_interlock(const char *intrinsic_name
,
6372 builtin_available_predicate avail
)
6374 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6375 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6376 NULL
, sig
->parameters
));
6380 ir_function_signature
*
6381 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
6382 const glsl_type
*type
)
6384 MAKE_INTRINSIC(type
, ir_intrinsic_shader_clock
, avail
, 0);
6388 ir_function_signature
*
6389 builtin_builder::_shader_clock(builtin_available_predicate avail
,
6390 const glsl_type
*type
)
6392 MAKE_SIG(type
, avail
, 0);
6394 ir_variable
*retval
= body
.make_temp(glsl_type::uvec2_type
, "clock_retval");
6396 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
6397 retval
, sig
->parameters
));
6399 if (type
== glsl_type::uint64_t_type
) {
6400 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, retval
)));
6402 body
.emit(ret(retval
));
6408 ir_function_signature
*
6409 builtin_builder::_vote_intrinsic(builtin_available_predicate avail
,
6410 enum ir_intrinsic_id id
)
6412 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6413 MAKE_INTRINSIC(glsl_type::bool_type
, id
, avail
, 1, value
);
6417 ir_function_signature
*
6418 builtin_builder::_vote(const char *intrinsic_name
,
6419 builtin_available_predicate avail
)
6421 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6423 MAKE_SIG(glsl_type::bool_type
, avail
, 1, value
);
6425 ir_variable
*retval
= body
.make_temp(glsl_type::bool_type
, "retval");
6427 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6428 retval
, sig
->parameters
));
6429 body
.emit(ret(retval
));
6435 /******************************************************************************/
6437 /* The singleton instance of builtin_builder. */
6438 static builtin_builder builtins
;
6439 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
6442 * External API (exposing the built-in module to the rest of the compiler):
6446 _mesa_glsl_initialize_builtin_functions()
6448 mtx_lock(&builtins_lock
);
6449 builtins
.initialize();
6450 mtx_unlock(&builtins_lock
);
6454 _mesa_glsl_release_builtin_functions()
6456 mtx_lock(&builtins_lock
);
6458 mtx_unlock(&builtins_lock
);
6461 ir_function_signature
*
6462 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
6463 const char *name
, exec_list
*actual_parameters
)
6465 ir_function_signature
*s
;
6466 mtx_lock(&builtins_lock
);
6467 s
= builtins
.find(state
, name
, actual_parameters
);
6468 mtx_unlock(&builtins_lock
);
6474 _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state
*state
, const char *name
)
6478 mtx_lock(&builtins_lock
);
6479 f
= builtins
.shader
->symbols
->get_function(name
);
6481 foreach_in_list(ir_function_signature
, sig
, &f
->signatures
) {
6482 if (sig
->is_builtin_available(state
)) {
6488 mtx_unlock(&builtins_lock
);
6494 _mesa_glsl_get_builtin_function_shader()
6496 return builtins
.shader
;
6501 * Get the function signature for main from a shader
6503 ir_function_signature
*
6504 _mesa_get_main_function_signature(glsl_symbol_table
*symbols
)
6506 ir_function
*const f
= symbols
->get_function("main");
6508 exec_list void_parameters
;
6510 /* Look for the 'void main()' signature and ensure that it's defined.
6511 * This keeps the linker from accidentally pick a shader that just
6512 * contains a prototype for main.
6514 * We don't have to check for multiple definitions of main (in multiple
6515 * shaders) because that would have already been caught above.
6517 ir_function_signature
*sig
=
6518 f
->matching_signature(NULL
, &void_parameters
, false);
6519 if ((sig
!= NULL
) && sig
->is_defined
) {