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/core.h" /* for struct gl_shader */
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
->language_version
<= 130 &&
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 v130_fs_only(const _mesa_glsl_parse_state
*state
)
156 return state
->is_version(130, 300) &&
157 state
->stage
== MESA_SHADER_FRAGMENT
;
161 v140_or_es3(const _mesa_glsl_parse_state
*state
)
163 return state
->is_version(140, 300);
167 v400_fs_only(const _mesa_glsl_parse_state
*state
)
169 return state
->is_version(400, 0) &&
170 state
->stage
== MESA_SHADER_FRAGMENT
;
174 texture_rectangle(const _mesa_glsl_parse_state
*state
)
176 return state
->ARB_texture_rectangle_enable
;
180 texture_external(const _mesa_glsl_parse_state
*state
)
182 return state
->OES_EGL_image_external_enable
;
185 /** True if texturing functions with explicit LOD are allowed. */
187 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
189 /* Texturing functions with "Lod" in their name exist:
190 * - In the vertex shader stage (for all languages)
191 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
192 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
194 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
195 * don't need to explicitly check state->es_shader.
197 return state
->stage
== MESA_SHADER_VERTEX
||
198 state
->is_version(130, 300) ||
199 state
->ARB_shader_texture_lod_enable
;
203 v110_lod(const _mesa_glsl_parse_state
*state
)
205 return !state
->es_shader
&& lod_exists_in_stage(state
);
209 texture_buffer(const _mesa_glsl_parse_state
*state
)
211 return state
->is_version(140, 320) ||
212 state
->EXT_texture_buffer_enable
||
213 state
->OES_texture_buffer_enable
;
217 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
219 return state
->ARB_shader_texture_lod_enable
;
223 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
225 return state
->ARB_shader_texture_lod_enable
&&
226 state
->ARB_texture_rectangle_enable
;
230 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
232 return state
->is_version(330, 300) ||
233 state
->ARB_shader_bit_encoding_enable
||
234 state
->ARB_gpu_shader5_enable
;
238 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
240 return state
->is_version(450, 310) ||
241 state
->ARB_ES3_1_compatibility_enable
||
242 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
246 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
248 return state
->ARB_shading_language_packing_enable
||
249 state
->is_version(420, 300);
253 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
255 return state
->ARB_shading_language_packing_enable
||
256 state
->ARB_gpu_shader5_enable
||
257 state
->is_version(400, 300);
261 gpu_shader5(const _mesa_glsl_parse_state
*state
)
263 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
267 gpu_shader5_es(const _mesa_glsl_parse_state
*state
)
269 return state
->is_version(400, 320) ||
270 state
->ARB_gpu_shader5_enable
||
271 state
->EXT_gpu_shader5_enable
||
272 state
->OES_gpu_shader5_enable
;
276 gpu_shader5_or_OES_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
278 return state
->is_version(400, 320) ||
279 state
->ARB_gpu_shader5_enable
||
280 state
->EXT_texture_cube_map_array_enable
||
281 state
->OES_texture_cube_map_array_enable
;
285 es31_not_gs5(const _mesa_glsl_parse_state
*state
)
287 return state
->is_version(0, 310) && !gpu_shader5_es(state
);
291 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
293 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
297 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
299 return state
->ARB_shading_language_packing_enable
||
300 state
->ARB_gpu_shader5_enable
||
301 state
->is_version(400, 310);
305 gpu_shader5_or_es31_or_integer_functions(const _mesa_glsl_parse_state
*state
)
307 return gpu_shader5_or_es31(state
) ||
308 state
->MESA_shader_integer_functions_enable
;
312 fs_interpolate_at(const _mesa_glsl_parse_state
*state
)
314 return state
->stage
== MESA_SHADER_FRAGMENT
&&
315 (state
->is_version(400, 320) ||
316 state
->ARB_gpu_shader5_enable
||
317 state
->OES_shader_multisample_interpolation_enable
);
322 texture_array_lod(const _mesa_glsl_parse_state
*state
)
324 return lod_exists_in_stage(state
) &&
325 state
->EXT_texture_array_enable
;
329 fs_texture_array(const _mesa_glsl_parse_state
*state
)
331 return state
->stage
== MESA_SHADER_FRAGMENT
&&
332 state
->EXT_texture_array_enable
;
336 texture_array(const _mesa_glsl_parse_state
*state
)
338 return state
->EXT_texture_array_enable
;
342 texture_multisample(const _mesa_glsl_parse_state
*state
)
344 return state
->is_version(150, 310) ||
345 state
->ARB_texture_multisample_enable
;
349 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
351 return state
->is_version(150, 320) ||
352 state
->ARB_texture_multisample_enable
||
353 state
->OES_texture_storage_multisample_2d_array_enable
;
357 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
359 return texture_multisample(state
) &&
360 state
->EXT_shader_samples_identical_enable
;
364 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
366 return texture_multisample_array(state
) &&
367 state
->EXT_shader_samples_identical_enable
;
371 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
373 return state
->stage
== MESA_SHADER_FRAGMENT
&&
374 state
->has_texture_cube_map_array();
378 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
380 return state
->has_texture_cube_map_array();
384 texture_query_levels(const _mesa_glsl_parse_state
*state
)
386 return state
->is_version(430, 0) ||
387 state
->ARB_texture_query_levels_enable
;
391 texture_query_lod(const _mesa_glsl_parse_state
*state
)
393 return state
->stage
== MESA_SHADER_FRAGMENT
&&
394 state
->ARB_texture_query_lod_enable
;
398 texture_gather_cube_map_array(const _mesa_glsl_parse_state
*state
)
400 return state
->is_version(400, 320) ||
401 state
->ARB_texture_gather_enable
||
402 state
->ARB_gpu_shader5_enable
||
403 state
->EXT_texture_cube_map_array_enable
||
404 state
->OES_texture_cube_map_array_enable
;
408 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
410 return state
->is_version(400, 310) ||
411 state
->ARB_texture_gather_enable
||
412 state
->ARB_gpu_shader5_enable
;
415 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
416 * used for relaxation of const offset requirements.
419 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
421 return !state
->is_version(400, 320) &&
422 !state
->ARB_gpu_shader5_enable
&&
423 !state
->EXT_gpu_shader5_enable
&&
424 !state
->OES_gpu_shader5_enable
&&
425 (state
->ARB_texture_gather_enable
||
426 state
->is_version(0, 310));
429 /* Desktop GL or OES_standard_derivatives + fragment shader only */
431 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
433 return state
->stage
== MESA_SHADER_FRAGMENT
&&
434 (state
->is_version(110, 300) ||
435 state
->OES_standard_derivatives_enable
);
439 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
441 return state
->stage
== MESA_SHADER_FRAGMENT
&&
442 (state
->is_version(450, 0) ||
443 state
->ARB_derivative_control_enable
);
447 tex1d_lod(const _mesa_glsl_parse_state
*state
)
449 return !state
->es_shader
&& lod_exists_in_stage(state
);
452 /** True if sampler3D exists */
454 tex3d(const _mesa_glsl_parse_state
*state
)
456 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
457 * OES_texture_3D extension, and in GLSL ES 3.00.
459 return !state
->es_shader
||
460 state
->OES_texture_3D_enable
||
461 state
->language_version
>= 300;
465 fs_tex3d(const _mesa_glsl_parse_state
*state
)
467 return state
->stage
== MESA_SHADER_FRAGMENT
&&
468 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
472 tex3d_lod(const _mesa_glsl_parse_state
*state
)
474 return tex3d(state
) && lod_exists_in_stage(state
);
478 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
480 return state
->has_atomic_counters();
484 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
486 return state
->ARB_shader_atomic_counter_ops_enable
;
490 shader_ballot(const _mesa_glsl_parse_state
*state
)
492 return state
->ARB_shader_ballot_enable
;
496 shader_clock(const _mesa_glsl_parse_state
*state
)
498 return state
->ARB_shader_clock_enable
;
502 shader_clock_int64(const _mesa_glsl_parse_state
*state
)
504 return state
->ARB_shader_clock_enable
&&
505 state
->ARB_gpu_shader_int64_enable
;
509 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
511 return state
->has_shader_storage_buffer_objects();
515 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
517 return state
->AMD_shader_trinary_minmax_enable
;
521 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
523 return (state
->is_version(420, 310) ||
524 state
->ARB_shader_image_load_store_enable
);
528 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
530 return (state
->is_version(420, 320) ||
531 state
->ARB_shader_image_load_store_enable
||
532 state
->OES_shader_image_atomic_enable
);
536 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
538 return (state
->is_version(450, 320) ||
539 state
->ARB_ES3_1_compatibility_enable
||
540 state
->OES_shader_image_atomic_enable
);
544 shader_image_size(const _mesa_glsl_parse_state
*state
)
546 return state
->is_version(430, 310) ||
547 state
->ARB_shader_image_size_enable
;
551 shader_samples(const _mesa_glsl_parse_state
*state
)
553 return state
->is_version(450, 0) ||
554 state
->ARB_shader_texture_image_samples_enable
;
558 gs_streams(const _mesa_glsl_parse_state
*state
)
560 return gpu_shader5(state
) && gs_only(state
);
564 fp64(const _mesa_glsl_parse_state
*state
)
566 return state
->has_double();
570 int64(const _mesa_glsl_parse_state
*state
)
572 return state
->has_int64();
576 int64_fp64(const _mesa_glsl_parse_state
*state
)
578 return state
->has_int64() && state
->has_double();
582 compute_shader(const _mesa_glsl_parse_state
*state
)
584 return state
->stage
== MESA_SHADER_COMPUTE
;
588 compute_shader_supported(const _mesa_glsl_parse_state
*state
)
590 return state
->has_compute_shader();
594 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
596 return compute_shader(state
) || shader_storage_buffer_object(state
);
600 barrier_supported(const _mesa_glsl_parse_state
*state
)
602 return compute_shader(state
) ||
603 state
->stage
== MESA_SHADER_TESS_CTRL
;
607 vote(const _mesa_glsl_parse_state
*state
)
609 return state
->ARB_shader_group_vote_enable
;
613 integer_functions_supported(const _mesa_glsl_parse_state
*state
)
615 return state
->extensions
->MESA_shader_integer_functions
;
619 /******************************************************************************/
624 * builtin_builder: A singleton object representing the core of the built-in
627 * It generates IR for every built-in function signature, and organizes them
630 class builtin_builder
{
637 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
638 const char *name
, exec_list
*actual_parameters
);
641 * A shader to hold all the built-in signatures; created by this module.
643 * This includes signatures for every built-in, regardless of version or
644 * enabled extensions. The availability predicate associated with each
645 * signature allows matching_signature() to filter out the irrelevant ones.
652 void create_shader();
653 void create_intrinsics();
654 void create_builtins();
657 * IR builder helpers:
659 * These convenience functions assist in emitting IR, but don't necessarily
660 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
663 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
664 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
665 ir_constant
*imm(float f
, unsigned vector_elements
=1);
666 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
667 ir_constant
*imm(int i
, unsigned vector_elements
=1);
668 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
669 ir_constant
*imm(double d
, unsigned vector_elements
=1);
670 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
671 ir_dereference_variable
*var_ref(ir_variable
*var
);
672 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
673 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
675 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
676 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
679 * Call function \param f with parameters specified as the linked
680 * list \param params of \c ir_variable objects. \param ret should
681 * point to the ir_variable that will hold the function return
682 * value, or be \c NULL if the function has void return type.
684 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
686 /** Create a new function and add the given signatures. */
687 void add_function(const char *name
, ...);
689 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
690 unsigned num_arguments
,
694 * Create a new image built-in function for all known image types.
695 * \p flags is a bitfield of \c image_function_flags flags.
697 void add_image_function(const char *name
,
698 const char *intrinsic_name
,
699 image_prototype_ctr prototype
,
700 unsigned num_arguments
,
702 enum ir_intrinsic_id id
);
705 * Create new functions for all known image built-ins and types.
706 * If \p glsl is \c true, use the GLSL built-in names and emit code
707 * to call into the actual compiler intrinsic. If \p glsl is
708 * false, emit a function prototype with no body for each image
711 void add_image_functions(bool glsl
);
713 ir_function_signature
*new_sig(const glsl_type
*return_type
,
714 builtin_available_predicate avail
,
715 int num_params
, ...);
718 * Function signature generators:
721 ir_function_signature
*unop(builtin_available_predicate avail
,
722 ir_expression_operation opcode
,
723 const glsl_type
*return_type
,
724 const glsl_type
*param_type
);
725 ir_function_signature
*binop(builtin_available_predicate avail
,
726 ir_expression_operation opcode
,
727 const glsl_type
*return_type
,
728 const glsl_type
*param0_type
,
729 const glsl_type
*param1_type
);
731 #define B0(X) ir_function_signature *_##X();
732 #define B1(X) ir_function_signature *_##X(const glsl_type *);
733 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
734 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
735 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
736 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
773 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
774 const glsl_type
*val_type
,
775 const glsl_type
*blend_type
);
785 BA1(doubleBitsToInt64
)
786 BA1(doubleBitsToUint64
)
787 BA1(int64BitsToDouble
)
788 BA1(uint64BitsToDouble
)
790 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
791 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
792 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
793 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
794 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
795 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
796 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
797 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
798 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
799 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
800 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
801 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
802 ir_function_signature
*_packInt2x32(builtin_available_predicate avail
);
803 ir_function_signature
*_unpackInt2x32(builtin_available_predicate avail
);
804 ir_function_signature
*_packUint2x32(builtin_available_predicate avail
);
805 ir_function_signature
*_unpackUint2x32(builtin_available_predicate avail
);
818 BA1(determinant_mat2
);
819 BA1(determinant_mat3
);
820 BA1(determinant_mat4
);
828 BA1(greaterThanEqual
);
837 /** Flags to _texture() */
838 #define TEX_PROJECT 1
840 #define TEX_COMPONENT 4
841 #define TEX_OFFSET_NONCONST 8
842 #define TEX_OFFSET_ARRAY 16
844 ir_function_signature
*_texture(ir_texture_opcode opcode
,
845 builtin_available_predicate avail
,
846 const glsl_type
*return_type
,
847 const glsl_type
*sampler_type
,
848 const glsl_type
*coord_type
,
850 BA1(textureCubeArrayShadow
);
851 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
852 const glsl_type
*return_type
,
853 const glsl_type
*sampler_type
,
854 const glsl_type
*coord_type
,
855 const glsl_type
*offset_type
= NULL
);
859 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
860 const glsl_type
*stream_type
);
861 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
862 const glsl_type
*stream_type
);
865 BA2(textureQueryLod
);
866 BA1(textureQueryLevels
);
867 BA2(textureSamplesIdentical
);
895 B1(interpolateAtCentroid
)
896 B1(interpolateAtOffset
)
897 B1(interpolateAtSample
)
899 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
,
900 enum ir_intrinsic_id id
);
901 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
,
902 enum ir_intrinsic_id id
);
903 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
,
904 enum ir_intrinsic_id id
);
905 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
906 builtin_available_predicate avail
);
907 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
908 builtin_available_predicate avail
);
909 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
910 builtin_available_predicate avail
);
912 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
913 const glsl_type
*type
,
914 enum ir_intrinsic_id id
);
915 ir_function_signature
*_atomic_op2(const char *intrinsic
,
916 builtin_available_predicate avail
,
917 const glsl_type
*type
);
918 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
919 const glsl_type
*type
,
920 enum ir_intrinsic_id id
);
921 ir_function_signature
*_atomic_op3(const char *intrinsic
,
922 builtin_available_predicate avail
,
923 const glsl_type
*type
);
929 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
930 unsigned num_arguments
,
932 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
933 unsigned num_arguments
,
935 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
936 unsigned num_arguments
,
938 ir_function_signature
*_image(image_prototype_ctr prototype
,
939 const glsl_type
*image_type
,
940 const char *intrinsic_name
,
941 unsigned num_arguments
,
943 enum ir_intrinsic_id id
);
945 ir_function_signature
*_memory_barrier_intrinsic(
946 builtin_available_predicate avail
,
947 enum ir_intrinsic_id id
);
948 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
949 builtin_available_predicate avail
);
951 ir_function_signature
*_ballot();
952 ir_function_signature
*_read_first_invocation(const glsl_type
*type
);
953 ir_function_signature
*_read_invocation(const glsl_type
*type
);
955 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
956 const glsl_type
*type
);
957 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
958 const glsl_type
*type
);
960 ir_function_signature
*_vote_intrinsic(builtin_available_predicate avail
,
961 enum ir_intrinsic_id id
);
962 ir_function_signature
*_vote(const char *intrinsic_name
);
973 enum image_function_flags
{
974 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
975 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
976 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
977 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
978 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
979 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
980 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
981 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
982 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8)
985 } /* anonymous namespace */
988 * Core builtin_builder functionality:
991 builtin_builder::builtin_builder()
997 builtin_builder::~builtin_builder()
999 ralloc_free(mem_ctx
);
1002 ir_function_signature
*
1003 builtin_builder::find(_mesa_glsl_parse_state
*state
,
1004 const char *name
, exec_list
*actual_parameters
)
1006 /* The shader currently being compiled requested a built-in function;
1007 * it needs to link against builtin_builder::shader in order to get them.
1009 * Even if we don't find a matching signature, we still need to do this so
1010 * that the "no matching signature" error will list potential candidates
1011 * from the available built-ins.
1013 state
->uses_builtin_functions
= true;
1015 ir_function
*f
= shader
->symbols
->get_function(name
);
1019 ir_function_signature
*sig
=
1020 f
->matching_signature(state
, actual_parameters
, true);
1028 builtin_builder::initialize()
1030 /* If already initialized, don't do it again. */
1031 if (mem_ctx
!= NULL
)
1034 mem_ctx
= ralloc_context(NULL
);
1036 create_intrinsics();
1041 builtin_builder::release()
1043 ralloc_free(mem_ctx
);
1046 ralloc_free(shader
);
1051 builtin_builder::create_shader()
1053 /* The target doesn't actually matter. There's no target for generic
1054 * GLSL utility code that could be linked against any stage, so just
1055 * arbitrarily pick GL_VERTEX_SHADER.
1057 shader
= _mesa_new_shader(0, MESA_SHADER_VERTEX
);
1058 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
1064 * Create ir_function and ir_function_signature objects for each
1068 builtin_builder::create_intrinsics()
1070 add_function("__intrinsic_atomic_read",
1071 _atomic_counter_intrinsic(shader_atomic_counters
,
1072 ir_intrinsic_atomic_counter_read
),
1074 add_function("__intrinsic_atomic_increment",
1075 _atomic_counter_intrinsic(shader_atomic_counters
,
1076 ir_intrinsic_atomic_counter_increment
),
1078 add_function("__intrinsic_atomic_predecrement",
1079 _atomic_counter_intrinsic(shader_atomic_counters
,
1080 ir_intrinsic_atomic_counter_predecrement
),
1083 add_function("__intrinsic_atomic_add",
1084 _atomic_intrinsic2(buffer_atomics_supported
,
1085 glsl_type::uint_type
,
1086 ir_intrinsic_generic_atomic_add
),
1087 _atomic_intrinsic2(buffer_atomics_supported
,
1088 glsl_type::int_type
,
1089 ir_intrinsic_generic_atomic_add
),
1090 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1091 ir_intrinsic_atomic_counter_add
),
1093 add_function("__intrinsic_atomic_min",
1094 _atomic_intrinsic2(buffer_atomics_supported
,
1095 glsl_type::uint_type
,
1096 ir_intrinsic_generic_atomic_min
),
1097 _atomic_intrinsic2(buffer_atomics_supported
,
1098 glsl_type::int_type
,
1099 ir_intrinsic_generic_atomic_min
),
1100 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1101 ir_intrinsic_atomic_counter_min
),
1103 add_function("__intrinsic_atomic_max",
1104 _atomic_intrinsic2(buffer_atomics_supported
,
1105 glsl_type::uint_type
,
1106 ir_intrinsic_generic_atomic_max
),
1107 _atomic_intrinsic2(buffer_atomics_supported
,
1108 glsl_type::int_type
,
1109 ir_intrinsic_generic_atomic_max
),
1110 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1111 ir_intrinsic_atomic_counter_max
),
1113 add_function("__intrinsic_atomic_and",
1114 _atomic_intrinsic2(buffer_atomics_supported
,
1115 glsl_type::uint_type
,
1116 ir_intrinsic_generic_atomic_and
),
1117 _atomic_intrinsic2(buffer_atomics_supported
,
1118 glsl_type::int_type
,
1119 ir_intrinsic_generic_atomic_and
),
1120 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1121 ir_intrinsic_atomic_counter_and
),
1123 add_function("__intrinsic_atomic_or",
1124 _atomic_intrinsic2(buffer_atomics_supported
,
1125 glsl_type::uint_type
,
1126 ir_intrinsic_generic_atomic_or
),
1127 _atomic_intrinsic2(buffer_atomics_supported
,
1128 glsl_type::int_type
,
1129 ir_intrinsic_generic_atomic_or
),
1130 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1131 ir_intrinsic_atomic_counter_or
),
1133 add_function("__intrinsic_atomic_xor",
1134 _atomic_intrinsic2(buffer_atomics_supported
,
1135 glsl_type::uint_type
,
1136 ir_intrinsic_generic_atomic_xor
),
1137 _atomic_intrinsic2(buffer_atomics_supported
,
1138 glsl_type::int_type
,
1139 ir_intrinsic_generic_atomic_xor
),
1140 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1141 ir_intrinsic_atomic_counter_xor
),
1143 add_function("__intrinsic_atomic_exchange",
1144 _atomic_intrinsic2(buffer_atomics_supported
,
1145 glsl_type::uint_type
,
1146 ir_intrinsic_generic_atomic_exchange
),
1147 _atomic_intrinsic2(buffer_atomics_supported
,
1148 glsl_type::int_type
,
1149 ir_intrinsic_generic_atomic_exchange
),
1150 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1151 ir_intrinsic_atomic_counter_exchange
),
1153 add_function("__intrinsic_atomic_comp_swap",
1154 _atomic_intrinsic3(buffer_atomics_supported
,
1155 glsl_type::uint_type
,
1156 ir_intrinsic_generic_atomic_comp_swap
),
1157 _atomic_intrinsic3(buffer_atomics_supported
,
1158 glsl_type::int_type
,
1159 ir_intrinsic_generic_atomic_comp_swap
),
1160 _atomic_counter_intrinsic2(shader_atomic_counter_ops
,
1161 ir_intrinsic_atomic_counter_comp_swap
),
1164 add_image_functions(false);
1166 add_function("__intrinsic_memory_barrier",
1167 _memory_barrier_intrinsic(shader_image_load_store
,
1168 ir_intrinsic_memory_barrier
),
1170 add_function("__intrinsic_group_memory_barrier",
1171 _memory_barrier_intrinsic(compute_shader
,
1172 ir_intrinsic_group_memory_barrier
),
1174 add_function("__intrinsic_memory_barrier_atomic_counter",
1175 _memory_barrier_intrinsic(compute_shader_supported
,
1176 ir_intrinsic_memory_barrier_atomic_counter
),
1178 add_function("__intrinsic_memory_barrier_buffer",
1179 _memory_barrier_intrinsic(compute_shader_supported
,
1180 ir_intrinsic_memory_barrier_buffer
),
1182 add_function("__intrinsic_memory_barrier_image",
1183 _memory_barrier_intrinsic(compute_shader_supported
,
1184 ir_intrinsic_memory_barrier_image
),
1186 add_function("__intrinsic_memory_barrier_shared",
1187 _memory_barrier_intrinsic(compute_shader
,
1188 ir_intrinsic_memory_barrier_shared
),
1191 add_function("__intrinsic_shader_clock",
1192 _shader_clock_intrinsic(shader_clock
,
1193 glsl_type::uvec2_type
),
1196 add_function("__intrinsic_vote_all",
1197 _vote_intrinsic(vote
, ir_intrinsic_vote_all
),
1199 add_function("__intrinsic_vote_any",
1200 _vote_intrinsic(vote
, ir_intrinsic_vote_any
),
1202 add_function("__intrinsic_vote_eq",
1203 _vote_intrinsic(vote
, ir_intrinsic_vote_eq
),
1208 * Create ir_function and ir_function_signature objects for each built-in.
1210 * Contains a list of every available built-in.
1213 builtin_builder::create_builtins()
1216 add_function(#NAME, \
1217 _##NAME(glsl_type::float_type), \
1218 _##NAME(glsl_type::vec2_type), \
1219 _##NAME(glsl_type::vec3_type), \
1220 _##NAME(glsl_type::vec4_type), \
1224 add_function(#NAME, \
1225 _##NAME(always_available, glsl_type::float_type), \
1226 _##NAME(always_available, glsl_type::vec2_type), \
1227 _##NAME(always_available, glsl_type::vec3_type), \
1228 _##NAME(always_available, glsl_type::vec4_type), \
1229 _##NAME(fp64, glsl_type::double_type), \
1230 _##NAME(fp64, glsl_type::dvec2_type), \
1231 _##NAME(fp64, glsl_type::dvec3_type), \
1232 _##NAME(fp64, glsl_type::dvec4_type), \
1235 #define FD130(NAME) \
1236 add_function(#NAME, \
1237 _##NAME(v130, glsl_type::float_type), \
1238 _##NAME(v130, glsl_type::vec2_type), \
1239 _##NAME(v130, glsl_type::vec3_type), \
1240 _##NAME(v130, glsl_type::vec4_type), \
1241 _##NAME(fp64, glsl_type::double_type), \
1242 _##NAME(fp64, glsl_type::dvec2_type), \
1243 _##NAME(fp64, glsl_type::dvec3_type), \
1244 _##NAME(fp64, glsl_type::dvec4_type), \
1247 #define FDGS5(NAME) \
1248 add_function(#NAME, \
1249 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1250 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1251 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1252 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1253 _##NAME(fp64, glsl_type::double_type), \
1254 _##NAME(fp64, glsl_type::dvec2_type), \
1255 _##NAME(fp64, glsl_type::dvec3_type), \
1256 _##NAME(fp64, glsl_type::dvec4_type), \
1260 add_function(#NAME, \
1261 _##NAME(glsl_type::float_type), \
1262 _##NAME(glsl_type::vec2_type), \
1263 _##NAME(glsl_type::vec3_type), \
1264 _##NAME(glsl_type::vec4_type), \
1265 _##NAME(glsl_type::int_type), \
1266 _##NAME(glsl_type::ivec2_type), \
1267 _##NAME(glsl_type::ivec3_type), \
1268 _##NAME(glsl_type::ivec4_type), \
1271 #define FI64(NAME) \
1272 add_function(#NAME, \
1273 _##NAME(always_available, glsl_type::float_type), \
1274 _##NAME(always_available, glsl_type::vec2_type), \
1275 _##NAME(always_available, glsl_type::vec3_type), \
1276 _##NAME(always_available, glsl_type::vec4_type), \
1277 _##NAME(always_available, glsl_type::int_type), \
1278 _##NAME(always_available, glsl_type::ivec2_type), \
1279 _##NAME(always_available, glsl_type::ivec3_type), \
1280 _##NAME(always_available, glsl_type::ivec4_type), \
1281 _##NAME(fp64, glsl_type::double_type), \
1282 _##NAME(fp64, glsl_type::dvec2_type), \
1283 _##NAME(fp64, glsl_type::dvec3_type), \
1284 _##NAME(fp64, glsl_type::dvec4_type), \
1285 _##NAME(int64, glsl_type::int64_t_type), \
1286 _##NAME(int64, glsl_type::i64vec2_type), \
1287 _##NAME(int64, glsl_type::i64vec3_type), \
1288 _##NAME(int64, glsl_type::i64vec4_type), \
1291 #define FIUD_VEC(NAME) \
1292 add_function(#NAME, \
1293 _##NAME(always_available, glsl_type::vec2_type), \
1294 _##NAME(always_available, glsl_type::vec3_type), \
1295 _##NAME(always_available, glsl_type::vec4_type), \
1297 _##NAME(always_available, glsl_type::ivec2_type), \
1298 _##NAME(always_available, glsl_type::ivec3_type), \
1299 _##NAME(always_available, glsl_type::ivec4_type), \
1301 _##NAME(v130, glsl_type::uvec2_type), \
1302 _##NAME(v130, glsl_type::uvec3_type), \
1303 _##NAME(v130, glsl_type::uvec4_type), \
1304 _##NAME(fp64, glsl_type::dvec2_type), \
1305 _##NAME(fp64, glsl_type::dvec3_type), \
1306 _##NAME(fp64, glsl_type::dvec4_type), \
1307 _##NAME(int64, glsl_type::int64_t_type), \
1308 _##NAME(int64, glsl_type::i64vec2_type), \
1309 _##NAME(int64, glsl_type::i64vec3_type), \
1310 _##NAME(int64, glsl_type::i64vec4_type), \
1311 _##NAME(int64, glsl_type::uint64_t_type), \
1312 _##NAME(int64, glsl_type::u64vec2_type), \
1313 _##NAME(int64, glsl_type::u64vec3_type), \
1314 _##NAME(int64, glsl_type::u64vec4_type), \
1318 add_function(#NAME, \
1319 _##NAME(glsl_type::int_type), \
1320 _##NAME(glsl_type::ivec2_type), \
1321 _##NAME(glsl_type::ivec3_type), \
1322 _##NAME(glsl_type::ivec4_type), \
1324 _##NAME(glsl_type::uint_type), \
1325 _##NAME(glsl_type::uvec2_type), \
1326 _##NAME(glsl_type::uvec3_type), \
1327 _##NAME(glsl_type::uvec4_type), \
1330 #define FIUBD_VEC(NAME) \
1331 add_function(#NAME, \
1332 _##NAME(always_available, glsl_type::vec2_type), \
1333 _##NAME(always_available, glsl_type::vec3_type), \
1334 _##NAME(always_available, glsl_type::vec4_type), \
1336 _##NAME(always_available, glsl_type::ivec2_type), \
1337 _##NAME(always_available, glsl_type::ivec3_type), \
1338 _##NAME(always_available, glsl_type::ivec4_type), \
1340 _##NAME(v130, glsl_type::uvec2_type), \
1341 _##NAME(v130, glsl_type::uvec3_type), \
1342 _##NAME(v130, glsl_type::uvec4_type), \
1344 _##NAME(always_available, glsl_type::bvec2_type), \
1345 _##NAME(always_available, glsl_type::bvec3_type), \
1346 _##NAME(always_available, glsl_type::bvec4_type), \
1348 _##NAME(fp64, glsl_type::dvec2_type), \
1349 _##NAME(fp64, glsl_type::dvec3_type), \
1350 _##NAME(fp64, glsl_type::dvec4_type), \
1351 _##NAME(int64, glsl_type::int64_t_type), \
1352 _##NAME(int64, glsl_type::i64vec2_type), \
1353 _##NAME(int64, glsl_type::i64vec3_type), \
1354 _##NAME(int64, glsl_type::i64vec4_type), \
1355 _##NAME(int64, glsl_type::uint64_t_type), \
1356 _##NAME(int64, glsl_type::u64vec2_type), \
1357 _##NAME(int64, glsl_type::u64vec3_type), \
1358 _##NAME(int64, glsl_type::u64vec4_type), \
1361 #define FIUD2_MIXED(NAME) \
1362 add_function(#NAME, \
1363 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1364 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1365 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1366 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1368 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1369 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1370 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1372 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1373 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1374 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1375 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1377 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1378 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1379 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1381 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1382 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1383 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1384 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1386 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1387 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1388 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1390 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1391 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1392 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1393 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1394 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1395 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1396 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1398 _##NAME(int64, glsl_type::int64_t_type, glsl_type::int64_t_type), \
1399 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::int64_t_type), \
1400 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::int64_t_type), \
1401 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::int64_t_type), \
1402 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::i64vec2_type), \
1403 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::i64vec3_type), \
1404 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::i64vec4_type), \
1405 _##NAME(int64, glsl_type::uint64_t_type, glsl_type::uint64_t_type), \
1406 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::uint64_t_type), \
1407 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::uint64_t_type), \
1408 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::uint64_t_type), \
1409 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::u64vec2_type), \
1410 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::u64vec3_type), \
1411 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::u64vec4_type), \
1422 add_function("atan",
1423 _atan(glsl_type::float_type
),
1424 _atan(glsl_type::vec2_type
),
1425 _atan(glsl_type::vec3_type
),
1426 _atan(glsl_type::vec4_type
),
1427 _atan2(glsl_type::float_type
),
1428 _atan2(glsl_type::vec2_type
),
1429 _atan2(glsl_type::vec3_type
),
1430 _atan2(glsl_type::vec4_type
),
1456 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1457 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1458 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1459 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1461 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1462 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1463 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1465 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1466 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1467 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1468 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1470 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1471 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1472 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1482 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1483 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1484 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1485 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1487 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1488 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1489 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1491 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1492 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1493 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1494 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1496 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1497 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1498 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1500 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1501 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1502 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1503 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1505 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1506 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1507 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1508 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1510 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1511 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1512 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1513 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1515 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1516 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1517 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1518 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1520 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1521 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1522 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1523 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1525 _mix_sel(int64
, glsl_type::int64_t_type
, glsl_type::bool_type
),
1526 _mix_sel(int64
, glsl_type::i64vec2_type
, glsl_type::bvec2_type
),
1527 _mix_sel(int64
, glsl_type::i64vec3_type
, glsl_type::bvec3_type
),
1528 _mix_sel(int64
, glsl_type::i64vec4_type
, glsl_type::bvec4_type
),
1530 _mix_sel(int64
, glsl_type::uint64_t_type
, glsl_type::bool_type
),
1531 _mix_sel(int64
, glsl_type::u64vec2_type
, glsl_type::bvec2_type
),
1532 _mix_sel(int64
, glsl_type::u64vec3_type
, glsl_type::bvec3_type
),
1533 _mix_sel(int64
, glsl_type::u64vec4_type
, glsl_type::bvec4_type
),
1536 add_function("step",
1537 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1538 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1539 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1540 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1542 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1543 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1544 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1545 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1546 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1547 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1548 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1550 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1551 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1552 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1555 add_function("smoothstep",
1556 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1557 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1558 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1559 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1561 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1562 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1563 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1564 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1565 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1566 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1567 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1569 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1570 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1571 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1579 add_function("intBitsToFloat",
1580 _intBitsToFloat(glsl_type::int_type
),
1581 _intBitsToFloat(glsl_type::ivec2_type
),
1582 _intBitsToFloat(glsl_type::ivec3_type
),
1583 _intBitsToFloat(glsl_type::ivec4_type
),
1585 add_function("uintBitsToFloat",
1586 _uintBitsToFloat(glsl_type::uint_type
),
1587 _uintBitsToFloat(glsl_type::uvec2_type
),
1588 _uintBitsToFloat(glsl_type::uvec3_type
),
1589 _uintBitsToFloat(glsl_type::uvec4_type
),
1592 add_function("doubleBitsToInt64",
1593 _doubleBitsToInt64(int64_fp64
, glsl_type::double_type
),
1594 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec2_type
),
1595 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec3_type
),
1596 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec4_type
),
1599 add_function("doubleBitsToUint64",
1600 _doubleBitsToUint64(int64_fp64
, glsl_type::double_type
),
1601 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec2_type
),
1602 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec3_type
),
1603 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec4_type
),
1606 add_function("int64BitsToDouble",
1607 _int64BitsToDouble(int64_fp64
, glsl_type::int64_t_type
),
1608 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec2_type
),
1609 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec3_type
),
1610 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec4_type
),
1613 add_function("uint64BitsToDouble",
1614 _uint64BitsToDouble(int64_fp64
, glsl_type::uint64_t_type
),
1615 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec2_type
),
1616 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec3_type
),
1617 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec4_type
),
1620 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1621 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1622 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1623 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1624 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1625 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1626 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1627 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1628 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1629 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1630 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1631 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1633 add_function("packInt2x32", _packInt2x32(int64
), NULL
);
1634 add_function("unpackInt2x32", _unpackInt2x32(int64
), NULL
);
1635 add_function("packUint2x32", _packUint2x32(int64
), NULL
);
1636 add_function("unpackUint2x32", _unpackUint2x32(int64
), NULL
);
1642 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1643 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1646 add_function("ftransform", _ftransform(), NULL
);
1651 add_function("matrixCompMult",
1652 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1653 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1654 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1655 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1656 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1657 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1658 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1659 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1660 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1661 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1662 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1663 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1664 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1665 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1666 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1667 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1668 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1669 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1671 add_function("outerProduct",
1672 _outerProduct(v120
, glsl_type::mat2_type
),
1673 _outerProduct(v120
, glsl_type::mat3_type
),
1674 _outerProduct(v120
, glsl_type::mat4_type
),
1675 _outerProduct(v120
, glsl_type::mat2x3_type
),
1676 _outerProduct(v120
, glsl_type::mat2x4_type
),
1677 _outerProduct(v120
, glsl_type::mat3x2_type
),
1678 _outerProduct(v120
, glsl_type::mat3x4_type
),
1679 _outerProduct(v120
, glsl_type::mat4x2_type
),
1680 _outerProduct(v120
, glsl_type::mat4x3_type
),
1681 _outerProduct(fp64
, glsl_type::dmat2_type
),
1682 _outerProduct(fp64
, glsl_type::dmat3_type
),
1683 _outerProduct(fp64
, glsl_type::dmat4_type
),
1684 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1685 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1686 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1687 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1688 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1689 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1691 add_function("determinant",
1692 _determinant_mat2(v120
, glsl_type::mat2_type
),
1693 _determinant_mat3(v120
, glsl_type::mat3_type
),
1694 _determinant_mat4(v120
, glsl_type::mat4_type
),
1695 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1696 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1697 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1700 add_function("inverse",
1701 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1702 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1703 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1704 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1705 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1706 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1708 add_function("transpose",
1709 _transpose(v120
, glsl_type::mat2_type
),
1710 _transpose(v120
, glsl_type::mat3_type
),
1711 _transpose(v120
, glsl_type::mat4_type
),
1712 _transpose(v120
, glsl_type::mat2x3_type
),
1713 _transpose(v120
, glsl_type::mat2x4_type
),
1714 _transpose(v120
, glsl_type::mat3x2_type
),
1715 _transpose(v120
, glsl_type::mat3x4_type
),
1716 _transpose(v120
, glsl_type::mat4x2_type
),
1717 _transpose(v120
, glsl_type::mat4x3_type
),
1718 _transpose(fp64
, glsl_type::dmat2_type
),
1719 _transpose(fp64
, glsl_type::dmat3_type
),
1720 _transpose(fp64
, glsl_type::dmat4_type
),
1721 _transpose(fp64
, glsl_type::dmat2x3_type
),
1722 _transpose(fp64
, glsl_type::dmat2x4_type
),
1723 _transpose(fp64
, glsl_type::dmat3x2_type
),
1724 _transpose(fp64
, glsl_type::dmat3x4_type
),
1725 _transpose(fp64
, glsl_type::dmat4x2_type
),
1726 _transpose(fp64
, glsl_type::dmat4x3_type
),
1729 FIUD_VEC(lessThanEqual
)
1730 FIUD_VEC(greaterThan
)
1731 FIUD_VEC(greaterThanEqual
)
1736 _any(glsl_type::bvec2_type
),
1737 _any(glsl_type::bvec3_type
),
1738 _any(glsl_type::bvec4_type
),
1742 _all(glsl_type::bvec2_type
),
1743 _all(glsl_type::bvec3_type
),
1744 _all(glsl_type::bvec4_type
),
1748 _not(glsl_type::bvec2_type
),
1749 _not(glsl_type::bvec3_type
),
1750 _not(glsl_type::bvec4_type
),
1753 add_function("textureSize",
1754 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1755 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1756 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1758 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1759 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1760 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1762 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1763 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1764 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1766 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1767 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1768 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1770 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1771 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1772 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1774 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1775 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1776 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1777 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1778 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1779 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1781 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1782 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1784 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1785 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1786 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1787 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1789 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1790 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1791 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1792 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1794 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1795 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1796 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1797 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1798 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1799 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1801 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1802 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1803 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1806 add_function("textureSamples",
1807 _textureSamples(shader_samples
, glsl_type::sampler2DMS_type
),
1808 _textureSamples(shader_samples
, glsl_type::isampler2DMS_type
),
1809 _textureSamples(shader_samples
, glsl_type::usampler2DMS_type
),
1811 _textureSamples(shader_samples
, glsl_type::sampler2DMSArray_type
),
1812 _textureSamples(shader_samples
, glsl_type::isampler2DMSArray_type
),
1813 _textureSamples(shader_samples
, glsl_type::usampler2DMSArray_type
),
1816 add_function("texture",
1817 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1818 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1819 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1821 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1822 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1823 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1825 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1826 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1827 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1829 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1830 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1831 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1833 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1834 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1835 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1837 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1838 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1839 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1841 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1842 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1843 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1845 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1846 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1847 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1849 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1850 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1851 /* samplerCubeArrayShadow is special; it has an extra parameter
1852 * for the shadow comparator since there is no vec5 type.
1854 _textureCubeArrayShadow(texture_cube_map_array
, glsl_type::samplerCubeArrayShadow_type
),
1856 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1857 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1858 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1860 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1862 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1863 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1864 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1866 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1867 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1868 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1870 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1871 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1872 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1874 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1875 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1876 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1878 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1879 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1880 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1882 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1883 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1884 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1886 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1887 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1888 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1890 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1891 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1892 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1894 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1897 add_function("textureLod",
1898 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1899 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1900 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1902 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1903 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1904 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1906 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1907 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1908 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1910 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1911 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1912 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1914 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1915 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1917 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1918 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1919 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1921 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1922 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1923 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1925 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1926 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1927 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1929 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1932 add_function("textureOffset",
1933 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1934 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1935 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1937 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1938 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1939 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1941 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1942 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1943 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1945 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1946 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1947 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1949 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1951 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1952 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1954 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1955 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1956 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1958 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1959 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1960 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1962 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1963 /* The next one was forgotten in GLSL 1.30 spec. It's from
1964 * EXT_gpu_shader4 originally. It was added in 4.30 with the
1965 * wrong syntax. This was corrected in 4.40. 4.30 indicates
1966 * that it was intended to be included previously, so allow it
1969 _texture(ir_tex
, v130_desktop
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1971 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1972 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1973 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1975 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1976 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1977 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1979 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1980 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1981 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1983 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1984 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1986 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1987 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1988 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1990 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1991 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1992 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1994 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1997 add_function("textureProj",
1998 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1999 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2000 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2001 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2002 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2003 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2005 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2006 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2007 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2008 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2009 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2010 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2012 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2013 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2014 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2016 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2017 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2019 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2020 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2021 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2022 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2023 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2024 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2026 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2028 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2029 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2030 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2031 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2032 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2033 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2035 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2036 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2037 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2038 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2039 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2040 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2042 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2043 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2044 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2046 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2047 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2050 add_function("texelFetch",
2051 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
2052 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
2053 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
2055 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
2056 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
2057 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
2059 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
2060 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
2061 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
2063 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
2064 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
2065 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
2067 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
2068 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
2069 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
2071 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
2072 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
2073 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
2075 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
2076 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
2077 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
2079 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2080 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2081 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2083 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2084 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2085 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2088 add_function("texelFetchOffset",
2089 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2090 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2091 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2093 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2094 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2095 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2097 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2098 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2099 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2101 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2102 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2103 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2105 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2106 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2107 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2109 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2110 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2111 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2115 add_function("textureProjOffset",
2116 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2117 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2118 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2119 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2120 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2121 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2123 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2124 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2125 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2126 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2127 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2128 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2130 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2131 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2132 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2134 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2135 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2137 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2138 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2139 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2140 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2141 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2142 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2144 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2146 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2147 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2148 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2149 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2150 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2151 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2153 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2154 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2155 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2156 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2157 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2158 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2160 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2161 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2162 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2164 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2165 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2168 add_function("textureLodOffset",
2169 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2170 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2171 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2173 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2174 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2175 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2177 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2178 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2179 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2181 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2182 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2184 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2185 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2186 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2188 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2189 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2190 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2192 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2195 add_function("textureProjLod",
2196 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2197 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2198 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2199 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2200 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2201 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2203 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2204 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2205 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2206 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2207 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2208 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2210 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2211 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2212 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2214 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2215 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2218 add_function("textureProjLodOffset",
2219 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2220 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2221 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2222 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2223 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2224 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2226 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2227 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2228 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2229 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2230 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2231 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2233 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2234 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2235 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2237 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2238 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2241 add_function("textureGrad",
2242 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2243 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2244 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2246 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2247 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2248 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2250 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2251 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2252 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2254 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2255 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2256 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2258 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2259 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2260 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2262 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2264 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2265 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2266 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2268 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2269 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2270 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2272 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2273 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2274 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2276 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2277 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2278 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2280 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2281 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2284 add_function("textureGradOffset",
2285 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2286 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2287 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2289 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2290 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2291 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2293 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2294 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2295 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2297 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2298 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2299 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2301 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2303 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2304 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2306 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2307 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2308 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2310 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2311 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2312 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2314 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2315 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2318 add_function("textureProjGrad",
2319 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2320 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2321 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2322 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2323 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2324 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2326 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2327 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2328 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2329 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2330 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2331 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2333 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2334 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2335 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2337 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2338 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2339 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2340 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2341 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2342 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2344 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2346 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2347 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2350 add_function("textureProjGradOffset",
2351 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2352 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2353 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2354 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2355 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2356 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2358 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2359 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2360 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2361 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2362 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2363 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2365 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2366 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2367 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2369 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2370 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2371 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2372 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2373 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2374 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2376 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2378 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2379 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2382 add_function("EmitVertex", _EmitVertex(), NULL
);
2383 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2384 add_function("EmitStreamVertex",
2385 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2386 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2388 add_function("EndStreamPrimitive",
2389 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2390 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2392 add_function("barrier", _barrier(), NULL
);
2394 add_function("textureQueryLOD",
2395 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2396 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2397 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2399 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2400 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2401 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2403 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2404 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2405 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2407 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2408 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2409 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2411 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2412 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2413 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2415 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2416 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2417 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2419 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2420 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2421 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2423 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2424 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2425 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2426 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2427 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2428 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2431 add_function("textureQueryLod",
2432 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2433 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2434 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2436 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2437 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2438 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2440 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2441 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2442 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2444 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2445 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2446 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2448 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2449 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2450 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2452 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2453 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2454 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2456 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2457 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2458 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2460 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2461 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2462 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2463 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2464 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2465 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2468 add_function("textureQueryLevels",
2469 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1D_type
),
2470 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2D_type
),
2471 _textureQueryLevels(texture_query_levels
, glsl_type::sampler3D_type
),
2472 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCube_type
),
2473 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArray_type
),
2474 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArray_type
),
2475 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArray_type
),
2476 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DShadow_type
),
2477 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DShadow_type
),
2478 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeShadow_type
),
2479 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArrayShadow_type
),
2480 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArrayShadow_type
),
2481 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArrayShadow_type
),
2483 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1D_type
),
2484 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2D_type
),
2485 _textureQueryLevels(texture_query_levels
, glsl_type::isampler3D_type
),
2486 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCube_type
),
2487 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1DArray_type
),
2488 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2DArray_type
),
2489 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCubeArray_type
),
2491 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1D_type
),
2492 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2D_type
),
2493 _textureQueryLevels(texture_query_levels
, glsl_type::usampler3D_type
),
2494 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCube_type
),
2495 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1DArray_type
),
2496 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2DArray_type
),
2497 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCubeArray_type
),
2501 add_function("textureSamplesIdenticalEXT",
2502 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2503 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2504 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2506 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2507 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2508 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2511 add_function("texture1D",
2512 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2513 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2516 add_function("texture1DArray",
2517 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2518 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2521 add_function("texture1DProj",
2522 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2523 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2524 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2525 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2528 add_function("texture1DLod",
2529 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2532 add_function("texture1DArrayLod",
2533 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2536 add_function("texture1DProjLod",
2537 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2538 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2541 add_function("texture2D",
2542 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2543 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2544 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2547 add_function("texture2DArray",
2548 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2549 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2552 add_function("texture2DProj",
2553 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2554 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2555 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2556 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2557 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2558 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2561 add_function("texture2DLod",
2562 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2565 add_function("texture2DArrayLod",
2566 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2569 add_function("texture2DProjLod",
2570 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2571 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2574 add_function("texture3D",
2575 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2576 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2579 add_function("texture3DProj",
2580 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2581 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2584 add_function("texture3DLod",
2585 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2588 add_function("texture3DProjLod",
2589 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2592 add_function("textureCube",
2593 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2594 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2597 add_function("textureCubeLod",
2598 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2601 add_function("texture2DRect",
2602 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2605 add_function("texture2DRectProj",
2606 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2607 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2610 add_function("shadow1D",
2611 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2612 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2615 add_function("shadow1DArray",
2616 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2617 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2620 add_function("shadow2D",
2621 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2622 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2625 add_function("shadow2DArray",
2626 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2627 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2630 add_function("shadow1DProj",
2631 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2632 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2635 add_function("shadow2DProj",
2636 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2637 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2640 add_function("shadow1DLod",
2641 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2644 add_function("shadow2DLod",
2645 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2648 add_function("shadow1DArrayLod",
2649 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2652 add_function("shadow1DProjLod",
2653 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2656 add_function("shadow2DProjLod",
2657 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2660 add_function("shadow2DRect",
2661 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2664 add_function("shadow2DRectProj",
2665 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2668 add_function("texture1DGradARB",
2669 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2672 add_function("texture1DProjGradARB",
2673 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2674 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2677 add_function("texture2DGradARB",
2678 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2681 add_function("texture2DProjGradARB",
2682 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2683 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2686 add_function("texture3DGradARB",
2687 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2690 add_function("texture3DProjGradARB",
2691 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2694 add_function("textureCubeGradARB",
2695 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2698 add_function("shadow1DGradARB",
2699 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2702 add_function("shadow1DProjGradARB",
2703 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2706 add_function("shadow2DGradARB",
2707 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2710 add_function("shadow2DProjGradARB",
2711 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2714 add_function("texture2DRectGradARB",
2715 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2718 add_function("texture2DRectProjGradARB",
2719 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2720 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2723 add_function("shadow2DRectGradARB",
2724 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2727 add_function("shadow2DRectProjGradARB",
2728 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2731 add_function("textureGather",
2732 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2733 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2734 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2736 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2737 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2738 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2740 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2741 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2742 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2744 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2745 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2746 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2748 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2749 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2750 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2752 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2753 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2754 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2756 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2757 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2758 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2760 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2761 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2762 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2764 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2765 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2766 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2768 _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
),
2769 _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
),
2770 _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
),
2772 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2773 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2774 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2775 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2776 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2779 add_function("textureGatherOffset",
2780 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2781 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2782 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2784 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2785 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2786 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2788 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2789 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2790 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2792 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2793 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2794 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2796 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2797 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2798 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2800 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2801 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2802 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2804 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2805 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2806 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2808 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2809 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2810 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2812 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2813 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2814 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2816 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2817 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2818 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2820 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2821 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2822 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2824 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2825 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2828 add_function("textureGatherOffsets",
2829 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2830 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2831 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2833 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2834 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2835 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2837 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2838 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2839 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2841 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2842 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2843 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2845 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2846 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2847 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2849 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2850 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2851 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2853 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2854 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2855 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2880 add_function("ldexp",
2881 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2882 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2883 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2884 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2885 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2886 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2887 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2888 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2891 add_function("frexp",
2892 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2893 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2894 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2895 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2896 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2897 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2898 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2899 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2901 add_function("uaddCarry",
2902 _uaddCarry(glsl_type::uint_type
),
2903 _uaddCarry(glsl_type::uvec2_type
),
2904 _uaddCarry(glsl_type::uvec3_type
),
2905 _uaddCarry(glsl_type::uvec4_type
),
2907 add_function("usubBorrow",
2908 _usubBorrow(glsl_type::uint_type
),
2909 _usubBorrow(glsl_type::uvec2_type
),
2910 _usubBorrow(glsl_type::uvec3_type
),
2911 _usubBorrow(glsl_type::uvec4_type
),
2913 add_function("imulExtended",
2914 _mulExtended(glsl_type::int_type
),
2915 _mulExtended(glsl_type::ivec2_type
),
2916 _mulExtended(glsl_type::ivec3_type
),
2917 _mulExtended(glsl_type::ivec4_type
),
2919 add_function("umulExtended",
2920 _mulExtended(glsl_type::uint_type
),
2921 _mulExtended(glsl_type::uvec2_type
),
2922 _mulExtended(glsl_type::uvec3_type
),
2923 _mulExtended(glsl_type::uvec4_type
),
2925 add_function("interpolateAtCentroid",
2926 _interpolateAtCentroid(glsl_type::float_type
),
2927 _interpolateAtCentroid(glsl_type::vec2_type
),
2928 _interpolateAtCentroid(glsl_type::vec3_type
),
2929 _interpolateAtCentroid(glsl_type::vec4_type
),
2931 add_function("interpolateAtOffset",
2932 _interpolateAtOffset(glsl_type::float_type
),
2933 _interpolateAtOffset(glsl_type::vec2_type
),
2934 _interpolateAtOffset(glsl_type::vec3_type
),
2935 _interpolateAtOffset(glsl_type::vec4_type
),
2937 add_function("interpolateAtSample",
2938 _interpolateAtSample(glsl_type::float_type
),
2939 _interpolateAtSample(glsl_type::vec2_type
),
2940 _interpolateAtSample(glsl_type::vec3_type
),
2941 _interpolateAtSample(glsl_type::vec4_type
),
2944 add_function("atomicCounter",
2945 _atomic_counter_op("__intrinsic_atomic_read",
2946 shader_atomic_counters
),
2948 add_function("atomicCounterIncrement",
2949 _atomic_counter_op("__intrinsic_atomic_increment",
2950 shader_atomic_counters
),
2952 add_function("atomicCounterDecrement",
2953 _atomic_counter_op("__intrinsic_atomic_predecrement",
2954 shader_atomic_counters
),
2957 add_function("atomicCounterAddARB",
2958 _atomic_counter_op1("__intrinsic_atomic_add",
2959 shader_atomic_counter_ops
),
2961 add_function("atomicCounterSubtractARB",
2962 _atomic_counter_op1("__intrinsic_atomic_sub",
2963 shader_atomic_counter_ops
),
2965 add_function("atomicCounterMinARB",
2966 _atomic_counter_op1("__intrinsic_atomic_min",
2967 shader_atomic_counter_ops
),
2969 add_function("atomicCounterMaxARB",
2970 _atomic_counter_op1("__intrinsic_atomic_max",
2971 shader_atomic_counter_ops
),
2973 add_function("atomicCounterAndARB",
2974 _atomic_counter_op1("__intrinsic_atomic_and",
2975 shader_atomic_counter_ops
),
2977 add_function("atomicCounterOrARB",
2978 _atomic_counter_op1("__intrinsic_atomic_or",
2979 shader_atomic_counter_ops
),
2981 add_function("atomicCounterXorARB",
2982 _atomic_counter_op1("__intrinsic_atomic_xor",
2983 shader_atomic_counter_ops
),
2985 add_function("atomicCounterExchangeARB",
2986 _atomic_counter_op1("__intrinsic_atomic_exchange",
2987 shader_atomic_counter_ops
),
2989 add_function("atomicCounterCompSwapARB",
2990 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
2991 shader_atomic_counter_ops
),
2994 add_function("atomicAdd",
2995 _atomic_op2("__intrinsic_atomic_add",
2996 buffer_atomics_supported
,
2997 glsl_type::uint_type
),
2998 _atomic_op2("__intrinsic_atomic_add",
2999 buffer_atomics_supported
,
3000 glsl_type::int_type
),
3002 add_function("atomicMin",
3003 _atomic_op2("__intrinsic_atomic_min",
3004 buffer_atomics_supported
,
3005 glsl_type::uint_type
),
3006 _atomic_op2("__intrinsic_atomic_min",
3007 buffer_atomics_supported
,
3008 glsl_type::int_type
),
3010 add_function("atomicMax",
3011 _atomic_op2("__intrinsic_atomic_max",
3012 buffer_atomics_supported
,
3013 glsl_type::uint_type
),
3014 _atomic_op2("__intrinsic_atomic_max",
3015 buffer_atomics_supported
,
3016 glsl_type::int_type
),
3018 add_function("atomicAnd",
3019 _atomic_op2("__intrinsic_atomic_and",
3020 buffer_atomics_supported
,
3021 glsl_type::uint_type
),
3022 _atomic_op2("__intrinsic_atomic_and",
3023 buffer_atomics_supported
,
3024 glsl_type::int_type
),
3026 add_function("atomicOr",
3027 _atomic_op2("__intrinsic_atomic_or",
3028 buffer_atomics_supported
,
3029 glsl_type::uint_type
),
3030 _atomic_op2("__intrinsic_atomic_or",
3031 buffer_atomics_supported
,
3032 glsl_type::int_type
),
3034 add_function("atomicXor",
3035 _atomic_op2("__intrinsic_atomic_xor",
3036 buffer_atomics_supported
,
3037 glsl_type::uint_type
),
3038 _atomic_op2("__intrinsic_atomic_xor",
3039 buffer_atomics_supported
,
3040 glsl_type::int_type
),
3042 add_function("atomicExchange",
3043 _atomic_op2("__intrinsic_atomic_exchange",
3044 buffer_atomics_supported
,
3045 glsl_type::uint_type
),
3046 _atomic_op2("__intrinsic_atomic_exchange",
3047 buffer_atomics_supported
,
3048 glsl_type::int_type
),
3050 add_function("atomicCompSwap",
3051 _atomic_op3("__intrinsic_atomic_comp_swap",
3052 buffer_atomics_supported
,
3053 glsl_type::uint_type
),
3054 _atomic_op3("__intrinsic_atomic_comp_swap",
3055 buffer_atomics_supported
,
3056 glsl_type::int_type
),
3059 add_function("min3",
3060 _min3(glsl_type::float_type
),
3061 _min3(glsl_type::vec2_type
),
3062 _min3(glsl_type::vec3_type
),
3063 _min3(glsl_type::vec4_type
),
3065 _min3(glsl_type::int_type
),
3066 _min3(glsl_type::ivec2_type
),
3067 _min3(glsl_type::ivec3_type
),
3068 _min3(glsl_type::ivec4_type
),
3070 _min3(glsl_type::uint_type
),
3071 _min3(glsl_type::uvec2_type
),
3072 _min3(glsl_type::uvec3_type
),
3073 _min3(glsl_type::uvec4_type
),
3076 add_function("max3",
3077 _max3(glsl_type::float_type
),
3078 _max3(glsl_type::vec2_type
),
3079 _max3(glsl_type::vec3_type
),
3080 _max3(glsl_type::vec4_type
),
3082 _max3(glsl_type::int_type
),
3083 _max3(glsl_type::ivec2_type
),
3084 _max3(glsl_type::ivec3_type
),
3085 _max3(glsl_type::ivec4_type
),
3087 _max3(glsl_type::uint_type
),
3088 _max3(glsl_type::uvec2_type
),
3089 _max3(glsl_type::uvec3_type
),
3090 _max3(glsl_type::uvec4_type
),
3093 add_function("mid3",
3094 _mid3(glsl_type::float_type
),
3095 _mid3(glsl_type::vec2_type
),
3096 _mid3(glsl_type::vec3_type
),
3097 _mid3(glsl_type::vec4_type
),
3099 _mid3(glsl_type::int_type
),
3100 _mid3(glsl_type::ivec2_type
),
3101 _mid3(glsl_type::ivec3_type
),
3102 _mid3(glsl_type::ivec4_type
),
3104 _mid3(glsl_type::uint_type
),
3105 _mid3(glsl_type::uvec2_type
),
3106 _mid3(glsl_type::uvec3_type
),
3107 _mid3(glsl_type::uvec4_type
),
3110 add_image_functions(true);
3112 add_function("memoryBarrier",
3113 _memory_barrier("__intrinsic_memory_barrier",
3114 shader_image_load_store
),
3116 add_function("groupMemoryBarrier",
3117 _memory_barrier("__intrinsic_group_memory_barrier",
3120 add_function("memoryBarrierAtomicCounter",
3121 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
3122 compute_shader_supported
),
3124 add_function("memoryBarrierBuffer",
3125 _memory_barrier("__intrinsic_memory_barrier_buffer",
3126 compute_shader_supported
),
3128 add_function("memoryBarrierImage",
3129 _memory_barrier("__intrinsic_memory_barrier_image",
3130 compute_shader_supported
),
3132 add_function("memoryBarrierShared",
3133 _memory_barrier("__intrinsic_memory_barrier_shared",
3137 add_function("ballotARB", _ballot(), NULL
);
3139 add_function("readInvocationARB",
3140 _read_invocation(glsl_type::float_type
),
3141 _read_invocation(glsl_type::vec2_type
),
3142 _read_invocation(glsl_type::vec3_type
),
3143 _read_invocation(glsl_type::vec4_type
),
3145 _read_invocation(glsl_type::int_type
),
3146 _read_invocation(glsl_type::ivec2_type
),
3147 _read_invocation(glsl_type::ivec3_type
),
3148 _read_invocation(glsl_type::ivec4_type
),
3150 _read_invocation(glsl_type::uint_type
),
3151 _read_invocation(glsl_type::uvec2_type
),
3152 _read_invocation(glsl_type::uvec3_type
),
3153 _read_invocation(glsl_type::uvec4_type
),
3156 add_function("readFirstInvocationARB",
3157 _read_first_invocation(glsl_type::float_type
),
3158 _read_first_invocation(glsl_type::vec2_type
),
3159 _read_first_invocation(glsl_type::vec3_type
),
3160 _read_first_invocation(glsl_type::vec4_type
),
3162 _read_first_invocation(glsl_type::int_type
),
3163 _read_first_invocation(glsl_type::ivec2_type
),
3164 _read_first_invocation(glsl_type::ivec3_type
),
3165 _read_first_invocation(glsl_type::ivec4_type
),
3167 _read_first_invocation(glsl_type::uint_type
),
3168 _read_first_invocation(glsl_type::uvec2_type
),
3169 _read_first_invocation(glsl_type::uvec3_type
),
3170 _read_first_invocation(glsl_type::uvec4_type
),
3173 add_function("clock2x32ARB",
3174 _shader_clock(shader_clock
,
3175 glsl_type::uvec2_type
),
3178 add_function("clockARB",
3179 _shader_clock(shader_clock_int64
,
3180 glsl_type::uint64_t_type
),
3183 add_function("anyInvocationARB", _vote("__intrinsic_vote_any"), NULL
);
3184 add_function("allInvocationsARB", _vote("__intrinsic_vote_all"), NULL
);
3185 add_function("allInvocationsEqualARB", _vote("__intrinsic_vote_eq"), NULL
);
3187 add_function("__builtin_idiv64",
3188 generate_ir::idiv64(mem_ctx
, integer_functions_supported
),
3191 add_function("__builtin_imod64",
3192 generate_ir::imod64(mem_ctx
, integer_functions_supported
),
3195 add_function("__builtin_sign64",
3196 generate_ir::sign64(mem_ctx
, integer_functions_supported
),
3199 add_function("__builtin_udiv64",
3200 generate_ir::udiv64(mem_ctx
, integer_functions_supported
),
3203 add_function("__builtin_umod64",
3204 generate_ir::umod64(mem_ctx
, integer_functions_supported
),
3207 add_function("__builtin_umul64",
3208 generate_ir::umul64(mem_ctx
, integer_functions_supported
),
3219 builtin_builder::add_function(const char *name
, ...)
3223 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3227 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
3233 stuff
.push_tail(sig
);
3234 validate_ir_tree(&stuff
);
3237 f
->add_signature(sig
);
3241 shader
->symbols
->add_function(f
);
3245 builtin_builder::add_image_function(const char *name
,
3246 const char *intrinsic_name
,
3247 image_prototype_ctr prototype
,
3248 unsigned num_arguments
,
3250 enum ir_intrinsic_id intrinsic_id
)
3252 static const glsl_type
*const types
[] = {
3253 glsl_type::image1D_type
,
3254 glsl_type::image2D_type
,
3255 glsl_type::image3D_type
,
3256 glsl_type::image2DRect_type
,
3257 glsl_type::imageCube_type
,
3258 glsl_type::imageBuffer_type
,
3259 glsl_type::image1DArray_type
,
3260 glsl_type::image2DArray_type
,
3261 glsl_type::imageCubeArray_type
,
3262 glsl_type::image2DMS_type
,
3263 glsl_type::image2DMSArray_type
,
3264 glsl_type::iimage1D_type
,
3265 glsl_type::iimage2D_type
,
3266 glsl_type::iimage3D_type
,
3267 glsl_type::iimage2DRect_type
,
3268 glsl_type::iimageCube_type
,
3269 glsl_type::iimageBuffer_type
,
3270 glsl_type::iimage1DArray_type
,
3271 glsl_type::iimage2DArray_type
,
3272 glsl_type::iimageCubeArray_type
,
3273 glsl_type::iimage2DMS_type
,
3274 glsl_type::iimage2DMSArray_type
,
3275 glsl_type::uimage1D_type
,
3276 glsl_type::uimage2D_type
,
3277 glsl_type::uimage3D_type
,
3278 glsl_type::uimage2DRect_type
,
3279 glsl_type::uimageCube_type
,
3280 glsl_type::uimageBuffer_type
,
3281 glsl_type::uimage1DArray_type
,
3282 glsl_type::uimage2DArray_type
,
3283 glsl_type::uimageCubeArray_type
,
3284 glsl_type::uimage2DMS_type
,
3285 glsl_type::uimage2DMSArray_type
3288 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3290 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3291 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3292 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3293 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3294 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3295 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3296 num_arguments
, flags
, intrinsic_id
));
3299 shader
->symbols
->add_function(f
);
3303 builtin_builder::add_image_functions(bool glsl
)
3305 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3307 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3308 "__intrinsic_image_load",
3309 &builtin_builder::_image_prototype
, 0,
3310 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3311 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3312 IMAGE_FUNCTION_READ_ONLY
),
3313 ir_intrinsic_image_load
);
3315 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3316 "__intrinsic_image_store",
3317 &builtin_builder::_image_prototype
, 1,
3318 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3319 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3320 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3321 IMAGE_FUNCTION_WRITE_ONLY
),
3322 ir_intrinsic_image_store
);
3324 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3326 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3327 "__intrinsic_image_atomic_add",
3328 &builtin_builder::_image_prototype
, 1, atom_flags
,
3329 ir_intrinsic_image_atomic_add
);
3331 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3332 "__intrinsic_image_atomic_min",
3333 &builtin_builder::_image_prototype
, 1, atom_flags
,
3334 ir_intrinsic_image_atomic_min
);
3336 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3337 "__intrinsic_image_atomic_max",
3338 &builtin_builder::_image_prototype
, 1, atom_flags
,
3339 ir_intrinsic_image_atomic_max
);
3341 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3342 "__intrinsic_image_atomic_and",
3343 &builtin_builder::_image_prototype
, 1, atom_flags
,
3344 ir_intrinsic_image_atomic_and
);
3346 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3347 "__intrinsic_image_atomic_or",
3348 &builtin_builder::_image_prototype
, 1, atom_flags
,
3349 ir_intrinsic_image_atomic_or
);
3351 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3352 "__intrinsic_image_atomic_xor",
3353 &builtin_builder::_image_prototype
, 1, atom_flags
,
3354 ir_intrinsic_image_atomic_xor
);
3356 add_image_function((glsl
? "imageAtomicExchange" :
3357 "__intrinsic_image_atomic_exchange"),
3358 "__intrinsic_image_atomic_exchange",
3359 &builtin_builder::_image_prototype
, 1,
3360 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3361 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3362 ir_intrinsic_image_atomic_exchange
);
3364 add_image_function((glsl
? "imageAtomicCompSwap" :
3365 "__intrinsic_image_atomic_comp_swap"),
3366 "__intrinsic_image_atomic_comp_swap",
3367 &builtin_builder::_image_prototype
, 2, atom_flags
,
3368 ir_intrinsic_image_atomic_comp_swap
);
3370 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3371 "__intrinsic_image_size",
3372 &builtin_builder::_image_size_prototype
, 1,
3373 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
,
3374 ir_intrinsic_image_size
);
3376 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3377 "__intrinsic_image_samples",
3378 &builtin_builder::_image_samples_prototype
, 1,
3379 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3380 IMAGE_FUNCTION_MS_ONLY
,
3381 ir_intrinsic_image_samples
);
3385 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3387 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3391 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3393 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3397 builtin_builder::imm(bool b
, unsigned vector_elements
)
3399 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3403 builtin_builder::imm(float f
, unsigned vector_elements
)
3405 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3409 builtin_builder::imm(int i
, unsigned vector_elements
)
3411 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3415 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3417 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3421 builtin_builder::imm(double d
, unsigned vector_elements
)
3423 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3427 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3429 return new(mem_ctx
) ir_constant(type
, &data
);
3432 #define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)
3434 ir_dereference_variable
*
3435 builtin_builder::var_ref(ir_variable
*var
)
3437 return new(mem_ctx
) ir_dereference_variable(var
);
3440 ir_dereference_array
*
3441 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3443 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3446 /** Return an element of a matrix */
3448 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3450 return swizzle(array_ref(var
, column
), row
, 1);
3454 * Implementations of built-in functions:
3457 ir_function_signature
*
3458 builtin_builder::new_sig(const glsl_type
*return_type
,
3459 builtin_available_predicate avail
,
3465 ir_function_signature
*sig
=
3466 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3469 va_start(ap
, num_params
);
3470 for (int i
= 0; i
< num_params
; i
++) {
3471 plist
.push_tail(va_arg(ap
, ir_variable
*));
3475 sig
->replace_parameters(&plist
);
3479 #define MAKE_SIG(return_type, avail, ...) \
3480 ir_function_signature *sig = \
3481 new_sig(return_type, avail, __VA_ARGS__); \
3482 ir_factory body(&sig->body, mem_ctx); \
3483 sig->is_defined = true;
3485 #define MAKE_INTRINSIC(return_type, id, avail, ...) \
3486 ir_function_signature *sig = \
3487 new_sig(return_type, avail, __VA_ARGS__); \
3488 sig->intrinsic_id = id;
3490 ir_function_signature
*
3491 builtin_builder::unop(builtin_available_predicate avail
,
3492 ir_expression_operation opcode
,
3493 const glsl_type
*return_type
,
3494 const glsl_type
*param_type
)
3496 ir_variable
*x
= in_var(param_type
, "x");
3497 MAKE_SIG(return_type
, avail
, 1, x
);
3498 body
.emit(ret(expr(opcode
, x
)));
3502 #define UNOP(NAME, OPCODE, AVAIL) \
3503 ir_function_signature * \
3504 builtin_builder::_##NAME(const glsl_type *type) \
3506 return unop(&AVAIL, OPCODE, type, type); \
3509 #define UNOPA(NAME, OPCODE) \
3510 ir_function_signature * \
3511 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3513 return unop(avail, OPCODE, type, type); \
3516 ir_function_signature
*
3517 builtin_builder::binop(builtin_available_predicate avail
,
3518 ir_expression_operation opcode
,
3519 const glsl_type
*return_type
,
3520 const glsl_type
*param0_type
,
3521 const glsl_type
*param1_type
)
3523 ir_variable
*x
= in_var(param0_type
, "x");
3524 ir_variable
*y
= in_var(param1_type
, "y");
3525 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3526 body
.emit(ret(expr(opcode
, x
, y
)));
3530 #define BINOP(NAME, OPCODE, AVAIL) \
3531 ir_function_signature * \
3532 builtin_builder::_##NAME(const glsl_type *return_type, \
3533 const glsl_type *param0_type, \
3534 const glsl_type *param1_type) \
3536 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3540 * Angle and Trigonometry Functions @{
3543 ir_function_signature
*
3544 builtin_builder::_radians(const glsl_type
*type
)
3546 ir_variable
*degrees
= in_var(type
, "degrees");
3547 MAKE_SIG(type
, always_available
, 1, degrees
);
3548 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3552 ir_function_signature
*
3553 builtin_builder::_degrees(const glsl_type
*type
)
3555 ir_variable
*radians
= in_var(type
, "radians");
3556 MAKE_SIG(type
, always_available
, 1, radians
);
3557 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3561 UNOP(sin
, ir_unop_sin
, always_available
)
3562 UNOP(cos
, ir_unop_cos
, always_available
)
3564 ir_function_signature
*
3565 builtin_builder::_tan(const glsl_type
*type
)
3567 ir_variable
*theta
= in_var(type
, "theta");
3568 MAKE_SIG(type
, always_available
, 1, theta
);
3569 body
.emit(ret(div(sin(theta
), cos(theta
))));
3574 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3578 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3581 add(imm(M_PI_4f
- 1.0f
),
3584 mul(abs(x
), imm(p1
))))))))));
3588 * Generate a ir_call to a function with a set of parameters
3590 * The input \c params can either be a list of \c ir_variable or a list of
3591 * \c ir_dereference_variable. In the latter case, all nodes will be removed
3592 * from \c params and used directly as the parameters to the generated
3596 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3598 exec_list actual_params
;
3600 foreach_in_list_safe(ir_instruction
, ir
, ¶ms
) {
3601 ir_dereference_variable
*d
= ir
->as_dereference_variable();
3604 actual_params
.push_tail(d
);
3606 ir_variable
*var
= ir
->as_variable();
3607 assert(var
!= NULL
);
3608 actual_params
.push_tail(var_ref(var
));
3612 ir_function_signature
*sig
=
3613 f
->exact_matching_signature(NULL
, &actual_params
);
3617 ir_dereference_variable
*deref
=
3618 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3620 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3623 ir_function_signature
*
3624 builtin_builder::_asin(const glsl_type
*type
)
3626 ir_variable
*x
= in_var(type
, "x");
3627 MAKE_SIG(type
, always_available
, 1, x
);
3629 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3634 ir_function_signature
*
3635 builtin_builder::_acos(const glsl_type
*type
)
3637 ir_variable
*x
= in_var(type
, "x");
3638 MAKE_SIG(type
, always_available
, 1, x
);
3640 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3645 ir_function_signature
*
3646 builtin_builder::_atan2(const glsl_type
*type
)
3648 const unsigned n
= type
->vector_elements
;
3649 ir_variable
*y
= in_var(type
, "y");
3650 ir_variable
*x
= in_var(type
, "x");
3651 MAKE_SIG(type
, always_available
, 2, y
, x
);
3653 /* If we're on the left half-plane rotate the coordinates π/2 clock-wise
3654 * for the y=0 discontinuity to end up aligned with the vertical
3655 * discontinuity of atan(s/t) along t=0. This also makes sure that we
3656 * don't attempt to divide by zero along the vertical line, which may give
3657 * unspecified results on non-GLSL 4.1-capable hardware.
3659 ir_variable
*flip
= body
.make_temp(glsl_type::bvec(n
), "flip");
3660 body
.emit(assign(flip
, gequal(imm(0.0f
, n
), x
)));
3661 ir_variable
*s
= body
.make_temp(type
, "s");
3662 body
.emit(assign(s
, csel(flip
, abs(x
), y
)));
3663 ir_variable
*t
= body
.make_temp(type
, "t");
3664 body
.emit(assign(t
, csel(flip
, y
, abs(x
))));
3666 /* If the magnitude of the denominator exceeds some huge value, scale down
3667 * the arguments in order to prevent the reciprocal operation from flushing
3668 * its result to zero, which would cause precision problems, and for s
3669 * infinite would cause us to return a NaN instead of the correct finite
3672 * If fmin and fmax are respectively the smallest and largest positive
3673 * normalized floating point values representable by the implementation,
3674 * the constants below should be in agreement with:
3677 * scale <= 1 / fmin / fmax (for |t| >= huge)
3679 * In addition scale should be a negative power of two in order to avoid
3680 * loss of precision. The values chosen below should work for most usual
3681 * floating point representations with at least the dynamic range of ATI's
3682 * 24-bit representation.
3684 ir_constant
*huge
= imm(1e18f
, n
);
3685 ir_variable
*scale
= body
.make_temp(type
, "scale");
3686 body
.emit(assign(scale
, csel(gequal(abs(t
), huge
),
3687 imm(0.25f
, n
), imm(1.0f
, n
))));
3688 ir_variable
*rcp_scaled_t
= body
.make_temp(type
, "rcp_scaled_t");
3689 body
.emit(assign(rcp_scaled_t
, rcp(mul(t
, scale
))));
3690 ir_expression
*s_over_t
= mul(mul(s
, scale
), rcp_scaled_t
);
3692 /* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily
3693 * that ∞/∞ = 1) in order to comply with the rather artificial rules
3694 * inherited from IEEE 754-2008, namely:
3696 * "atan2(±∞, −∞) is ±3π/4
3697 * atan2(±∞, +∞) is ±π/4"
3699 * Note that this is inconsistent with the rules for the neighborhood of
3700 * zero that are based on iterated limits:
3702 * "atan2(±0, −0) is ±π
3703 * atan2(±0, +0) is ±0"
3705 * but GLSL specifically allows implementations to deviate from IEEE rules
3706 * at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as
3709 ir_expression
*tan
= csel(equal(abs(x
), abs(y
)),
3710 imm(1.0f
, n
), abs(s_over_t
));
3712 /* Calculate the arctangent and fix up the result if we had flipped the
3713 * coordinate system.
3715 ir_variable
*arc
= body
.make_temp(type
, "arc");
3716 do_atan(body
, type
, arc
, tan
);
3717 body
.emit(assign(arc
, add(arc
, mul(b2f(flip
), imm(M_PI_2f
)))));
3719 /* Rather convoluted calculation of the sign of the result. When x < 0 we
3720 * cannot use fsign because we need to be able to distinguish between
3721 * negative and positive zero. Unfortunately we cannot use bitwise
3722 * arithmetic tricks either because of back-ends without integer support.
3723 * When x >= 0 rcp_scaled_t will always be non-negative so this won't be
3724 * able to distinguish between negative and positive zero, but we don't
3725 * care because atan2 is continuous along the whole positive y = 0
3726 * half-line, so it won't affect the result significantly.
3728 body
.emit(ret(csel(less(min2(y
, rcp_scaled_t
), imm(0.0f
, n
)),
3735 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3738 * range-reduction, first step:
3740 * / y_over_x if |y_over_x| <= 1.0;
3742 * \ 1.0 / y_over_x otherwise
3744 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3745 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3751 * approximate atan by evaluating polynomial:
3753 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3754 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3755 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3757 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3758 body
.emit(assign(tmp
, mul(x
, x
)));
3759 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3761 imm(0.0536813784310406f
)),
3763 imm(0.1173503194786851f
)),
3765 imm(0.1938924977115610f
)),
3767 imm(0.3326756418091246f
)),
3769 imm(0.9999793128310355f
)),
3772 /* range-reduction fixup */
3773 body
.emit(assign(tmp
, add(tmp
,
3774 mul(b2f(greater(abs(y_over_x
),
3775 imm(1.0f
, type
->components()))),
3781 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3784 ir_function_signature
*
3785 builtin_builder::_atan(const glsl_type
*type
)
3787 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3788 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3790 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3791 do_atan(body
, type
, tmp
, y_over_x
);
3792 body
.emit(ret(tmp
));
3797 ir_function_signature
*
3798 builtin_builder::_sinh(const glsl_type
*type
)
3800 ir_variable
*x
= in_var(type
, "x");
3801 MAKE_SIG(type
, v130
, 1, x
);
3803 /* 0.5 * (e^x - e^(-x)) */
3804 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3809 ir_function_signature
*
3810 builtin_builder::_cosh(const glsl_type
*type
)
3812 ir_variable
*x
= in_var(type
, "x");
3813 MAKE_SIG(type
, v130
, 1, x
);
3815 /* 0.5 * (e^x + e^(-x)) */
3816 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3821 ir_function_signature
*
3822 builtin_builder::_tanh(const glsl_type
*type
)
3824 ir_variable
*x
= in_var(type
, "x");
3825 MAKE_SIG(type
, v130
, 1, x
);
3827 /* tanh(x) := (0.5 * (e^x - e^(-x))) / (0.5 * (e^x + e^(-x)))
3829 * With a little algebra this reduces to (e^2x - 1) / (e^2x + 1)
3831 * Clamp x to (-inf, +10] to avoid precision problems. When x > 10, e^2x
3832 * is so much larger than 1.0 that 1.0 gets flushed to zero in the
3833 * computation e^2x +/- 1 so it can be ignored.
3835 ir_variable
*t
= body
.make_temp(type
, "tmp");
3836 body
.emit(assign(t
, min2(x
, imm(10.0f
))));
3838 body
.emit(ret(div(sub(exp(mul(t
, imm(2.0f
))), imm(1.0f
)),
3839 add(exp(mul(t
, imm(2.0f
))), imm(1.0f
)))));
3844 ir_function_signature
*
3845 builtin_builder::_asinh(const glsl_type
*type
)
3847 ir_variable
*x
= in_var(type
, "x");
3848 MAKE_SIG(type
, v130
, 1, x
);
3850 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3855 ir_function_signature
*
3856 builtin_builder::_acosh(const glsl_type
*type
)
3858 ir_variable
*x
= in_var(type
, "x");
3859 MAKE_SIG(type
, v130
, 1, x
);
3861 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3865 ir_function_signature
*
3866 builtin_builder::_atanh(const glsl_type
*type
)
3868 ir_variable
*x
= in_var(type
, "x");
3869 MAKE_SIG(type
, v130
, 1, x
);
3871 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3872 sub(imm(1.0f
), x
))))));
3878 * Exponential Functions @{
3881 ir_function_signature
*
3882 builtin_builder::_pow(const glsl_type
*type
)
3884 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
3887 UNOP(exp
, ir_unop_exp
, always_available
)
3888 UNOP(log
, ir_unop_log
, always_available
)
3889 UNOP(exp2
, ir_unop_exp2
, always_available
)
3890 UNOP(log2
, ir_unop_log2
, always_available
)
3891 UNOPA(sqrt
, ir_unop_sqrt
)
3892 UNOPA(inversesqrt
, ir_unop_rsq
)
3896 UNOPA(abs
, ir_unop_abs
)
3897 UNOPA(sign
, ir_unop_sign
)
3898 UNOPA(floor
, ir_unop_floor
)
3899 UNOPA(trunc
, ir_unop_trunc
)
3900 UNOPA(round
, ir_unop_round_even
)
3901 UNOPA(roundEven
, ir_unop_round_even
)
3902 UNOPA(ceil
, ir_unop_ceil
)
3903 UNOPA(fract
, ir_unop_fract
)
3905 ir_function_signature
*
3906 builtin_builder::_mod(builtin_available_predicate avail
,
3907 const glsl_type
*x_type
, const glsl_type
*y_type
)
3909 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
3912 ir_function_signature
*
3913 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3915 ir_variable
*x
= in_var(type
, "x");
3916 ir_variable
*i
= out_var(type
, "i");
3917 MAKE_SIG(type
, avail
, 2, x
, i
);
3919 ir_variable
*t
= body
.make_temp(type
, "t");
3920 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3921 body
.emit(assign(i
, t
));
3922 body
.emit(ret(sub(x
, t
)));
3927 ir_function_signature
*
3928 builtin_builder::_min(builtin_available_predicate avail
,
3929 const glsl_type
*x_type
, const glsl_type
*y_type
)
3931 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
3934 ir_function_signature
*
3935 builtin_builder::_max(builtin_available_predicate avail
,
3936 const glsl_type
*x_type
, const glsl_type
*y_type
)
3938 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
3941 ir_function_signature
*
3942 builtin_builder::_clamp(builtin_available_predicate avail
,
3943 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3945 ir_variable
*x
= in_var(val_type
, "x");
3946 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3947 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3948 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3950 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3955 ir_function_signature
*
3956 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3958 ir_variable
*x
= in_var(val_type
, "x");
3959 ir_variable
*y
= in_var(val_type
, "y");
3960 ir_variable
*a
= in_var(blend_type
, "a");
3961 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3963 body
.emit(ret(lrp(x
, y
, a
)));
3968 ir_function_signature
*
3969 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3970 const glsl_type
*val_type
,
3971 const glsl_type
*blend_type
)
3973 ir_variable
*x
= in_var(val_type
, "x");
3974 ir_variable
*y
= in_var(val_type
, "y");
3975 ir_variable
*a
= in_var(blend_type
, "a");
3976 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3978 /* csel matches the ternary operator in that a selector of true choses the
3979 * first argument. This differs from mix(x, y, false) which choses the
3980 * second argument (to remain consistent with the interpolating version of
3981 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3983 * To handle the behavior mismatch, reverse the x and y arguments.
3985 body
.emit(ret(csel(a
, y
, x
)));
3990 ir_function_signature
*
3991 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3993 ir_variable
*edge
= in_var(edge_type
, "edge");
3994 ir_variable
*x
= in_var(x_type
, "x");
3995 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3997 ir_variable
*t
= body
.make_temp(x_type
, "t");
3998 if (x_type
->vector_elements
== 1) {
3999 /* Both are floats */
4000 if (edge_type
->is_double())
4001 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
4003 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
4004 } else if (edge_type
->vector_elements
== 1) {
4005 /* x is a vector but edge is a float */
4006 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4007 if (edge_type
->is_double())
4008 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
4010 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
4013 /* Both are vectors */
4014 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4015 if (edge_type
->is_double())
4016 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
4019 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
4029 ir_function_signature
*
4030 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4032 ir_variable
*edge0
= in_var(edge_type
, "edge0");
4033 ir_variable
*edge1
= in_var(edge_type
, "edge1");
4034 ir_variable
*x
= in_var(x_type
, "x");
4035 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
4037 /* From the GLSL 1.10 specification:
4040 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
4041 * return t * t * (3 - 2 * t);
4044 ir_variable
*t
= body
.make_temp(x_type
, "t");
4045 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
4046 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
4048 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
4053 ir_function_signature
*
4054 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
4056 ir_variable
*x
= in_var(type
, "x");
4057 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4059 body
.emit(ret(nequal(x
, x
)));
4064 ir_function_signature
*
4065 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
4067 ir_variable
*x
= in_var(type
, "x");
4068 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4070 ir_constant_data infinities
;
4071 for (int i
= 0; i
< type
->vector_elements
; i
++) {
4072 switch (type
->base_type
) {
4073 case GLSL_TYPE_FLOAT
:
4074 infinities
.f
[i
] = INFINITY
;
4076 case GLSL_TYPE_DOUBLE
:
4077 infinities
.d
[i
] = INFINITY
;
4080 unreachable("unknown type");
4084 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
4089 ir_function_signature
*
4090 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
4092 ir_variable
*x
= in_var(type
, "x");
4093 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4094 body
.emit(ret(bitcast_f2i(x
)));
4098 ir_function_signature
*
4099 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
4101 ir_variable
*x
= in_var(type
, "x");
4102 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4103 body
.emit(ret(bitcast_f2u(x
)));
4107 ir_function_signature
*
4108 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
4110 ir_variable
*x
= in_var(type
, "x");
4111 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4112 body
.emit(ret(bitcast_i2f(x
)));
4116 ir_function_signature
*
4117 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
4119 ir_variable
*x
= in_var(type
, "x");
4120 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4121 body
.emit(ret(bitcast_u2f(x
)));
4125 ir_function_signature
*
4126 builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail
, const glsl_type
*type
)
4128 ir_variable
*x
= in_var(type
, "x");
4129 MAKE_SIG(glsl_type::i64vec(type
->vector_elements
), avail
, 1, x
);
4130 body
.emit(ret(bitcast_d2i64(x
)));
4134 ir_function_signature
*
4135 builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail
, const glsl_type
*type
)
4137 ir_variable
*x
= in_var(type
, "x");
4138 MAKE_SIG(glsl_type::u64vec(type
->vector_elements
), avail
, 1, x
);
4139 body
.emit(ret(bitcast_d2u64(x
)));
4143 ir_function_signature
*
4144 builtin_builder::_int64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4146 ir_variable
*x
= in_var(type
, "x");
4147 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4148 body
.emit(ret(bitcast_i642d(x
)));
4152 ir_function_signature
*
4153 builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4155 ir_variable
*x
= in_var(type
, "x");
4156 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4157 body
.emit(ret(bitcast_u642d(x
)));
4161 ir_function_signature
*
4162 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
4164 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4165 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4166 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
4170 ir_function_signature
*
4171 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
4173 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4174 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4175 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
4179 ir_function_signature
*
4180 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
4182 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4183 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4184 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
4188 ir_function_signature
*
4189 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
4191 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4192 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4193 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
4197 ir_function_signature
*
4198 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
4200 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4201 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4202 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
4206 ir_function_signature
*
4207 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
4209 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4210 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4211 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
4216 ir_function_signature
*
4217 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
4219 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4220 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4221 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
4225 ir_function_signature
*
4226 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
4228 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4229 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4230 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
4234 ir_function_signature
*
4235 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
4237 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4238 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4239 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
4243 ir_function_signature
*
4244 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
4246 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4247 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4248 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
4252 ir_function_signature
*
4253 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
4255 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4256 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
4257 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
4261 ir_function_signature
*
4262 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
4264 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
4265 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4266 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
4270 ir_function_signature
*
4271 builtin_builder::_packInt2x32(builtin_available_predicate avail
)
4273 ir_variable
*v
= in_var(glsl_type::ivec2_type
, "v");
4274 MAKE_SIG(glsl_type::int64_t_type
, avail
, 1, v
);
4275 body
.emit(ret(expr(ir_unop_pack_int_2x32
, v
)));
4279 ir_function_signature
*
4280 builtin_builder::_unpackInt2x32(builtin_available_predicate avail
)
4282 ir_variable
*p
= in_var(glsl_type::int64_t_type
, "p");
4283 MAKE_SIG(glsl_type::ivec2_type
, avail
, 1, p
);
4284 body
.emit(ret(expr(ir_unop_unpack_int_2x32
, p
)));
4288 ir_function_signature
*
4289 builtin_builder::_packUint2x32(builtin_available_predicate avail
)
4291 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4292 MAKE_SIG(glsl_type::uint64_t_type
, avail
, 1, v
);
4293 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, v
)));
4297 ir_function_signature
*
4298 builtin_builder::_unpackUint2x32(builtin_available_predicate avail
)
4300 ir_variable
*p
= in_var(glsl_type::uint64_t_type
, "p");
4301 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4302 body
.emit(ret(expr(ir_unop_unpack_uint_2x32
, p
)));
4306 ir_function_signature
*
4307 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
4309 ir_variable
*x
= in_var(type
, "x");
4310 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
4312 body
.emit(ret(sqrt(dot(x
, x
))));
4317 ir_function_signature
*
4318 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
4320 ir_variable
*p0
= in_var(type
, "p0");
4321 ir_variable
*p1
= in_var(type
, "p1");
4322 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
4324 if (type
->vector_elements
== 1) {
4325 body
.emit(ret(abs(sub(p0
, p1
))));
4327 ir_variable
*p
= body
.make_temp(type
, "p");
4328 body
.emit(assign(p
, sub(p0
, p1
)));
4329 body
.emit(ret(sqrt(dot(p
, p
))));
4335 ir_function_signature
*
4336 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
4338 if (type
->vector_elements
== 1)
4339 return binop(avail
, ir_binop_mul
, type
, type
, type
);
4341 return binop(avail
, ir_binop_dot
,
4342 type
->get_base_type(), type
, type
);
4345 ir_function_signature
*
4346 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
4348 ir_variable
*a
= in_var(type
, "a");
4349 ir_variable
*b
= in_var(type
, "b");
4350 MAKE_SIG(type
, avail
, 2, a
, b
);
4352 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
4353 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
4355 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
4356 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
4361 ir_function_signature
*
4362 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
4364 ir_variable
*x
= in_var(type
, "x");
4365 MAKE_SIG(type
, avail
, 1, x
);
4367 if (type
->vector_elements
== 1) {
4368 body
.emit(ret(sign(x
)));
4370 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
4376 ir_function_signature
*
4377 builtin_builder::_ftransform()
4379 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
4381 /* ftransform() refers to global variables, and is always emitted
4382 * directly by ast_function.cpp. Just emit a prototype here so we
4383 * can recognize calls to it.
4388 ir_function_signature
*
4389 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
4391 ir_variable
*N
= in_var(type
, "N");
4392 ir_variable
*I
= in_var(type
, "I");
4393 ir_variable
*Nref
= in_var(type
, "Nref");
4394 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
4396 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
4397 ret(N
), ret(neg(N
))));
4402 ir_function_signature
*
4403 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
4405 ir_variable
*I
= in_var(type
, "I");
4406 ir_variable
*N
= in_var(type
, "N");
4407 MAKE_SIG(type
, avail
, 2, I
, N
);
4409 /* I - 2 * dot(N, I) * N */
4410 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
4415 ir_function_signature
*
4416 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
4418 ir_variable
*I
= in_var(type
, "I");
4419 ir_variable
*N
= in_var(type
, "N");
4420 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
4421 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4423 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4424 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4426 /* From the GLSL 1.10 specification:
4427 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4429 * return genType(0.0)
4431 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4433 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4434 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4435 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4436 mul(n_dot_i
, n_dot_i
)))))));
4437 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4438 ret(ir_constant::zero(mem_ctx
, type
)),
4439 ret(sub(mul(eta
, I
),
4440 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4445 ir_function_signature
*
4446 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4448 ir_variable
*x
= in_var(type
, "x");
4449 ir_variable
*y
= in_var(type
, "y");
4450 MAKE_SIG(type
, avail
, 2, x
, y
);
4452 ir_variable
*z
= body
.make_temp(type
, "z");
4453 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4454 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4461 ir_function_signature
*
4462 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4467 if (type
->is_double()) {
4468 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4469 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4471 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4472 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4474 MAKE_SIG(type
, avail
, 2, c
, r
);
4476 ir_variable
*m
= body
.make_temp(type
, "m");
4477 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4478 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4485 ir_function_signature
*
4486 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4488 const glsl_type
*transpose_type
=
4489 glsl_type::get_instance(orig_type
->base_type
,
4490 orig_type
->matrix_columns
,
4491 orig_type
->vector_elements
);
4493 ir_variable
*m
= in_var(orig_type
, "m");
4494 MAKE_SIG(transpose_type
, avail
, 1, m
);
4496 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4497 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4498 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4499 body
.emit(assign(array_ref(t
, j
),
4500 matrix_elt(m
, i
, j
),
4509 ir_function_signature
*
4510 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4512 ir_variable
*m
= in_var(type
, "m");
4513 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4515 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4516 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4521 ir_function_signature
*
4522 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4524 ir_variable
*m
= in_var(type
, "m");
4525 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4528 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4529 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4532 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4533 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4536 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4537 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4539 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4540 mul(matrix_elt(m
, 0, 1), f2
)),
4541 mul(matrix_elt(m
, 0, 2), f3
))));
4546 ir_function_signature
*
4547 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4549 ir_variable
*m
= in_var(type
, "m");
4550 const glsl_type
*btype
= type
->get_base_type();
4551 MAKE_SIG(btype
, avail
, 1, m
);
4553 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4554 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4555 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4556 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4557 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4558 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4559 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4560 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4561 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4562 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4563 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4564 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4565 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4566 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4567 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4568 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4569 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4570 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4571 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4573 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)))));
4574 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)))));
4575 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)))));
4576 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)))));
4577 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)))));
4578 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)))));
4579 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)))));
4580 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)))));
4581 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)))));
4582 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)))));
4583 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)))));
4584 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)))));
4585 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)))));
4586 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)))));
4587 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)))));
4588 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)))));
4589 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)))));
4590 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)))));
4591 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)))));
4593 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4595 body
.emit(assign(adj_0
,
4596 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4597 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4598 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4600 body
.emit(assign(adj_0
, neg(
4601 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4602 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4603 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4605 body
.emit(assign(adj_0
,
4606 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4607 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4608 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4610 body
.emit(assign(adj_0
, neg(
4611 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4612 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4613 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4616 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4621 ir_function_signature
*
4622 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4624 ir_variable
*m
= in_var(type
, "m");
4625 MAKE_SIG(type
, avail
, 1, m
);
4627 ir_variable
*adj
= body
.make_temp(type
, "adj");
4628 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4629 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4630 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4631 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4633 ir_expression
*det
=
4634 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4635 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4637 body
.emit(ret(div(adj
, det
)));
4641 ir_function_signature
*
4642 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4644 ir_variable
*m
= in_var(type
, "m");
4645 const glsl_type
*btype
= type
->get_base_type();
4646 MAKE_SIG(type
, avail
, 1, m
);
4648 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4649 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4650 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4652 body
.emit(assign(f11_22_21_12
,
4653 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4654 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4655 body
.emit(assign(f10_22_20_12
,
4656 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4657 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4658 body
.emit(assign(f10_21_20_11
,
4659 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4660 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4662 ir_variable
*adj
= body
.make_temp(type
, "adj");
4663 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4664 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4665 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4667 body
.emit(assign(array_ref(adj
, 0), neg(
4668 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4669 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4671 body
.emit(assign(array_ref(adj
, 1),
4672 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4673 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4675 body
.emit(assign(array_ref(adj
, 2), neg(
4676 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4677 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4680 body
.emit(assign(array_ref(adj
, 0),
4681 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4682 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4684 body
.emit(assign(array_ref(adj
, 1), neg(
4685 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4686 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4688 body
.emit(assign(array_ref(adj
, 2),
4689 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4690 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4693 ir_expression
*det
=
4694 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4695 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4696 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4698 body
.emit(ret(div(adj
, det
)));
4703 ir_function_signature
*
4704 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4706 ir_variable
*m
= in_var(type
, "m");
4707 const glsl_type
*btype
= type
->get_base_type();
4708 MAKE_SIG(type
, avail
, 1, m
);
4710 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4711 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4712 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4713 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4714 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4715 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4716 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4717 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4718 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4719 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4720 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4721 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4722 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4723 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4724 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4725 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4726 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4727 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4728 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4730 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)))));
4731 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)))));
4732 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)))));
4733 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)))));
4734 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)))));
4735 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)))));
4736 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)))));
4737 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)))));
4738 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)))));
4739 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)))));
4740 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)))));
4741 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)))));
4742 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)))));
4743 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)))));
4744 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)))));
4745 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)))));
4746 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)))));
4747 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)))));
4748 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)))));
4750 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4751 body
.emit(assign(array_ref(adj
, 0),
4752 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4753 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4754 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4756 body
.emit(assign(array_ref(adj
, 1), neg(
4757 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4758 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4759 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4761 body
.emit(assign(array_ref(adj
, 2),
4762 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4763 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4764 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4766 body
.emit(assign(array_ref(adj
, 3), neg(
4767 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4768 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4769 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4772 body
.emit(assign(array_ref(adj
, 0), neg(
4773 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4774 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4775 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4777 body
.emit(assign(array_ref(adj
, 1),
4778 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4779 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4780 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4782 body
.emit(assign(array_ref(adj
, 2), neg(
4783 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4784 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4785 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4787 body
.emit(assign(array_ref(adj
, 3),
4788 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4789 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4790 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4793 body
.emit(assign(array_ref(adj
, 0),
4794 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4795 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4796 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4798 body
.emit(assign(array_ref(adj
, 1), neg(
4799 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4800 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4801 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4803 body
.emit(assign(array_ref(adj
, 2),
4804 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4805 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4806 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4808 body
.emit(assign(array_ref(adj
, 3), neg(
4809 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4810 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4811 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4814 body
.emit(assign(array_ref(adj
, 0), neg(
4815 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4816 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4817 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4819 body
.emit(assign(array_ref(adj
, 1),
4820 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4821 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4822 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4824 body
.emit(assign(array_ref(adj
, 2), neg(
4825 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4826 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4827 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4829 body
.emit(assign(array_ref(adj
, 3),
4830 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4831 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4832 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4835 ir_expression
*det
=
4836 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4837 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4838 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4839 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4841 body
.emit(ret(div(adj
, det
)));
4847 ir_function_signature
*
4848 builtin_builder::_lessThan(builtin_available_predicate avail
,
4849 const glsl_type
*type
)
4851 return binop(avail
, ir_binop_less
,
4852 glsl_type::bvec(type
->vector_elements
), type
, type
);
4855 ir_function_signature
*
4856 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4857 const glsl_type
*type
)
4859 return binop(avail
, ir_binop_lequal
,
4860 glsl_type::bvec(type
->vector_elements
), type
, type
);
4863 ir_function_signature
*
4864 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4865 const glsl_type
*type
)
4867 return binop(avail
, ir_binop_greater
,
4868 glsl_type::bvec(type
->vector_elements
), type
, type
);
4871 ir_function_signature
*
4872 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4873 const glsl_type
*type
)
4875 return binop(avail
, ir_binop_gequal
,
4876 glsl_type::bvec(type
->vector_elements
), type
, type
);
4879 ir_function_signature
*
4880 builtin_builder::_equal(builtin_available_predicate avail
,
4881 const glsl_type
*type
)
4883 return binop(avail
, ir_binop_equal
,
4884 glsl_type::bvec(type
->vector_elements
), type
, type
);
4887 ir_function_signature
*
4888 builtin_builder::_notEqual(builtin_available_predicate avail
,
4889 const glsl_type
*type
)
4891 return binop(avail
, ir_binop_nequal
,
4892 glsl_type::bvec(type
->vector_elements
), type
, type
);
4895 ir_function_signature
*
4896 builtin_builder::_any(const glsl_type
*type
)
4898 ir_variable
*v
= in_var(type
, "v");
4899 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4901 const unsigned vec_elem
= v
->type
->vector_elements
;
4902 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
4907 ir_function_signature
*
4908 builtin_builder::_all(const glsl_type
*type
)
4910 ir_variable
*v
= in_var(type
, "v");
4911 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4913 const unsigned vec_elem
= v
->type
->vector_elements
;
4914 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
4919 UNOP(not, ir_unop_logic_not
, always_available
)
4922 has_lod(const glsl_type
*sampler_type
)
4924 assert(sampler_type
->is_sampler());
4926 switch (sampler_type
->sampler_dimensionality
) {
4927 case GLSL_SAMPLER_DIM_RECT
:
4928 case GLSL_SAMPLER_DIM_BUF
:
4929 case GLSL_SAMPLER_DIM_MS
:
4936 ir_function_signature
*
4937 builtin_builder::_textureSize(builtin_available_predicate avail
,
4938 const glsl_type
*return_type
,
4939 const glsl_type
*sampler_type
)
4941 ir_variable
*s
= in_var(sampler_type
, "sampler");
4942 /* The sampler always exists; add optional lod later. */
4943 MAKE_SIG(return_type
, avail
, 1, s
);
4945 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4946 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4948 if (has_lod(sampler_type
)) {
4949 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4950 sig
->parameters
.push_tail(lod
);
4951 tex
->lod_info
.lod
= var_ref(lod
);
4953 tex
->lod_info
.lod
= imm(0u);
4956 body
.emit(ret(tex
));
4961 ir_function_signature
*
4962 builtin_builder::_textureSamples(builtin_available_predicate avail
,
4963 const glsl_type
*sampler_type
)
4965 ir_variable
*s
= in_var(sampler_type
, "sampler");
4966 MAKE_SIG(glsl_type::int_type
, avail
, 1, s
);
4968 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4969 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4970 body
.emit(ret(tex
));
4975 ir_function_signature
*
4976 builtin_builder::_texture(ir_texture_opcode opcode
,
4977 builtin_available_predicate avail
,
4978 const glsl_type
*return_type
,
4979 const glsl_type
*sampler_type
,
4980 const glsl_type
*coord_type
,
4983 ir_variable
*s
= in_var(sampler_type
, "sampler");
4984 ir_variable
*P
= in_var(coord_type
, "P");
4985 /* The sampler and coordinate always exist; add optional parameters later. */
4986 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4988 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4989 tex
->set_sampler(var_ref(s
), return_type
);
4991 const int coord_size
= sampler_type
->coordinate_components();
4993 if (coord_size
== coord_type
->vector_elements
) {
4994 tex
->coordinate
= var_ref(P
);
4996 /* The incoming coordinate also has the projector or shadow comparator,
4997 * so we need to swizzle those away.
4999 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
5002 /* The projector is always in the last component. */
5003 if (flags
& TEX_PROJECT
)
5004 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
5006 if (sampler_type
->sampler_shadow
) {
5007 if (opcode
== ir_tg4
) {
5008 /* gather has refz as a separate parameter, immediately after the
5011 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
5012 sig
->parameters
.push_tail(refz
);
5013 tex
->shadow_comparator
= var_ref(refz
);
5015 /* The shadow comparator is normally in the Z component, but a few types
5016 * have sufficiently large coordinates that it's in W.
5018 tex
->shadow_comparator
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
5022 if (opcode
== ir_txl
) {
5023 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
5024 sig
->parameters
.push_tail(lod
);
5025 tex
->lod_info
.lod
= var_ref(lod
);
5026 } else if (opcode
== ir_txd
) {
5027 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5028 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
5029 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
5030 sig
->parameters
.push_tail(dPdx
);
5031 sig
->parameters
.push_tail(dPdy
);
5032 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
5033 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
5036 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
5037 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5038 ir_variable
*offset
=
5039 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
5040 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
5041 sig
->parameters
.push_tail(offset
);
5042 tex
->offset
= var_ref(offset
);
5045 if (flags
& TEX_OFFSET_ARRAY
) {
5046 ir_variable
*offsets
=
5047 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
5048 "offsets", ir_var_const_in
);
5049 sig
->parameters
.push_tail(offsets
);
5050 tex
->offset
= var_ref(offsets
);
5053 if (opcode
== ir_tg4
) {
5054 if (flags
& TEX_COMPONENT
) {
5055 ir_variable
*component
=
5056 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
5057 sig
->parameters
.push_tail(component
);
5058 tex
->lod_info
.component
= var_ref(component
);
5061 tex
->lod_info
.component
= imm(0);
5065 /* The "bias" parameter comes /after/ the "offset" parameter, which is
5066 * inconsistent with both textureLodOffset and textureGradOffset.
5068 if (opcode
== ir_txb
) {
5069 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
5070 sig
->parameters
.push_tail(bias
);
5071 tex
->lod_info
.bias
= var_ref(bias
);
5074 body
.emit(ret(tex
));
5079 ir_function_signature
*
5080 builtin_builder::_textureCubeArrayShadow(builtin_available_predicate avail
,
5081 const glsl_type
*sampler_type
)
5083 ir_variable
*s
= in_var(sampler_type
, "sampler");
5084 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
5085 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
5086 MAKE_SIG(glsl_type::float_type
, avail
, 3, s
, P
, compare
);
5088 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
5089 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
5091 tex
->coordinate
= var_ref(P
);
5092 tex
->shadow_comparator
= var_ref(compare
);
5094 body
.emit(ret(tex
));
5099 ir_function_signature
*
5100 builtin_builder::_texelFetch(builtin_available_predicate avail
,
5101 const glsl_type
*return_type
,
5102 const glsl_type
*sampler_type
,
5103 const glsl_type
*coord_type
,
5104 const glsl_type
*offset_type
)
5106 ir_variable
*s
= in_var(sampler_type
, "sampler");
5107 ir_variable
*P
= in_var(coord_type
, "P");
5108 /* The sampler and coordinate always exist; add optional parameters later. */
5109 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5111 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
5112 tex
->coordinate
= var_ref(P
);
5113 tex
->set_sampler(var_ref(s
), return_type
);
5115 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
5116 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
5117 sig
->parameters
.push_tail(sample
);
5118 tex
->lod_info
.sample_index
= var_ref(sample
);
5119 tex
->op
= ir_txf_ms
;
5120 } else if (has_lod(sampler_type
)) {
5121 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5122 sig
->parameters
.push_tail(lod
);
5123 tex
->lod_info
.lod
= var_ref(lod
);
5125 tex
->lod_info
.lod
= imm(0u);
5128 if (offset_type
!= NULL
) {
5129 ir_variable
*offset
=
5130 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
5131 sig
->parameters
.push_tail(offset
);
5132 tex
->offset
= var_ref(offset
);
5135 body
.emit(ret(tex
));
5140 ir_function_signature
*
5141 builtin_builder::_EmitVertex()
5143 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5145 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5146 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
5151 ir_function_signature
*
5152 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
5153 const glsl_type
*stream_type
)
5155 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5157 * "Emit the current values of output variables to the current output
5158 * primitive on stream stream. The argument to stream must be a constant
5159 * integral expression."
5161 ir_variable
*stream
=
5162 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5164 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5166 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
5171 ir_function_signature
*
5172 builtin_builder::_EndPrimitive()
5174 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5176 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5177 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
5182 ir_function_signature
*
5183 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
5184 const glsl_type
*stream_type
)
5186 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5188 * "Completes the current output primitive on stream stream and starts
5189 * a new one. The argument to stream must be a constant integral
5192 ir_variable
*stream
=
5193 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5195 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5197 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
5202 ir_function_signature
*
5203 builtin_builder::_barrier()
5205 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
5207 body
.emit(new(mem_ctx
) ir_barrier());
5211 ir_function_signature
*
5212 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
5213 const glsl_type
*sampler_type
,
5214 const glsl_type
*coord_type
)
5216 ir_variable
*s
= in_var(sampler_type
, "sampler");
5217 ir_variable
*coord
= in_var(coord_type
, "coord");
5218 /* The sampler and coordinate always exist; add optional parameters later. */
5219 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
5221 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
5222 tex
->coordinate
= var_ref(coord
);
5223 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
5225 body
.emit(ret(tex
));
5230 ir_function_signature
*
5231 builtin_builder::_textureQueryLevels(builtin_available_predicate avail
,
5232 const glsl_type
*sampler_type
)
5234 ir_variable
*s
= in_var(sampler_type
, "sampler");
5235 const glsl_type
*return_type
= glsl_type::int_type
;
5236 MAKE_SIG(return_type
, avail
, 1, s
);
5238 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
5239 tex
->set_sampler(var_ref(s
), return_type
);
5241 body
.emit(ret(tex
));
5246 ir_function_signature
*
5247 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
5248 const glsl_type
*sampler_type
,
5249 const glsl_type
*coord_type
)
5251 ir_variable
*s
= in_var(sampler_type
, "sampler");
5252 ir_variable
*P
= in_var(coord_type
, "P");
5253 const glsl_type
*return_type
= glsl_type::bool_type
;
5254 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5256 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
5257 tex
->coordinate
= var_ref(P
);
5258 tex
->set_sampler(var_ref(s
), return_type
);
5260 body
.emit(ret(tex
));
5265 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
5266 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
5267 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
5268 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
5269 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
5270 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
5272 ir_function_signature
*
5273 builtin_builder::_fwidth(const glsl_type
*type
)
5275 ir_variable
*p
= in_var(type
, "p");
5276 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
5278 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
5283 ir_function_signature
*
5284 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
5286 ir_variable
*p
= in_var(type
, "p");
5287 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5289 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
5290 abs(expr(ir_unop_dFdy_coarse
, p
)))));
5295 ir_function_signature
*
5296 builtin_builder::_fwidthFine(const glsl_type
*type
)
5298 ir_variable
*p
= in_var(type
, "p");
5299 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5301 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
5302 abs(expr(ir_unop_dFdy_fine
, p
)))));
5307 ir_function_signature
*
5308 builtin_builder::_noise1(const glsl_type
*type
)
5310 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
5313 ir_function_signature
*
5314 builtin_builder::_noise2(const glsl_type
*type
)
5316 ir_variable
*p
= in_var(type
, "p");
5317 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
5319 ir_constant_data b_offset
;
5320 b_offset
.f
[0] = 601.0f
;
5321 b_offset
.f
[1] = 313.0f
;
5322 b_offset
.f
[2] = 29.0f
;
5323 b_offset
.f
[3] = 277.0f
;
5325 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5326 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5327 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
5328 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5329 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5330 body
.emit(assign(t
, a
, WRITEMASK_X
));
5331 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5337 ir_function_signature
*
5338 builtin_builder::_noise3(const glsl_type
*type
)
5340 ir_variable
*p
= in_var(type
, "p");
5341 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
5343 ir_constant_data b_offset
;
5344 b_offset
.f
[0] = 601.0f
;
5345 b_offset
.f
[1] = 313.0f
;
5346 b_offset
.f
[2] = 29.0f
;
5347 b_offset
.f
[3] = 277.0f
;
5349 ir_constant_data c_offset
;
5350 c_offset
.f
[0] = 1559.0f
;
5351 c_offset
.f
[1] = 113.0f
;
5352 c_offset
.f
[2] = 1861.0f
;
5353 c_offset
.f
[3] = 797.0f
;
5355 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5356 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5357 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5358 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
5359 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5360 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5361 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
5362 body
.emit(assign(t
, a
, WRITEMASK_X
));
5363 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5364 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5370 ir_function_signature
*
5371 builtin_builder::_noise4(const glsl_type
*type
)
5373 ir_variable
*p
= in_var(type
, "p");
5374 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
5376 ir_variable
*_p
= body
.make_temp(type
, "_p");
5378 ir_constant_data p_offset
;
5379 p_offset
.f
[0] = 1559.0f
;
5380 p_offset
.f
[1] = 113.0f
;
5381 p_offset
.f
[2] = 1861.0f
;
5382 p_offset
.f
[3] = 797.0f
;
5384 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
5386 ir_constant_data offset
;
5387 offset
.f
[0] = 601.0f
;
5388 offset
.f
[1] = 313.0f
;
5389 offset
.f
[2] = 29.0f
;
5390 offset
.f
[3] = 277.0f
;
5392 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5393 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5394 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5395 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
5396 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
5397 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5398 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
5399 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
5400 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
5401 body
.emit(assign(t
, a
, WRITEMASK_X
));
5402 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5403 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5404 body
.emit(assign(t
, d
, WRITEMASK_W
));
5410 ir_function_signature
*
5411 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
5413 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5414 ir_variable
*value
= in_var(type
, "value");
5415 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5416 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5417 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, value
, offset
,
5420 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5421 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5423 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
5424 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5425 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5430 ir_function_signature
*
5431 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5433 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5434 ir_variable
*base
= in_var(type
, "base");
5435 ir_variable
*insert
= in_var(type
, "insert");
5436 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5437 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5438 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 4, base
, insert
,
5441 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5442 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5444 body
.emit(ret(bitfield_insert(base
, insert
,
5445 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5446 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5451 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31_or_integer_functions
)
5453 ir_function_signature
*
5454 builtin_builder::_bitCount(const glsl_type
*type
)
5456 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_bit_count
,
5457 glsl_type::ivec(type
->vector_elements
), type
);
5460 ir_function_signature
*
5461 builtin_builder::_findLSB(const glsl_type
*type
)
5463 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_lsb
,
5464 glsl_type::ivec(type
->vector_elements
), type
);
5467 ir_function_signature
*
5468 builtin_builder::_findMSB(const glsl_type
*type
)
5470 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_msb
,
5471 glsl_type::ivec(type
->vector_elements
), type
);
5474 ir_function_signature
*
5475 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5477 ir_variable
*a
= in_var(type
, "a");
5478 ir_variable
*b
= in_var(type
, "b");
5479 ir_variable
*c
= in_var(type
, "c");
5480 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5482 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5487 ir_function_signature
*
5488 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5490 return binop(x_type
->is_double() ? fp64
: gpu_shader5_or_es31_or_integer_functions
,
5491 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5494 ir_function_signature
*
5495 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5497 ir_variable
*x
= in_var(x_type
, "x");
5498 ir_variable
*exponent
= out_var(exp_type
, "exp");
5499 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5501 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5503 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5507 ir_function_signature
*
5508 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5510 ir_variable
*x
= in_var(x_type
, "x");
5511 ir_variable
*exponent
= out_var(exp_type
, "exp");
5512 MAKE_SIG(x_type
, gpu_shader5_or_es31_or_integer_functions
, 2, x
, exponent
);
5514 const unsigned vec_elem
= x_type
->vector_elements
;
5515 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5516 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5518 /* Single-precision floating-point values are stored as
5523 * An exponent shift of 23 will shift the mantissa out, leaving only the
5524 * exponent and sign bit (which itself may be zero, if the absolute value
5525 * was taken before the bitcast and shift.
5527 ir_constant
*exponent_shift
= imm(23);
5528 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5530 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5532 /* Exponent of floating-point values in the range [0.5, 1.0). */
5533 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5535 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5536 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5538 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5539 * to unsigned integers to ensure that 1 bits aren't shifted in.
5541 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5542 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5543 imm(0, vec_elem
)))));
5545 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5546 body
.emit(assign(bits
, bitcast_f2u(x
)));
5547 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5548 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5549 imm(0u, vec_elem
)))));
5550 body
.emit(ret(bitcast_u2f(bits
)));
5555 ir_function_signature
*
5556 builtin_builder::_uaddCarry(const glsl_type
*type
)
5558 ir_variable
*x
= in_var(type
, "x");
5559 ir_variable
*y
= in_var(type
, "y");
5560 ir_variable
*carry
= out_var(type
, "carry");
5561 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, carry
);
5563 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5564 body
.emit(ret(add(x
, y
)));
5569 ir_function_signature
*
5570 builtin_builder::_usubBorrow(const glsl_type
*type
)
5572 ir_variable
*x
= in_var(type
, "x");
5573 ir_variable
*y
= in_var(type
, "y");
5574 ir_variable
*borrow
= out_var(type
, "borrow");
5575 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, borrow
);
5577 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5578 body
.emit(ret(sub(x
, y
)));
5584 * For both imulExtended() and umulExtended() built-ins.
5586 ir_function_signature
*
5587 builtin_builder::_mulExtended(const glsl_type
*type
)
5589 ir_variable
*x
= in_var(type
, "x");
5590 ir_variable
*y
= in_var(type
, "y");
5591 ir_variable
*msb
= out_var(type
, "msb");
5592 ir_variable
*lsb
= out_var(type
, "lsb");
5593 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31_or_integer_functions
, 4, x
, y
, msb
, lsb
);
5595 body
.emit(assign(msb
, imul_high(x
, y
)));
5596 body
.emit(assign(lsb
, mul(x
, y
)));
5601 ir_function_signature
*
5602 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5604 ir_variable
*interpolant
= in_var(type
, "interpolant");
5605 interpolant
->data
.must_be_shader_input
= 1;
5606 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5608 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5613 ir_function_signature
*
5614 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5616 ir_variable
*interpolant
= in_var(type
, "interpolant");
5617 interpolant
->data
.must_be_shader_input
= 1;
5618 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5619 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5621 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5626 ir_function_signature
*
5627 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5629 ir_variable
*interpolant
= in_var(type
, "interpolant");
5630 interpolant
->data
.must_be_shader_input
= 1;
5631 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5632 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5634 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5639 ir_function_signature
*
5640 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
,
5641 enum ir_intrinsic_id id
)
5643 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5644 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 1, counter
);
5648 ir_function_signature
*
5649 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
,
5650 enum ir_intrinsic_id id
)
5652 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5653 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5654 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 2, counter
, data
);
5658 ir_function_signature
*
5659 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
,
5660 enum ir_intrinsic_id id
)
5662 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5663 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5664 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5665 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 3, counter
, compare
, data
);
5669 ir_function_signature
*
5670 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5671 const glsl_type
*type
,
5672 enum ir_intrinsic_id id
)
5674 ir_variable
*atomic
= in_var(type
, "atomic");
5675 ir_variable
*data
= in_var(type
, "data");
5676 MAKE_INTRINSIC(type
, id
, avail
, 2, atomic
, data
);
5680 ir_function_signature
*
5681 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5682 const glsl_type
*type
,
5683 enum ir_intrinsic_id id
)
5685 ir_variable
*atomic
= in_var(type
, "atomic");
5686 ir_variable
*data1
= in_var(type
, "data1");
5687 ir_variable
*data2
= in_var(type
, "data2");
5688 MAKE_INTRINSIC(type
, id
, avail
, 3, atomic
, data1
, data2
);
5692 ir_function_signature
*
5693 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5694 builtin_available_predicate avail
)
5696 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5697 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5699 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5700 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5702 body
.emit(ret(retval
));
5706 ir_function_signature
*
5707 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5708 builtin_available_predicate avail
)
5710 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5711 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5712 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5714 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5716 /* Instead of generating an __intrinsic_atomic_sub, generate an
5717 * __intrinsic_atomic_add with the data parameter negated.
5719 if (strcmp("__intrinsic_atomic_sub", intrinsic
) == 0) {
5720 ir_variable
*const neg_data
=
5721 body
.make_temp(glsl_type::uint_type
, "neg_data");
5723 body
.emit(assign(neg_data
, neg(data
)));
5725 exec_list parameters
;
5727 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(counter
));
5728 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(neg_data
));
5730 ir_function
*const func
=
5731 shader
->symbols
->get_function("__intrinsic_atomic_add");
5732 ir_instruction
*const c
= call(func
, retval
, parameters
);
5735 assert(parameters
.is_empty());
5739 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5743 body
.emit(ret(retval
));
5747 ir_function_signature
*
5748 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
5749 builtin_available_predicate avail
)
5751 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5752 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5753 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5754 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5756 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5757 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5759 body
.emit(ret(retval
));
5763 ir_function_signature
*
5764 builtin_builder::_atomic_op2(const char *intrinsic
,
5765 builtin_available_predicate avail
,
5766 const glsl_type
*type
)
5768 ir_variable
*atomic
= in_var(type
, "atomic_var");
5769 ir_variable
*data
= in_var(type
, "atomic_data");
5770 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5772 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5773 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5775 body
.emit(ret(retval
));
5779 ir_function_signature
*
5780 builtin_builder::_atomic_op3(const char *intrinsic
,
5781 builtin_available_predicate avail
,
5782 const glsl_type
*type
)
5784 ir_variable
*atomic
= in_var(type
, "atomic_var");
5785 ir_variable
*data1
= in_var(type
, "atomic_data1");
5786 ir_variable
*data2
= in_var(type
, "atomic_data2");
5787 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5789 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5790 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5792 body
.emit(ret(retval
));
5796 ir_function_signature
*
5797 builtin_builder::_min3(const glsl_type
*type
)
5799 ir_variable
*x
= in_var(type
, "x");
5800 ir_variable
*y
= in_var(type
, "y");
5801 ir_variable
*z
= in_var(type
, "z");
5802 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5804 ir_expression
*min3
= min2(x
, min2(y
,z
));
5805 body
.emit(ret(min3
));
5810 ir_function_signature
*
5811 builtin_builder::_max3(const glsl_type
*type
)
5813 ir_variable
*x
= in_var(type
, "x");
5814 ir_variable
*y
= in_var(type
, "y");
5815 ir_variable
*z
= in_var(type
, "z");
5816 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5818 ir_expression
*max3
= max2(x
, max2(y
,z
));
5819 body
.emit(ret(max3
));
5824 ir_function_signature
*
5825 builtin_builder::_mid3(const glsl_type
*type
)
5827 ir_variable
*x
= in_var(type
, "x");
5828 ir_variable
*y
= in_var(type
, "y");
5829 ir_variable
*z
= in_var(type
, "z");
5830 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5832 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5833 body
.emit(ret(mid3
));
5838 static builtin_available_predicate
5839 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
5841 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
5842 type
->sampled_type
== GLSL_TYPE_FLOAT
)
5843 return shader_image_atomic_exchange_float
;
5845 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
5846 IMAGE_FUNCTION_AVAIL_ATOMIC
))
5847 return shader_image_atomic
;
5850 return shader_image_load_store
;
5853 ir_function_signature
*
5854 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5855 unsigned num_arguments
,
5858 const glsl_type
*data_type
= glsl_type::get_instance(
5859 image_type
->sampled_type
,
5860 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5862 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5863 glsl_type::void_type
: data_type
);
5865 /* Addressing arguments that are always present. */
5866 ir_variable
*image
= in_var(image_type
, "image");
5867 ir_variable
*coord
= in_var(
5868 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5870 ir_function_signature
*sig
= new_sig(
5871 ret_type
, get_image_available_predicate(image_type
, flags
),
5874 /* Sample index for multisample images. */
5875 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5876 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5878 /* Data arguments. */
5879 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5880 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5881 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5882 ralloc_free(arg_name
);
5885 /* Set the maximal set of qualifiers allowed for this image
5886 * built-in. Function calls with arguments having fewer
5887 * qualifiers than present in the prototype are allowed by the
5888 * spec, but not with more, i.e. this will make the compiler
5889 * accept everything that needs to be accepted, and reject cases
5890 * like loads from write-only or stores to read-only images.
5892 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5893 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5894 image
->data
.image_coherent
= true;
5895 image
->data
.image_volatile
= true;
5896 image
->data
.image_restrict
= true;
5901 ir_function_signature
*
5902 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5903 unsigned /* num_arguments */,
5904 unsigned /* flags */)
5906 const glsl_type
*ret_type
;
5907 unsigned num_components
= image_type
->coordinate_components();
5909 /* From the ARB_shader_image_size extension:
5910 * "Cube images return the dimensions of one face."
5912 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5913 !image_type
->sampler_array
) {
5917 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5918 * supported by mesa.
5920 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5922 ir_variable
*image
= in_var(image_type
, "image");
5923 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5925 /* Set the maximal set of qualifiers allowed for this image
5926 * built-in. Function calls with arguments having fewer
5927 * qualifiers than present in the prototype are allowed by the
5928 * spec, but not with more, i.e. this will make the compiler
5929 * accept everything that needs to be accepted, and reject cases
5930 * like loads from write-only or stores to read-only images.
5932 image
->data
.image_read_only
= true;
5933 image
->data
.image_write_only
= true;
5934 image
->data
.image_coherent
= true;
5935 image
->data
.image_volatile
= true;
5936 image
->data
.image_restrict
= true;
5941 ir_function_signature
*
5942 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5943 unsigned /* num_arguments */,
5944 unsigned /* flags */)
5946 ir_variable
*image
= in_var(image_type
, "image");
5947 ir_function_signature
*sig
=
5948 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5950 /* Set the maximal set of qualifiers allowed for this image
5951 * built-in. Function calls with arguments having fewer
5952 * qualifiers than present in the prototype are allowed by the
5953 * spec, but not with more, i.e. this will make the compiler
5954 * accept everything that needs to be accepted, and reject cases
5955 * like loads from write-only or stores to read-only images.
5957 image
->data
.image_read_only
= true;
5958 image
->data
.image_write_only
= true;
5959 image
->data
.image_coherent
= true;
5960 image
->data
.image_volatile
= true;
5961 image
->data
.image_restrict
= true;
5966 ir_function_signature
*
5967 builtin_builder::_image(image_prototype_ctr prototype
,
5968 const glsl_type
*image_type
,
5969 const char *intrinsic_name
,
5970 unsigned num_arguments
,
5972 enum ir_intrinsic_id id
)
5974 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5975 num_arguments
, flags
);
5977 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5978 ir_factory
body(&sig
->body
, mem_ctx
);
5979 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5981 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5982 body
.emit(call(f
, NULL
, sig
->parameters
));
5984 ir_variable
*ret_val
=
5985 body
.make_temp(sig
->return_type
, "_ret_val");
5986 body
.emit(call(f
, ret_val
, sig
->parameters
));
5987 body
.emit(ret(ret_val
));
5990 sig
->is_defined
= true;
5993 sig
->intrinsic_id
= id
;
5999 ir_function_signature
*
6000 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
,
6001 enum ir_intrinsic_id id
)
6003 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6007 ir_function_signature
*
6008 builtin_builder::_memory_barrier(const char *intrinsic_name
,
6009 builtin_available_predicate avail
)
6011 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6012 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6013 NULL
, sig
->parameters
));
6017 ir_function_signature
*
6018 builtin_builder::_ballot()
6020 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6022 MAKE_SIG(glsl_type::uint64_t_type
, shader_ballot
, 1, value
);
6023 body
.emit(ret(expr(ir_unop_ballot
, value
)));
6027 ir_function_signature
*
6028 builtin_builder::_read_first_invocation(const glsl_type
*type
)
6030 ir_variable
*value
= in_var(type
, "value");
6032 MAKE_SIG(type
, shader_ballot
, 1, value
);
6033 body
.emit(ret(expr(ir_unop_read_first_invocation
, value
)));
6037 ir_function_signature
*
6038 builtin_builder::_read_invocation(const glsl_type
*type
)
6040 ir_variable
*value
= in_var(type
, "value");
6041 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6043 MAKE_SIG(type
, shader_ballot
, 2, value
, invocation
);
6044 body
.emit(ret(expr(ir_binop_read_invocation
, value
, invocation
)));
6048 ir_function_signature
*
6049 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
6050 const glsl_type
*type
)
6052 MAKE_INTRINSIC(type
, ir_intrinsic_shader_clock
, avail
, 0);
6056 ir_function_signature
*
6057 builtin_builder::_shader_clock(builtin_available_predicate avail
,
6058 const glsl_type
*type
)
6060 MAKE_SIG(type
, avail
, 0);
6062 ir_variable
*retval
= body
.make_temp(glsl_type::uvec2_type
, "clock_retval");
6064 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
6065 retval
, sig
->parameters
));
6067 if (type
== glsl_type::uint64_t_type
) {
6068 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, retval
)));
6070 body
.emit(ret(retval
));
6076 ir_function_signature
*
6077 builtin_builder::_vote_intrinsic(builtin_available_predicate avail
,
6078 enum ir_intrinsic_id id
)
6080 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6081 MAKE_INTRINSIC(glsl_type::bool_type
, id
, avail
, 1, value
);
6085 ir_function_signature
*
6086 builtin_builder::_vote(const char *intrinsic_name
)
6088 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6090 MAKE_SIG(glsl_type::bool_type
, vote
, 1, value
);
6092 ir_variable
*retval
= body
.make_temp(glsl_type::bool_type
, "retval");
6094 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6095 retval
, sig
->parameters
));
6096 body
.emit(ret(retval
));
6102 /******************************************************************************/
6104 /* The singleton instance of builtin_builder. */
6105 static builtin_builder builtins
;
6106 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
6109 * External API (exposing the built-in module to the rest of the compiler):
6113 _mesa_glsl_initialize_builtin_functions()
6115 mtx_lock(&builtins_lock
);
6116 builtins
.initialize();
6117 mtx_unlock(&builtins_lock
);
6121 _mesa_glsl_release_builtin_functions()
6123 mtx_lock(&builtins_lock
);
6125 mtx_unlock(&builtins_lock
);
6128 ir_function_signature
*
6129 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
6130 const char *name
, exec_list
*actual_parameters
)
6132 ir_function_signature
*s
;
6133 mtx_lock(&builtins_lock
);
6134 s
= builtins
.find(state
, name
, actual_parameters
);
6135 mtx_unlock(&builtins_lock
);
6140 struct hash_table
*ht
=
6141 _mesa_hash_table_create(NULL
, _mesa_hash_pointer
, _mesa_key_pointer_equal
);
6142 void *mem_ctx
= state
;
6143 ir_function
*f
= s
->function()->clone(mem_ctx
, ht
);
6144 _mesa_hash_table_destroy(ht
, NULL
);
6146 return f
->matching_signature(state
, actual_parameters
, true);
6150 _mesa_glsl_has_builtin_function(const char *name
)
6153 mtx_lock(&builtins_lock
);
6154 f
= builtins
.shader
->symbols
->get_function(name
);
6155 mtx_unlock(&builtins_lock
);
6161 _mesa_glsl_get_builtin_function_shader()
6163 return builtins
.shader
;
6168 * Get the function signature for main from a shader
6170 ir_function_signature
*
6171 _mesa_get_main_function_signature(glsl_symbol_table
*symbols
)
6173 ir_function
*const f
= symbols
->get_function("main");
6175 exec_list void_parameters
;
6177 /* Look for the 'void main()' signature and ensure that it's defined.
6178 * This keeps the linker from accidentally pick a shader that just
6179 * contains a prototype for main.
6181 * We don't have to check for multiple definitions of main (in multiple
6182 * shaders) because that would have already been caught above.
6184 ir_function_signature
*sig
=
6185 f
->matching_signature(NULL
, &void_parameters
, false);
6186 if ((sig
!= NULL
) && sig
->is_defined
) {