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
->compat_shader
|| state
->ARB_compatibility_enable
) &&
112 fs_only(const _mesa_glsl_parse_state
*state
)
114 return state
->stage
== MESA_SHADER_FRAGMENT
;
118 gs_only(const _mesa_glsl_parse_state
*state
)
120 return state
->stage
== MESA_SHADER_GEOMETRY
;
124 v110(const _mesa_glsl_parse_state
*state
)
126 return !state
->es_shader
;
130 v110_fs_only(const _mesa_glsl_parse_state
*state
)
132 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
136 v120(const _mesa_glsl_parse_state
*state
)
138 return state
->is_version(120, 300);
142 v130(const _mesa_glsl_parse_state
*state
)
144 return state
->is_version(130, 300);
148 v130_desktop(const _mesa_glsl_parse_state
*state
)
150 return state
->is_version(130, 0);
154 v460_desktop(const _mesa_glsl_parse_state
*state
)
156 return state
->is_version(460, 0);
160 v130_fs_only(const _mesa_glsl_parse_state
*state
)
162 return state
->is_version(130, 300) &&
163 state
->stage
== MESA_SHADER_FRAGMENT
;
167 v140_or_es3(const _mesa_glsl_parse_state
*state
)
169 return state
->is_version(140, 300);
173 v400_fs_only(const _mesa_glsl_parse_state
*state
)
175 return state
->is_version(400, 0) &&
176 state
->stage
== MESA_SHADER_FRAGMENT
;
180 texture_rectangle(const _mesa_glsl_parse_state
*state
)
182 return state
->ARB_texture_rectangle_enable
;
186 texture_external(const _mesa_glsl_parse_state
*state
)
188 return state
->OES_EGL_image_external_enable
;
192 texture_external_es3(const _mesa_glsl_parse_state
*state
)
194 return state
->OES_EGL_image_external_essl3_enable
&&
196 state
->is_version(0, 300);
199 /** True if texturing functions with explicit LOD are allowed. */
201 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
203 /* Texturing functions with "Lod" in their name exist:
204 * - In the vertex shader stage (for all languages)
205 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
206 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
208 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
209 * don't need to explicitly check state->es_shader.
211 return state
->stage
== MESA_SHADER_VERTEX
||
212 state
->is_version(130, 300) ||
213 state
->ARB_shader_texture_lod_enable
;
217 v110_lod(const _mesa_glsl_parse_state
*state
)
219 return !state
->es_shader
&& lod_exists_in_stage(state
);
223 texture_buffer(const _mesa_glsl_parse_state
*state
)
225 return state
->is_version(140, 320) ||
226 state
->EXT_texture_buffer_enable
||
227 state
->OES_texture_buffer_enable
;
231 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
233 return state
->ARB_shader_texture_lod_enable
;
237 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
239 return state
->ARB_shader_texture_lod_enable
&&
240 state
->ARB_texture_rectangle_enable
;
244 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
246 return state
->is_version(330, 300) ||
247 state
->ARB_shader_bit_encoding_enable
||
248 state
->ARB_gpu_shader5_enable
;
252 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
254 return state
->is_version(450, 310) ||
255 state
->ARB_ES3_1_compatibility_enable
||
256 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
260 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
262 return state
->ARB_shading_language_packing_enable
||
263 state
->is_version(420, 300);
267 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
269 return state
->ARB_shading_language_packing_enable
||
270 state
->ARB_gpu_shader5_enable
||
271 state
->is_version(400, 300);
275 gpu_shader5(const _mesa_glsl_parse_state
*state
)
277 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
281 gpu_shader5_es(const _mesa_glsl_parse_state
*state
)
283 return state
->is_version(400, 320) ||
284 state
->ARB_gpu_shader5_enable
||
285 state
->EXT_gpu_shader5_enable
||
286 state
->OES_gpu_shader5_enable
;
290 gpu_shader5_or_OES_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
292 return state
->is_version(400, 320) ||
293 state
->ARB_gpu_shader5_enable
||
294 state
->EXT_texture_cube_map_array_enable
||
295 state
->OES_texture_cube_map_array_enable
;
299 es31_not_gs5(const _mesa_glsl_parse_state
*state
)
301 return state
->is_version(0, 310) && !gpu_shader5_es(state
);
305 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
307 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
311 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
313 return state
->ARB_shading_language_packing_enable
||
314 state
->ARB_gpu_shader5_enable
||
315 state
->is_version(400, 310);
319 gpu_shader5_or_es31_or_integer_functions(const _mesa_glsl_parse_state
*state
)
321 return gpu_shader5_or_es31(state
) ||
322 state
->MESA_shader_integer_functions_enable
;
326 fs_interpolate_at(const _mesa_glsl_parse_state
*state
)
328 return state
->stage
== MESA_SHADER_FRAGMENT
&&
329 (state
->is_version(400, 320) ||
330 state
->ARB_gpu_shader5_enable
||
331 state
->OES_shader_multisample_interpolation_enable
);
336 texture_array_lod(const _mesa_glsl_parse_state
*state
)
338 return lod_exists_in_stage(state
) &&
339 state
->EXT_texture_array_enable
;
343 fs_texture_array(const _mesa_glsl_parse_state
*state
)
345 return state
->stage
== MESA_SHADER_FRAGMENT
&&
346 state
->EXT_texture_array_enable
;
350 texture_array(const _mesa_glsl_parse_state
*state
)
352 return state
->EXT_texture_array_enable
;
356 texture_multisample(const _mesa_glsl_parse_state
*state
)
358 return state
->is_version(150, 310) ||
359 state
->ARB_texture_multisample_enable
;
363 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
365 return state
->is_version(150, 320) ||
366 state
->ARB_texture_multisample_enable
||
367 state
->OES_texture_storage_multisample_2d_array_enable
;
371 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
373 return texture_multisample(state
) &&
374 state
->EXT_shader_samples_identical_enable
;
378 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
380 return texture_multisample_array(state
) &&
381 state
->EXT_shader_samples_identical_enable
;
385 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
387 return state
->stage
== MESA_SHADER_FRAGMENT
&&
388 state
->has_texture_cube_map_array();
392 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
394 return state
->has_texture_cube_map_array();
398 texture_query_levels(const _mesa_glsl_parse_state
*state
)
400 return state
->is_version(430, 0) ||
401 state
->ARB_texture_query_levels_enable
;
405 texture_query_lod(const _mesa_glsl_parse_state
*state
)
407 return state
->stage
== MESA_SHADER_FRAGMENT
&&
408 state
->ARB_texture_query_lod_enable
;
412 texture_gather_cube_map_array(const _mesa_glsl_parse_state
*state
)
414 return state
->is_version(400, 320) ||
415 state
->ARB_texture_gather_enable
||
416 state
->ARB_gpu_shader5_enable
||
417 state
->EXT_texture_cube_map_array_enable
||
418 state
->OES_texture_cube_map_array_enable
;
422 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
424 return state
->is_version(400, 310) ||
425 state
->ARB_texture_gather_enable
||
426 state
->ARB_gpu_shader5_enable
;
429 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
430 * used for relaxation of const offset requirements.
433 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
435 return !state
->is_version(400, 320) &&
436 !state
->ARB_gpu_shader5_enable
&&
437 !state
->EXT_gpu_shader5_enable
&&
438 !state
->OES_gpu_shader5_enable
&&
439 (state
->ARB_texture_gather_enable
||
440 state
->is_version(0, 310));
443 /* Desktop GL or OES_standard_derivatives + fragment shader only */
445 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
447 return state
->stage
== MESA_SHADER_FRAGMENT
&&
448 (state
->is_version(110, 300) ||
449 state
->OES_standard_derivatives_enable
);
453 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
455 return state
->stage
== MESA_SHADER_FRAGMENT
&&
456 (state
->is_version(450, 0) ||
457 state
->ARB_derivative_control_enable
);
461 tex1d_lod(const _mesa_glsl_parse_state
*state
)
463 return !state
->es_shader
&& lod_exists_in_stage(state
);
466 /** True if sampler3D exists */
468 tex3d(const _mesa_glsl_parse_state
*state
)
470 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
471 * OES_texture_3D extension, and in GLSL ES 3.00.
473 return !state
->es_shader
||
474 state
->OES_texture_3D_enable
||
475 state
->language_version
>= 300;
479 fs_tex3d(const _mesa_glsl_parse_state
*state
)
481 return state
->stage
== MESA_SHADER_FRAGMENT
&&
482 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
486 tex3d_lod(const _mesa_glsl_parse_state
*state
)
488 return tex3d(state
) && lod_exists_in_stage(state
);
492 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
494 return state
->has_atomic_counters();
498 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
500 return state
->ARB_shader_atomic_counter_ops_enable
;
504 shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
506 return state
->ARB_shader_atomic_counter_ops_enable
|| v460_desktop(state
);
510 shader_ballot(const _mesa_glsl_parse_state
*state
)
512 return state
->ARB_shader_ballot_enable
;
516 shader_clock(const _mesa_glsl_parse_state
*state
)
518 return state
->ARB_shader_clock_enable
;
522 shader_clock_int64(const _mesa_glsl_parse_state
*state
)
524 return state
->ARB_shader_clock_enable
&&
525 state
->ARB_gpu_shader_int64_enable
;
529 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
531 return state
->has_shader_storage_buffer_objects();
535 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
537 return state
->AMD_shader_trinary_minmax_enable
;
541 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
543 return (state
->is_version(420, 310) ||
544 state
->ARB_shader_image_load_store_enable
);
548 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
550 return (state
->is_version(420, 320) ||
551 state
->ARB_shader_image_load_store_enable
||
552 state
->OES_shader_image_atomic_enable
);
556 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
558 return (state
->is_version(450, 320) ||
559 state
->ARB_ES3_1_compatibility_enable
||
560 state
->OES_shader_image_atomic_enable
);
564 shader_image_size(const _mesa_glsl_parse_state
*state
)
566 return state
->is_version(430, 310) ||
567 state
->ARB_shader_image_size_enable
;
571 shader_samples(const _mesa_glsl_parse_state
*state
)
573 return state
->is_version(450, 0) ||
574 state
->ARB_shader_texture_image_samples_enable
;
578 gs_streams(const _mesa_glsl_parse_state
*state
)
580 return gpu_shader5(state
) && gs_only(state
);
584 fp64(const _mesa_glsl_parse_state
*state
)
586 return state
->has_double();
590 int64(const _mesa_glsl_parse_state
*state
)
592 return state
->has_int64();
596 int64_fp64(const _mesa_glsl_parse_state
*state
)
598 return state
->has_int64() && state
->has_double();
602 compute_shader(const _mesa_glsl_parse_state
*state
)
604 return state
->stage
== MESA_SHADER_COMPUTE
;
608 compute_shader_supported(const _mesa_glsl_parse_state
*state
)
610 return state
->has_compute_shader();
614 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
616 return compute_shader(state
) || shader_storage_buffer_object(state
);
620 barrier_supported(const _mesa_glsl_parse_state
*state
)
622 return compute_shader(state
) ||
623 state
->stage
== MESA_SHADER_TESS_CTRL
;
627 vote(const _mesa_glsl_parse_state
*state
)
629 return state
->ARB_shader_group_vote_enable
;
633 vote_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
635 return state
->ARB_shader_group_vote_enable
|| v460_desktop(state
);
639 integer_functions_supported(const _mesa_glsl_parse_state
*state
)
641 return state
->extensions
->MESA_shader_integer_functions
;
645 /******************************************************************************/
650 * builtin_builder: A singleton object representing the core of the built-in
653 * It generates IR for every built-in function signature, and organizes them
656 class builtin_builder
{
663 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
664 const char *name
, exec_list
*actual_parameters
);
667 * A shader to hold all the built-in signatures; created by this module.
669 * This includes signatures for every built-in, regardless of version or
670 * enabled extensions. The availability predicate associated with each
671 * signature allows matching_signature() to filter out the irrelevant ones.
678 void create_shader();
679 void create_intrinsics();
680 void create_builtins();
683 * IR builder helpers:
685 * These convenience functions assist in emitting IR, but don't necessarily
686 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
689 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
690 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
691 ir_constant
*imm(float f
, unsigned vector_elements
=1);
692 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
693 ir_constant
*imm(int i
, unsigned vector_elements
=1);
694 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
695 ir_constant
*imm(double d
, unsigned vector_elements
=1);
696 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
697 ir_dereference_variable
*var_ref(ir_variable
*var
);
698 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
699 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
701 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
702 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
705 * Call function \param f with parameters specified as the linked
706 * list \param params of \c ir_variable objects. \param ret should
707 * point to the ir_variable that will hold the function return
708 * value, or be \c NULL if the function has void return type.
710 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
712 /** Create a new function and add the given signatures. */
713 void add_function(const char *name
, ...);
715 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
716 unsigned num_arguments
,
720 * Create a new image built-in function for all known image types.
721 * \p flags is a bitfield of \c image_function_flags flags.
723 void add_image_function(const char *name
,
724 const char *intrinsic_name
,
725 image_prototype_ctr prototype
,
726 unsigned num_arguments
,
728 enum ir_intrinsic_id id
);
731 * Create new functions for all known image built-ins and types.
732 * If \p glsl is \c true, use the GLSL built-in names and emit code
733 * to call into the actual compiler intrinsic. If \p glsl is
734 * false, emit a function prototype with no body for each image
737 void add_image_functions(bool glsl
);
739 ir_function_signature
*new_sig(const glsl_type
*return_type
,
740 builtin_available_predicate avail
,
741 int num_params
, ...);
744 * Function signature generators:
747 ir_function_signature
*unop(builtin_available_predicate avail
,
748 ir_expression_operation opcode
,
749 const glsl_type
*return_type
,
750 const glsl_type
*param_type
);
751 ir_function_signature
*binop(builtin_available_predicate avail
,
752 ir_expression_operation opcode
,
753 const glsl_type
*return_type
,
754 const glsl_type
*param0_type
,
755 const glsl_type
*param1_type
,
756 bool swap_operands
= false);
758 #define B0(X) ir_function_signature *_##X();
759 #define B1(X) ir_function_signature *_##X(const glsl_type *);
760 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
761 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
762 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
763 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
800 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
801 const glsl_type
*val_type
,
802 const glsl_type
*blend_type
);
812 BA1(doubleBitsToInt64
)
813 BA1(doubleBitsToUint64
)
814 BA1(int64BitsToDouble
)
815 BA1(uint64BitsToDouble
)
817 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
818 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
819 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
820 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
821 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
822 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
823 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
824 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
825 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
826 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
827 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
828 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
829 ir_function_signature
*_packInt2x32(builtin_available_predicate avail
);
830 ir_function_signature
*_unpackInt2x32(builtin_available_predicate avail
);
831 ir_function_signature
*_packUint2x32(builtin_available_predicate avail
);
832 ir_function_signature
*_unpackUint2x32(builtin_available_predicate avail
);
845 BA1(determinant_mat2
);
846 BA1(determinant_mat3
);
847 BA1(determinant_mat4
);
855 BA1(greaterThanEqual
);
864 /** Flags to _texture() */
865 #define TEX_PROJECT 1
867 #define TEX_COMPONENT 4
868 #define TEX_OFFSET_NONCONST 8
869 #define TEX_OFFSET_ARRAY 16
871 ir_function_signature
*_texture(ir_texture_opcode opcode
,
872 builtin_available_predicate avail
,
873 const glsl_type
*return_type
,
874 const glsl_type
*sampler_type
,
875 const glsl_type
*coord_type
,
877 BA1(textureCubeArrayShadow
);
878 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
879 const glsl_type
*return_type
,
880 const glsl_type
*sampler_type
,
881 const glsl_type
*coord_type
,
882 const glsl_type
*offset_type
= NULL
);
886 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
887 const glsl_type
*stream_type
);
888 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
889 const glsl_type
*stream_type
);
892 BA2(textureQueryLod
);
893 BA1(textureQueryLevels
);
894 BA2(textureSamplesIdentical
);
922 B1(interpolateAtCentroid
)
923 B1(interpolateAtOffset
)
924 B1(interpolateAtSample
)
926 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
,
927 enum ir_intrinsic_id id
);
928 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
,
929 enum ir_intrinsic_id id
);
930 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
,
931 enum ir_intrinsic_id id
);
932 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
933 builtin_available_predicate avail
);
934 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
935 builtin_available_predicate avail
);
936 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
937 builtin_available_predicate avail
);
939 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
940 const glsl_type
*type
,
941 enum ir_intrinsic_id id
);
942 ir_function_signature
*_atomic_op2(const char *intrinsic
,
943 builtin_available_predicate avail
,
944 const glsl_type
*type
);
945 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
946 const glsl_type
*type
,
947 enum ir_intrinsic_id id
);
948 ir_function_signature
*_atomic_op3(const char *intrinsic
,
949 builtin_available_predicate avail
,
950 const glsl_type
*type
);
956 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
957 unsigned num_arguments
,
959 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
960 unsigned num_arguments
,
962 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
963 unsigned num_arguments
,
965 ir_function_signature
*_image(image_prototype_ctr prototype
,
966 const glsl_type
*image_type
,
967 const char *intrinsic_name
,
968 unsigned num_arguments
,
970 enum ir_intrinsic_id id
);
972 ir_function_signature
*_memory_barrier_intrinsic(
973 builtin_available_predicate avail
,
974 enum ir_intrinsic_id id
);
975 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
976 builtin_available_predicate avail
);
978 ir_function_signature
*_ballot_intrinsic();
979 ir_function_signature
*_ballot();
980 ir_function_signature
*_read_first_invocation_intrinsic(const glsl_type
*type
);
981 ir_function_signature
*_read_first_invocation(const glsl_type
*type
);
982 ir_function_signature
*_read_invocation_intrinsic(const glsl_type
*type
);
983 ir_function_signature
*_read_invocation(const glsl_type
*type
);
985 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
986 const glsl_type
*type
);
987 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
988 const glsl_type
*type
);
990 ir_function_signature
*_vote_intrinsic(builtin_available_predicate avail
,
991 enum ir_intrinsic_id id
);
992 ir_function_signature
*_vote(const char *intrinsic_name
,
993 builtin_available_predicate avail
);
1004 enum image_function_flags
{
1005 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
1006 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
1007 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
1008 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
1009 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
1010 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
1011 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
1012 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
1013 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8)
1016 } /* anonymous namespace */
1019 * Core builtin_builder functionality:
1022 builtin_builder::builtin_builder()
1028 builtin_builder::~builtin_builder()
1030 ralloc_free(mem_ctx
);
1033 ir_function_signature
*
1034 builtin_builder::find(_mesa_glsl_parse_state
*state
,
1035 const char *name
, exec_list
*actual_parameters
)
1037 /* The shader currently being compiled requested a built-in function;
1038 * it needs to link against builtin_builder::shader in order to get them.
1040 * Even if we don't find a matching signature, we still need to do this so
1041 * that the "no matching signature" error will list potential candidates
1042 * from the available built-ins.
1044 state
->uses_builtin_functions
= true;
1046 ir_function
*f
= shader
->symbols
->get_function(name
);
1050 ir_function_signature
*sig
=
1051 f
->matching_signature(state
, actual_parameters
, true);
1059 builtin_builder::initialize()
1061 /* If already initialized, don't do it again. */
1062 if (mem_ctx
!= NULL
)
1065 mem_ctx
= ralloc_context(NULL
);
1067 create_intrinsics();
1072 builtin_builder::release()
1074 ralloc_free(mem_ctx
);
1077 ralloc_free(shader
);
1082 builtin_builder::create_shader()
1084 /* The target doesn't actually matter. There's no target for generic
1085 * GLSL utility code that could be linked against any stage, so just
1086 * arbitrarily pick GL_VERTEX_SHADER.
1088 shader
= _mesa_new_shader(0, MESA_SHADER_VERTEX
);
1089 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
1095 * Create ir_function and ir_function_signature objects for each
1099 builtin_builder::create_intrinsics()
1101 add_function("__intrinsic_atomic_read",
1102 _atomic_counter_intrinsic(shader_atomic_counters
,
1103 ir_intrinsic_atomic_counter_read
),
1105 add_function("__intrinsic_atomic_increment",
1106 _atomic_counter_intrinsic(shader_atomic_counters
,
1107 ir_intrinsic_atomic_counter_increment
),
1109 add_function("__intrinsic_atomic_predecrement",
1110 _atomic_counter_intrinsic(shader_atomic_counters
,
1111 ir_intrinsic_atomic_counter_predecrement
),
1114 add_function("__intrinsic_atomic_add",
1115 _atomic_intrinsic2(buffer_atomics_supported
,
1116 glsl_type::uint_type
,
1117 ir_intrinsic_generic_atomic_add
),
1118 _atomic_intrinsic2(buffer_atomics_supported
,
1119 glsl_type::int_type
,
1120 ir_intrinsic_generic_atomic_add
),
1121 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1122 ir_intrinsic_atomic_counter_add
),
1124 add_function("__intrinsic_atomic_min",
1125 _atomic_intrinsic2(buffer_atomics_supported
,
1126 glsl_type::uint_type
,
1127 ir_intrinsic_generic_atomic_min
),
1128 _atomic_intrinsic2(buffer_atomics_supported
,
1129 glsl_type::int_type
,
1130 ir_intrinsic_generic_atomic_min
),
1131 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1132 ir_intrinsic_atomic_counter_min
),
1134 add_function("__intrinsic_atomic_max",
1135 _atomic_intrinsic2(buffer_atomics_supported
,
1136 glsl_type::uint_type
,
1137 ir_intrinsic_generic_atomic_max
),
1138 _atomic_intrinsic2(buffer_atomics_supported
,
1139 glsl_type::int_type
,
1140 ir_intrinsic_generic_atomic_max
),
1141 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1142 ir_intrinsic_atomic_counter_max
),
1144 add_function("__intrinsic_atomic_and",
1145 _atomic_intrinsic2(buffer_atomics_supported
,
1146 glsl_type::uint_type
,
1147 ir_intrinsic_generic_atomic_and
),
1148 _atomic_intrinsic2(buffer_atomics_supported
,
1149 glsl_type::int_type
,
1150 ir_intrinsic_generic_atomic_and
),
1151 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1152 ir_intrinsic_atomic_counter_and
),
1154 add_function("__intrinsic_atomic_or",
1155 _atomic_intrinsic2(buffer_atomics_supported
,
1156 glsl_type::uint_type
,
1157 ir_intrinsic_generic_atomic_or
),
1158 _atomic_intrinsic2(buffer_atomics_supported
,
1159 glsl_type::int_type
,
1160 ir_intrinsic_generic_atomic_or
),
1161 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1162 ir_intrinsic_atomic_counter_or
),
1164 add_function("__intrinsic_atomic_xor",
1165 _atomic_intrinsic2(buffer_atomics_supported
,
1166 glsl_type::uint_type
,
1167 ir_intrinsic_generic_atomic_xor
),
1168 _atomic_intrinsic2(buffer_atomics_supported
,
1169 glsl_type::int_type
,
1170 ir_intrinsic_generic_atomic_xor
),
1171 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1172 ir_intrinsic_atomic_counter_xor
),
1174 add_function("__intrinsic_atomic_exchange",
1175 _atomic_intrinsic2(buffer_atomics_supported
,
1176 glsl_type::uint_type
,
1177 ir_intrinsic_generic_atomic_exchange
),
1178 _atomic_intrinsic2(buffer_atomics_supported
,
1179 glsl_type::int_type
,
1180 ir_intrinsic_generic_atomic_exchange
),
1181 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1182 ir_intrinsic_atomic_counter_exchange
),
1184 add_function("__intrinsic_atomic_comp_swap",
1185 _atomic_intrinsic3(buffer_atomics_supported
,
1186 glsl_type::uint_type
,
1187 ir_intrinsic_generic_atomic_comp_swap
),
1188 _atomic_intrinsic3(buffer_atomics_supported
,
1189 glsl_type::int_type
,
1190 ir_intrinsic_generic_atomic_comp_swap
),
1191 _atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop
,
1192 ir_intrinsic_atomic_counter_comp_swap
),
1195 add_image_functions(false);
1197 add_function("__intrinsic_memory_barrier",
1198 _memory_barrier_intrinsic(shader_image_load_store
,
1199 ir_intrinsic_memory_barrier
),
1201 add_function("__intrinsic_group_memory_barrier",
1202 _memory_barrier_intrinsic(compute_shader
,
1203 ir_intrinsic_group_memory_barrier
),
1205 add_function("__intrinsic_memory_barrier_atomic_counter",
1206 _memory_barrier_intrinsic(compute_shader_supported
,
1207 ir_intrinsic_memory_barrier_atomic_counter
),
1209 add_function("__intrinsic_memory_barrier_buffer",
1210 _memory_barrier_intrinsic(compute_shader_supported
,
1211 ir_intrinsic_memory_barrier_buffer
),
1213 add_function("__intrinsic_memory_barrier_image",
1214 _memory_barrier_intrinsic(compute_shader_supported
,
1215 ir_intrinsic_memory_barrier_image
),
1217 add_function("__intrinsic_memory_barrier_shared",
1218 _memory_barrier_intrinsic(compute_shader
,
1219 ir_intrinsic_memory_barrier_shared
),
1222 add_function("__intrinsic_shader_clock",
1223 _shader_clock_intrinsic(shader_clock
,
1224 glsl_type::uvec2_type
),
1227 add_function("__intrinsic_vote_all",
1228 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_all
),
1230 add_function("__intrinsic_vote_any",
1231 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_any
),
1233 add_function("__intrinsic_vote_eq",
1234 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_eq
),
1237 add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL
);
1239 add_function("__intrinsic_read_invocation",
1240 _read_invocation_intrinsic(glsl_type::float_type
),
1241 _read_invocation_intrinsic(glsl_type::vec2_type
),
1242 _read_invocation_intrinsic(glsl_type::vec3_type
),
1243 _read_invocation_intrinsic(glsl_type::vec4_type
),
1245 _read_invocation_intrinsic(glsl_type::int_type
),
1246 _read_invocation_intrinsic(glsl_type::ivec2_type
),
1247 _read_invocation_intrinsic(glsl_type::ivec3_type
),
1248 _read_invocation_intrinsic(glsl_type::ivec4_type
),
1250 _read_invocation_intrinsic(glsl_type::uint_type
),
1251 _read_invocation_intrinsic(glsl_type::uvec2_type
),
1252 _read_invocation_intrinsic(glsl_type::uvec3_type
),
1253 _read_invocation_intrinsic(glsl_type::uvec4_type
),
1256 add_function("__intrinsic_read_first_invocation",
1257 _read_first_invocation_intrinsic(glsl_type::float_type
),
1258 _read_first_invocation_intrinsic(glsl_type::vec2_type
),
1259 _read_first_invocation_intrinsic(glsl_type::vec3_type
),
1260 _read_first_invocation_intrinsic(glsl_type::vec4_type
),
1262 _read_first_invocation_intrinsic(glsl_type::int_type
),
1263 _read_first_invocation_intrinsic(glsl_type::ivec2_type
),
1264 _read_first_invocation_intrinsic(glsl_type::ivec3_type
),
1265 _read_first_invocation_intrinsic(glsl_type::ivec4_type
),
1267 _read_first_invocation_intrinsic(glsl_type::uint_type
),
1268 _read_first_invocation_intrinsic(glsl_type::uvec2_type
),
1269 _read_first_invocation_intrinsic(glsl_type::uvec3_type
),
1270 _read_first_invocation_intrinsic(glsl_type::uvec4_type
),
1276 * Create ir_function and ir_function_signature objects for each built-in.
1278 * Contains a list of every available built-in.
1281 builtin_builder::create_builtins()
1284 add_function(#NAME, \
1285 _##NAME(glsl_type::float_type), \
1286 _##NAME(glsl_type::vec2_type), \
1287 _##NAME(glsl_type::vec3_type), \
1288 _##NAME(glsl_type::vec4_type), \
1292 add_function(#NAME, \
1293 _##NAME(always_available, glsl_type::float_type), \
1294 _##NAME(always_available, glsl_type::vec2_type), \
1295 _##NAME(always_available, glsl_type::vec3_type), \
1296 _##NAME(always_available, glsl_type::vec4_type), \
1297 _##NAME(fp64, glsl_type::double_type), \
1298 _##NAME(fp64, glsl_type::dvec2_type), \
1299 _##NAME(fp64, glsl_type::dvec3_type), \
1300 _##NAME(fp64, glsl_type::dvec4_type), \
1303 #define FD130(NAME) \
1304 add_function(#NAME, \
1305 _##NAME(v130, glsl_type::float_type), \
1306 _##NAME(v130, glsl_type::vec2_type), \
1307 _##NAME(v130, glsl_type::vec3_type), \
1308 _##NAME(v130, glsl_type::vec4_type), \
1309 _##NAME(fp64, glsl_type::double_type), \
1310 _##NAME(fp64, glsl_type::dvec2_type), \
1311 _##NAME(fp64, glsl_type::dvec3_type), \
1312 _##NAME(fp64, glsl_type::dvec4_type), \
1315 #define FDGS5(NAME) \
1316 add_function(#NAME, \
1317 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1318 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1319 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1320 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1321 _##NAME(fp64, glsl_type::double_type), \
1322 _##NAME(fp64, glsl_type::dvec2_type), \
1323 _##NAME(fp64, glsl_type::dvec3_type), \
1324 _##NAME(fp64, glsl_type::dvec4_type), \
1328 add_function(#NAME, \
1329 _##NAME(glsl_type::float_type), \
1330 _##NAME(glsl_type::vec2_type), \
1331 _##NAME(glsl_type::vec3_type), \
1332 _##NAME(glsl_type::vec4_type), \
1333 _##NAME(glsl_type::int_type), \
1334 _##NAME(glsl_type::ivec2_type), \
1335 _##NAME(glsl_type::ivec3_type), \
1336 _##NAME(glsl_type::ivec4_type), \
1339 #define FI64(NAME) \
1340 add_function(#NAME, \
1341 _##NAME(always_available, glsl_type::float_type), \
1342 _##NAME(always_available, glsl_type::vec2_type), \
1343 _##NAME(always_available, glsl_type::vec3_type), \
1344 _##NAME(always_available, glsl_type::vec4_type), \
1345 _##NAME(always_available, glsl_type::int_type), \
1346 _##NAME(always_available, glsl_type::ivec2_type), \
1347 _##NAME(always_available, glsl_type::ivec3_type), \
1348 _##NAME(always_available, glsl_type::ivec4_type), \
1349 _##NAME(fp64, glsl_type::double_type), \
1350 _##NAME(fp64, glsl_type::dvec2_type), \
1351 _##NAME(fp64, glsl_type::dvec3_type), \
1352 _##NAME(fp64, glsl_type::dvec4_type), \
1353 _##NAME(int64, glsl_type::int64_t_type), \
1354 _##NAME(int64, glsl_type::i64vec2_type), \
1355 _##NAME(int64, glsl_type::i64vec3_type), \
1356 _##NAME(int64, glsl_type::i64vec4_type), \
1359 #define FIUD_VEC(NAME) \
1360 add_function(#NAME, \
1361 _##NAME(always_available, glsl_type::vec2_type), \
1362 _##NAME(always_available, glsl_type::vec3_type), \
1363 _##NAME(always_available, glsl_type::vec4_type), \
1365 _##NAME(always_available, glsl_type::ivec2_type), \
1366 _##NAME(always_available, glsl_type::ivec3_type), \
1367 _##NAME(always_available, glsl_type::ivec4_type), \
1369 _##NAME(v130, glsl_type::uvec2_type), \
1370 _##NAME(v130, glsl_type::uvec3_type), \
1371 _##NAME(v130, glsl_type::uvec4_type), \
1372 _##NAME(fp64, glsl_type::dvec2_type), \
1373 _##NAME(fp64, glsl_type::dvec3_type), \
1374 _##NAME(fp64, glsl_type::dvec4_type), \
1375 _##NAME(int64, glsl_type::int64_t_type), \
1376 _##NAME(int64, glsl_type::i64vec2_type), \
1377 _##NAME(int64, glsl_type::i64vec3_type), \
1378 _##NAME(int64, glsl_type::i64vec4_type), \
1379 _##NAME(int64, glsl_type::uint64_t_type), \
1380 _##NAME(int64, glsl_type::u64vec2_type), \
1381 _##NAME(int64, glsl_type::u64vec3_type), \
1382 _##NAME(int64, glsl_type::u64vec4_type), \
1386 add_function(#NAME, \
1387 _##NAME(glsl_type::int_type), \
1388 _##NAME(glsl_type::ivec2_type), \
1389 _##NAME(glsl_type::ivec3_type), \
1390 _##NAME(glsl_type::ivec4_type), \
1392 _##NAME(glsl_type::uint_type), \
1393 _##NAME(glsl_type::uvec2_type), \
1394 _##NAME(glsl_type::uvec3_type), \
1395 _##NAME(glsl_type::uvec4_type), \
1398 #define FIUBD_VEC(NAME) \
1399 add_function(#NAME, \
1400 _##NAME(always_available, glsl_type::vec2_type), \
1401 _##NAME(always_available, glsl_type::vec3_type), \
1402 _##NAME(always_available, glsl_type::vec4_type), \
1404 _##NAME(always_available, glsl_type::ivec2_type), \
1405 _##NAME(always_available, glsl_type::ivec3_type), \
1406 _##NAME(always_available, glsl_type::ivec4_type), \
1408 _##NAME(v130, glsl_type::uvec2_type), \
1409 _##NAME(v130, glsl_type::uvec3_type), \
1410 _##NAME(v130, glsl_type::uvec4_type), \
1412 _##NAME(always_available, glsl_type::bvec2_type), \
1413 _##NAME(always_available, glsl_type::bvec3_type), \
1414 _##NAME(always_available, glsl_type::bvec4_type), \
1416 _##NAME(fp64, glsl_type::dvec2_type), \
1417 _##NAME(fp64, glsl_type::dvec3_type), \
1418 _##NAME(fp64, glsl_type::dvec4_type), \
1419 _##NAME(int64, glsl_type::int64_t_type), \
1420 _##NAME(int64, glsl_type::i64vec2_type), \
1421 _##NAME(int64, glsl_type::i64vec3_type), \
1422 _##NAME(int64, glsl_type::i64vec4_type), \
1423 _##NAME(int64, glsl_type::uint64_t_type), \
1424 _##NAME(int64, glsl_type::u64vec2_type), \
1425 _##NAME(int64, glsl_type::u64vec3_type), \
1426 _##NAME(int64, glsl_type::u64vec4_type), \
1429 #define FIUD2_MIXED(NAME) \
1430 add_function(#NAME, \
1431 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1432 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1433 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1434 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1436 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1437 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1438 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1440 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1441 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1442 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1443 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1445 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1446 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1447 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1449 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1450 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1451 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1452 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1454 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1455 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1456 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1458 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1459 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1460 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1461 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1462 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1463 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1464 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1466 _##NAME(int64, glsl_type::int64_t_type, glsl_type::int64_t_type), \
1467 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::int64_t_type), \
1468 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::int64_t_type), \
1469 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::int64_t_type), \
1470 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::i64vec2_type), \
1471 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::i64vec3_type), \
1472 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::i64vec4_type), \
1473 _##NAME(int64, glsl_type::uint64_t_type, glsl_type::uint64_t_type), \
1474 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::uint64_t_type), \
1475 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::uint64_t_type), \
1476 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::uint64_t_type), \
1477 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::u64vec2_type), \
1478 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::u64vec3_type), \
1479 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::u64vec4_type), \
1490 add_function("atan",
1491 _atan(glsl_type::float_type
),
1492 _atan(glsl_type::vec2_type
),
1493 _atan(glsl_type::vec3_type
),
1494 _atan(glsl_type::vec4_type
),
1495 _atan2(glsl_type::float_type
),
1496 _atan2(glsl_type::vec2_type
),
1497 _atan2(glsl_type::vec3_type
),
1498 _atan2(glsl_type::vec4_type
),
1524 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1525 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1526 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1527 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1529 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1530 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1531 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1533 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1534 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1535 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1536 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1538 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1539 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1540 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1550 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1551 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1552 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1553 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1555 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1556 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1557 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1559 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1560 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1561 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1562 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1564 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1565 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1566 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1568 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1569 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1570 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1571 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1573 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1574 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1575 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1576 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1578 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1579 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1580 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1581 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1583 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1584 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1585 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1586 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1588 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1589 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1590 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1591 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1593 _mix_sel(int64
, glsl_type::int64_t_type
, glsl_type::bool_type
),
1594 _mix_sel(int64
, glsl_type::i64vec2_type
, glsl_type::bvec2_type
),
1595 _mix_sel(int64
, glsl_type::i64vec3_type
, glsl_type::bvec3_type
),
1596 _mix_sel(int64
, glsl_type::i64vec4_type
, glsl_type::bvec4_type
),
1598 _mix_sel(int64
, glsl_type::uint64_t_type
, glsl_type::bool_type
),
1599 _mix_sel(int64
, glsl_type::u64vec2_type
, glsl_type::bvec2_type
),
1600 _mix_sel(int64
, glsl_type::u64vec3_type
, glsl_type::bvec3_type
),
1601 _mix_sel(int64
, glsl_type::u64vec4_type
, glsl_type::bvec4_type
),
1604 add_function("step",
1605 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1606 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1607 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1608 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1610 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1611 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1612 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1613 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1614 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1615 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1616 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1618 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1619 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1620 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1623 add_function("smoothstep",
1624 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1625 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1626 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1627 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1629 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1630 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1631 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1632 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1633 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1634 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1635 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1637 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1638 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1639 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1647 add_function("intBitsToFloat",
1648 _intBitsToFloat(glsl_type::int_type
),
1649 _intBitsToFloat(glsl_type::ivec2_type
),
1650 _intBitsToFloat(glsl_type::ivec3_type
),
1651 _intBitsToFloat(glsl_type::ivec4_type
),
1653 add_function("uintBitsToFloat",
1654 _uintBitsToFloat(glsl_type::uint_type
),
1655 _uintBitsToFloat(glsl_type::uvec2_type
),
1656 _uintBitsToFloat(glsl_type::uvec3_type
),
1657 _uintBitsToFloat(glsl_type::uvec4_type
),
1660 add_function("doubleBitsToInt64",
1661 _doubleBitsToInt64(int64_fp64
, glsl_type::double_type
),
1662 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec2_type
),
1663 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec3_type
),
1664 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec4_type
),
1667 add_function("doubleBitsToUint64",
1668 _doubleBitsToUint64(int64_fp64
, glsl_type::double_type
),
1669 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec2_type
),
1670 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec3_type
),
1671 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec4_type
),
1674 add_function("int64BitsToDouble",
1675 _int64BitsToDouble(int64_fp64
, glsl_type::int64_t_type
),
1676 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec2_type
),
1677 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec3_type
),
1678 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec4_type
),
1681 add_function("uint64BitsToDouble",
1682 _uint64BitsToDouble(int64_fp64
, glsl_type::uint64_t_type
),
1683 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec2_type
),
1684 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec3_type
),
1685 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec4_type
),
1688 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1689 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1690 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1691 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1692 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1693 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1694 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1695 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1696 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1697 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1698 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1699 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1701 add_function("packInt2x32", _packInt2x32(int64
), NULL
);
1702 add_function("unpackInt2x32", _unpackInt2x32(int64
), NULL
);
1703 add_function("packUint2x32", _packUint2x32(int64
), NULL
);
1704 add_function("unpackUint2x32", _unpackUint2x32(int64
), NULL
);
1710 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1711 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1714 add_function("ftransform", _ftransform(), NULL
);
1719 add_function("matrixCompMult",
1720 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1721 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1722 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1723 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1724 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1725 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1726 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1727 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1728 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1729 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1730 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1731 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1732 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1733 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1734 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1735 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1736 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1737 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1739 add_function("outerProduct",
1740 _outerProduct(v120
, glsl_type::mat2_type
),
1741 _outerProduct(v120
, glsl_type::mat3_type
),
1742 _outerProduct(v120
, glsl_type::mat4_type
),
1743 _outerProduct(v120
, glsl_type::mat2x3_type
),
1744 _outerProduct(v120
, glsl_type::mat2x4_type
),
1745 _outerProduct(v120
, glsl_type::mat3x2_type
),
1746 _outerProduct(v120
, glsl_type::mat3x4_type
),
1747 _outerProduct(v120
, glsl_type::mat4x2_type
),
1748 _outerProduct(v120
, glsl_type::mat4x3_type
),
1749 _outerProduct(fp64
, glsl_type::dmat2_type
),
1750 _outerProduct(fp64
, glsl_type::dmat3_type
),
1751 _outerProduct(fp64
, glsl_type::dmat4_type
),
1752 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1753 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1754 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1755 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1756 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1757 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1759 add_function("determinant",
1760 _determinant_mat2(v120
, glsl_type::mat2_type
),
1761 _determinant_mat3(v120
, glsl_type::mat3_type
),
1762 _determinant_mat4(v120
, glsl_type::mat4_type
),
1763 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1764 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1765 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1768 add_function("inverse",
1769 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1770 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1771 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1772 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1773 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1774 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1776 add_function("transpose",
1777 _transpose(v120
, glsl_type::mat2_type
),
1778 _transpose(v120
, glsl_type::mat3_type
),
1779 _transpose(v120
, glsl_type::mat4_type
),
1780 _transpose(v120
, glsl_type::mat2x3_type
),
1781 _transpose(v120
, glsl_type::mat2x4_type
),
1782 _transpose(v120
, glsl_type::mat3x2_type
),
1783 _transpose(v120
, glsl_type::mat3x4_type
),
1784 _transpose(v120
, glsl_type::mat4x2_type
),
1785 _transpose(v120
, glsl_type::mat4x3_type
),
1786 _transpose(fp64
, glsl_type::dmat2_type
),
1787 _transpose(fp64
, glsl_type::dmat3_type
),
1788 _transpose(fp64
, glsl_type::dmat4_type
),
1789 _transpose(fp64
, glsl_type::dmat2x3_type
),
1790 _transpose(fp64
, glsl_type::dmat2x4_type
),
1791 _transpose(fp64
, glsl_type::dmat3x2_type
),
1792 _transpose(fp64
, glsl_type::dmat3x4_type
),
1793 _transpose(fp64
, glsl_type::dmat4x2_type
),
1794 _transpose(fp64
, glsl_type::dmat4x3_type
),
1797 FIUD_VEC(lessThanEqual
)
1798 FIUD_VEC(greaterThan
)
1799 FIUD_VEC(greaterThanEqual
)
1804 _any(glsl_type::bvec2_type
),
1805 _any(glsl_type::bvec3_type
),
1806 _any(glsl_type::bvec4_type
),
1810 _all(glsl_type::bvec2_type
),
1811 _all(glsl_type::bvec3_type
),
1812 _all(glsl_type::bvec4_type
),
1816 _not(glsl_type::bvec2_type
),
1817 _not(glsl_type::bvec3_type
),
1818 _not(glsl_type::bvec4_type
),
1821 add_function("textureSize",
1822 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1823 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1824 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1826 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1827 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1828 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1830 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1831 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1832 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1834 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1835 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1836 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1838 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1839 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1840 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1842 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1843 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1844 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1845 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1846 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1847 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1849 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1850 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1852 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1853 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1854 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1855 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1857 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1858 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1859 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1860 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1862 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1863 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1864 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1865 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1866 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1867 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1869 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1870 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1871 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1874 add_function("textureSamples",
1875 _textureSamples(shader_samples
, glsl_type::sampler2DMS_type
),
1876 _textureSamples(shader_samples
, glsl_type::isampler2DMS_type
),
1877 _textureSamples(shader_samples
, glsl_type::usampler2DMS_type
),
1879 _textureSamples(shader_samples
, glsl_type::sampler2DMSArray_type
),
1880 _textureSamples(shader_samples
, glsl_type::isampler2DMSArray_type
),
1881 _textureSamples(shader_samples
, glsl_type::usampler2DMSArray_type
),
1884 add_function("texture",
1885 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1886 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1887 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1889 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1890 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1891 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1893 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1894 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1895 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1897 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1898 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1899 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1901 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1902 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1903 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1905 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1906 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1907 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1909 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1910 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1911 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1913 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1914 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1915 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1917 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1918 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1919 /* samplerCubeArrayShadow is special; it has an extra parameter
1920 * for the shadow comparator since there is no vec5 type.
1922 _textureCubeArrayShadow(texture_cube_map_array
, glsl_type::samplerCubeArrayShadow_type
),
1924 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1925 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1926 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1928 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1930 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
1932 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1933 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1934 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1936 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1937 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1938 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1940 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1941 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1942 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1944 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1945 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1946 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1948 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1949 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1950 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1952 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1953 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1954 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1956 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1957 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1958 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1960 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1961 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1962 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1964 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1967 add_function("textureLod",
1968 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1969 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1970 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1972 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1973 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1974 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1976 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1977 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1978 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1980 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1981 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1982 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1984 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1985 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1987 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1988 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1989 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1991 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1992 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1993 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1995 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1996 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1997 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1999 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2002 add_function("textureOffset",
2003 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2004 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2005 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2007 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2008 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2009 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2011 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2012 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2013 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2015 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2016 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2017 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2019 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2021 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2022 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2024 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2025 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2026 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2028 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2029 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2030 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2032 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2033 /* The next one was forgotten in GLSL 1.30 spec. It's from
2034 * EXT_gpu_shader4 originally. It was added in 4.30 with the
2035 * wrong syntax. This was corrected in 4.40. 4.30 indicates
2036 * that it was intended to be included previously, so allow it
2039 _texture(ir_tex
, v130_desktop
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2041 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2042 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2043 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2045 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2046 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2047 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2049 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2050 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2051 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2053 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2054 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2056 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2057 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2058 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2060 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2061 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2062 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2064 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2067 add_function("textureProj",
2068 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2069 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2070 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2071 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2072 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2073 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2075 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2076 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2077 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2078 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2079 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2080 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2082 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2083 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2084 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2086 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2087 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2089 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2090 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2091 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2092 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2094 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2095 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2096 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2097 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2099 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2101 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2102 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2103 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2104 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2105 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2106 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2108 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2109 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2110 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2111 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2112 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2113 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2115 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2116 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2117 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2119 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2120 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2123 add_function("texelFetch",
2124 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
2125 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
2126 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
2128 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
2129 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
2130 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
2132 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
2133 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
2134 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
2136 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
2137 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
2138 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
2140 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
2141 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
2142 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
2144 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
2145 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
2146 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
2148 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
2149 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
2150 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
2152 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2153 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2154 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2156 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2157 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2158 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2160 _texelFetch(texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::ivec2_type
),
2165 add_function("texelFetchOffset",
2166 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2167 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2168 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2170 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2171 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2172 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2174 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2175 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2176 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2178 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2179 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2180 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2182 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2183 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2184 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2186 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2187 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2188 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2192 add_function("textureProjOffset",
2193 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2194 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2195 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2196 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2197 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2198 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2200 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2201 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2202 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2203 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2204 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2205 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2207 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2208 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2209 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2211 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2212 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2214 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2215 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2216 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2217 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2218 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2219 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2221 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2223 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2224 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2225 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2226 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2227 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2228 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2230 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2231 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2232 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2233 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2234 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2235 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2237 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2238 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2239 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2241 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2242 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2245 add_function("textureLodOffset",
2246 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2247 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2248 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2250 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2251 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2252 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2254 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2255 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2256 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2258 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2259 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2261 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2262 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2263 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2265 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2266 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2267 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2269 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2272 add_function("textureProjLod",
2273 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2274 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2275 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2276 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2277 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2278 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2280 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2281 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2282 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2283 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2284 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2285 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2287 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2288 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2289 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2291 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2292 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2295 add_function("textureProjLodOffset",
2296 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2297 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2298 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2299 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2300 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2301 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2303 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2304 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2305 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2306 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2307 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2308 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2310 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2311 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2312 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2314 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2315 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2318 add_function("textureGrad",
2319 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2320 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2321 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2323 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2324 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2325 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2327 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2328 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2329 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2331 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2332 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2333 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2335 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2336 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2337 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2339 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2341 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2342 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2343 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2345 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2346 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2347 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2349 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2350 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2351 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2353 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2354 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2355 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2357 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2358 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2361 add_function("textureGradOffset",
2362 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2363 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2364 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2366 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2367 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2368 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2370 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2371 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2372 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2374 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2375 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2376 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2378 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2380 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2381 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2383 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2384 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2385 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2387 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2388 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2389 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2391 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2392 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2395 add_function("textureProjGrad",
2396 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2397 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2398 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2399 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2400 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2401 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2403 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2404 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2405 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2406 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2407 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2408 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2410 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2411 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2412 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2414 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2415 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2416 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2417 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2418 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2419 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2421 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2423 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2424 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2427 add_function("textureProjGradOffset",
2428 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2429 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2430 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2431 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2432 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2433 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2435 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2436 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2437 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2438 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2439 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2440 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2442 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2443 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2444 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2446 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2447 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2448 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2449 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2450 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2451 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2453 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2455 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2456 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2459 add_function("EmitVertex", _EmitVertex(), NULL
);
2460 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2461 add_function("EmitStreamVertex",
2462 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2463 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2465 add_function("EndStreamPrimitive",
2466 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2467 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2469 add_function("barrier", _barrier(), NULL
);
2471 add_function("textureQueryLOD",
2472 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2473 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2474 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2476 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2477 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2478 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2480 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2481 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2482 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2484 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2485 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2486 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2488 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2489 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2490 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2492 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2493 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2494 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2496 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2497 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2498 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2500 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2501 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2502 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2503 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2504 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2505 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2508 add_function("textureQueryLod",
2509 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2510 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2511 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2513 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2514 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2515 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2517 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2518 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2519 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2521 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2522 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2523 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2525 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2526 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2527 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2529 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2530 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2531 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2533 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2534 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2535 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2537 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2538 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2539 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2540 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2541 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2542 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2545 add_function("textureQueryLevels",
2546 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1D_type
),
2547 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2D_type
),
2548 _textureQueryLevels(texture_query_levels
, glsl_type::sampler3D_type
),
2549 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCube_type
),
2550 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArray_type
),
2551 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArray_type
),
2552 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArray_type
),
2553 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DShadow_type
),
2554 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DShadow_type
),
2555 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeShadow_type
),
2556 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArrayShadow_type
),
2557 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArrayShadow_type
),
2558 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArrayShadow_type
),
2560 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1D_type
),
2561 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2D_type
),
2562 _textureQueryLevels(texture_query_levels
, glsl_type::isampler3D_type
),
2563 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCube_type
),
2564 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1DArray_type
),
2565 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2DArray_type
),
2566 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCubeArray_type
),
2568 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1D_type
),
2569 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2D_type
),
2570 _textureQueryLevels(texture_query_levels
, glsl_type::usampler3D_type
),
2571 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCube_type
),
2572 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1DArray_type
),
2573 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2DArray_type
),
2574 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCubeArray_type
),
2578 add_function("textureSamplesIdenticalEXT",
2579 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2580 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2581 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2583 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2584 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2585 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2588 add_function("texture1D",
2589 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2590 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2593 add_function("texture1DArray",
2594 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2595 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2598 add_function("texture1DProj",
2599 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2600 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2601 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2602 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2605 add_function("texture1DLod",
2606 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2609 add_function("texture1DArrayLod",
2610 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2613 add_function("texture1DProjLod",
2614 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2615 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2618 add_function("texture2D",
2619 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2620 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2621 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2624 add_function("texture2DArray",
2625 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2626 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2629 add_function("texture2DProj",
2630 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2631 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2632 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2633 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2634 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2635 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2638 add_function("texture2DLod",
2639 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2642 add_function("texture2DArrayLod",
2643 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2646 add_function("texture2DProjLod",
2647 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2648 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2651 add_function("texture3D",
2652 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2653 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2656 add_function("texture3DProj",
2657 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2658 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2661 add_function("texture3DLod",
2662 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2665 add_function("texture3DProjLod",
2666 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2669 add_function("textureCube",
2670 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2671 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2674 add_function("textureCubeLod",
2675 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2678 add_function("texture2DRect",
2679 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2682 add_function("texture2DRectProj",
2683 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2684 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2687 add_function("shadow1D",
2688 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2689 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2692 add_function("shadow1DArray",
2693 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2694 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2697 add_function("shadow2D",
2698 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2699 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2702 add_function("shadow2DArray",
2703 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2704 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2707 add_function("shadow1DProj",
2708 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2709 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2712 add_function("shadow2DProj",
2713 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2714 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2717 add_function("shadow1DLod",
2718 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2721 add_function("shadow2DLod",
2722 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2725 add_function("shadow1DArrayLod",
2726 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2729 add_function("shadow1DProjLod",
2730 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2733 add_function("shadow2DProjLod",
2734 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2737 add_function("shadow2DRect",
2738 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2741 add_function("shadow2DRectProj",
2742 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2745 add_function("texture1DGradARB",
2746 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2749 add_function("texture1DProjGradARB",
2750 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2751 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2754 add_function("texture2DGradARB",
2755 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2758 add_function("texture2DProjGradARB",
2759 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2760 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2763 add_function("texture3DGradARB",
2764 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2767 add_function("texture3DProjGradARB",
2768 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2771 add_function("textureCubeGradARB",
2772 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2775 add_function("shadow1DGradARB",
2776 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2779 add_function("shadow1DProjGradARB",
2780 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2783 add_function("shadow2DGradARB",
2784 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2787 add_function("shadow2DProjGradARB",
2788 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2791 add_function("texture2DRectGradARB",
2792 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2795 add_function("texture2DRectProjGradARB",
2796 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2797 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2800 add_function("shadow2DRectGradARB",
2801 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2804 add_function("shadow2DRectProjGradARB",
2805 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2808 add_function("textureGather",
2809 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2810 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2811 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2813 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2814 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2815 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2817 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2818 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2819 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2821 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2822 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2823 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2825 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2826 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2827 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2829 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2830 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2831 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2833 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2834 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2835 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2837 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2838 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2839 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2841 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2842 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2843 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2845 _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
),
2846 _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
),
2847 _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
),
2849 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2850 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2851 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2852 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2853 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2856 add_function("textureGatherOffset",
2857 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2858 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2859 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2861 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2862 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2863 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2865 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2866 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2867 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2869 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2870 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2871 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2873 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2874 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2875 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2877 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2878 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2879 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2881 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2882 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2883 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2885 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2886 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2887 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2889 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2890 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2891 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2893 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2894 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2895 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2897 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2898 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2899 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2901 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2902 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2905 add_function("textureGatherOffsets",
2906 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2907 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2908 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2910 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2911 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2912 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2914 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2915 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2916 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2918 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2919 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2920 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2922 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2923 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2924 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2926 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2927 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2928 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2930 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2931 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2932 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2957 add_function("ldexp",
2958 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2959 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2960 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2961 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2962 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2963 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2964 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2965 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2968 add_function("frexp",
2969 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2970 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2971 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2972 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2973 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2974 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2975 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2976 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2978 add_function("uaddCarry",
2979 _uaddCarry(glsl_type::uint_type
),
2980 _uaddCarry(glsl_type::uvec2_type
),
2981 _uaddCarry(glsl_type::uvec3_type
),
2982 _uaddCarry(glsl_type::uvec4_type
),
2984 add_function("usubBorrow",
2985 _usubBorrow(glsl_type::uint_type
),
2986 _usubBorrow(glsl_type::uvec2_type
),
2987 _usubBorrow(glsl_type::uvec3_type
),
2988 _usubBorrow(glsl_type::uvec4_type
),
2990 add_function("imulExtended",
2991 _mulExtended(glsl_type::int_type
),
2992 _mulExtended(glsl_type::ivec2_type
),
2993 _mulExtended(glsl_type::ivec3_type
),
2994 _mulExtended(glsl_type::ivec4_type
),
2996 add_function("umulExtended",
2997 _mulExtended(glsl_type::uint_type
),
2998 _mulExtended(glsl_type::uvec2_type
),
2999 _mulExtended(glsl_type::uvec3_type
),
3000 _mulExtended(glsl_type::uvec4_type
),
3002 add_function("interpolateAtCentroid",
3003 _interpolateAtCentroid(glsl_type::float_type
),
3004 _interpolateAtCentroid(glsl_type::vec2_type
),
3005 _interpolateAtCentroid(glsl_type::vec3_type
),
3006 _interpolateAtCentroid(glsl_type::vec4_type
),
3008 add_function("interpolateAtOffset",
3009 _interpolateAtOffset(glsl_type::float_type
),
3010 _interpolateAtOffset(glsl_type::vec2_type
),
3011 _interpolateAtOffset(glsl_type::vec3_type
),
3012 _interpolateAtOffset(glsl_type::vec4_type
),
3014 add_function("interpolateAtSample",
3015 _interpolateAtSample(glsl_type::float_type
),
3016 _interpolateAtSample(glsl_type::vec2_type
),
3017 _interpolateAtSample(glsl_type::vec3_type
),
3018 _interpolateAtSample(glsl_type::vec4_type
),
3021 add_function("atomicCounter",
3022 _atomic_counter_op("__intrinsic_atomic_read",
3023 shader_atomic_counters
),
3025 add_function("atomicCounterIncrement",
3026 _atomic_counter_op("__intrinsic_atomic_increment",
3027 shader_atomic_counters
),
3029 add_function("atomicCounterDecrement",
3030 _atomic_counter_op("__intrinsic_atomic_predecrement",
3031 shader_atomic_counters
),
3034 add_function("atomicCounterAddARB",
3035 _atomic_counter_op1("__intrinsic_atomic_add",
3036 shader_atomic_counter_ops
),
3038 add_function("atomicCounterSubtractARB",
3039 _atomic_counter_op1("__intrinsic_atomic_sub",
3040 shader_atomic_counter_ops
),
3042 add_function("atomicCounterMinARB",
3043 _atomic_counter_op1("__intrinsic_atomic_min",
3044 shader_atomic_counter_ops
),
3046 add_function("atomicCounterMaxARB",
3047 _atomic_counter_op1("__intrinsic_atomic_max",
3048 shader_atomic_counter_ops
),
3050 add_function("atomicCounterAndARB",
3051 _atomic_counter_op1("__intrinsic_atomic_and",
3052 shader_atomic_counter_ops
),
3054 add_function("atomicCounterOrARB",
3055 _atomic_counter_op1("__intrinsic_atomic_or",
3056 shader_atomic_counter_ops
),
3058 add_function("atomicCounterXorARB",
3059 _atomic_counter_op1("__intrinsic_atomic_xor",
3060 shader_atomic_counter_ops
),
3062 add_function("atomicCounterExchangeARB",
3063 _atomic_counter_op1("__intrinsic_atomic_exchange",
3064 shader_atomic_counter_ops
),
3066 add_function("atomicCounterCompSwapARB",
3067 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3068 shader_atomic_counter_ops
),
3071 add_function("atomicCounterAdd",
3072 _atomic_counter_op1("__intrinsic_atomic_add",
3075 add_function("atomicCounterSubtract",
3076 _atomic_counter_op1("__intrinsic_atomic_sub",
3079 add_function("atomicCounterMin",
3080 _atomic_counter_op1("__intrinsic_atomic_min",
3083 add_function("atomicCounterMax",
3084 _atomic_counter_op1("__intrinsic_atomic_max",
3087 add_function("atomicCounterAnd",
3088 _atomic_counter_op1("__intrinsic_atomic_and",
3091 add_function("atomicCounterOr",
3092 _atomic_counter_op1("__intrinsic_atomic_or",
3095 add_function("atomicCounterXor",
3096 _atomic_counter_op1("__intrinsic_atomic_xor",
3099 add_function("atomicCounterExchange",
3100 _atomic_counter_op1("__intrinsic_atomic_exchange",
3103 add_function("atomicCounterCompSwap",
3104 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3108 add_function("atomicAdd",
3109 _atomic_op2("__intrinsic_atomic_add",
3110 buffer_atomics_supported
,
3111 glsl_type::uint_type
),
3112 _atomic_op2("__intrinsic_atomic_add",
3113 buffer_atomics_supported
,
3114 glsl_type::int_type
),
3116 add_function("atomicMin",
3117 _atomic_op2("__intrinsic_atomic_min",
3118 buffer_atomics_supported
,
3119 glsl_type::uint_type
),
3120 _atomic_op2("__intrinsic_atomic_min",
3121 buffer_atomics_supported
,
3122 glsl_type::int_type
),
3124 add_function("atomicMax",
3125 _atomic_op2("__intrinsic_atomic_max",
3126 buffer_atomics_supported
,
3127 glsl_type::uint_type
),
3128 _atomic_op2("__intrinsic_atomic_max",
3129 buffer_atomics_supported
,
3130 glsl_type::int_type
),
3132 add_function("atomicAnd",
3133 _atomic_op2("__intrinsic_atomic_and",
3134 buffer_atomics_supported
,
3135 glsl_type::uint_type
),
3136 _atomic_op2("__intrinsic_atomic_and",
3137 buffer_atomics_supported
,
3138 glsl_type::int_type
),
3140 add_function("atomicOr",
3141 _atomic_op2("__intrinsic_atomic_or",
3142 buffer_atomics_supported
,
3143 glsl_type::uint_type
),
3144 _atomic_op2("__intrinsic_atomic_or",
3145 buffer_atomics_supported
,
3146 glsl_type::int_type
),
3148 add_function("atomicXor",
3149 _atomic_op2("__intrinsic_atomic_xor",
3150 buffer_atomics_supported
,
3151 glsl_type::uint_type
),
3152 _atomic_op2("__intrinsic_atomic_xor",
3153 buffer_atomics_supported
,
3154 glsl_type::int_type
),
3156 add_function("atomicExchange",
3157 _atomic_op2("__intrinsic_atomic_exchange",
3158 buffer_atomics_supported
,
3159 glsl_type::uint_type
),
3160 _atomic_op2("__intrinsic_atomic_exchange",
3161 buffer_atomics_supported
,
3162 glsl_type::int_type
),
3164 add_function("atomicCompSwap",
3165 _atomic_op3("__intrinsic_atomic_comp_swap",
3166 buffer_atomics_supported
,
3167 glsl_type::uint_type
),
3168 _atomic_op3("__intrinsic_atomic_comp_swap",
3169 buffer_atomics_supported
,
3170 glsl_type::int_type
),
3173 add_function("min3",
3174 _min3(glsl_type::float_type
),
3175 _min3(glsl_type::vec2_type
),
3176 _min3(glsl_type::vec3_type
),
3177 _min3(glsl_type::vec4_type
),
3179 _min3(glsl_type::int_type
),
3180 _min3(glsl_type::ivec2_type
),
3181 _min3(glsl_type::ivec3_type
),
3182 _min3(glsl_type::ivec4_type
),
3184 _min3(glsl_type::uint_type
),
3185 _min3(glsl_type::uvec2_type
),
3186 _min3(glsl_type::uvec3_type
),
3187 _min3(glsl_type::uvec4_type
),
3190 add_function("max3",
3191 _max3(glsl_type::float_type
),
3192 _max3(glsl_type::vec2_type
),
3193 _max3(glsl_type::vec3_type
),
3194 _max3(glsl_type::vec4_type
),
3196 _max3(glsl_type::int_type
),
3197 _max3(glsl_type::ivec2_type
),
3198 _max3(glsl_type::ivec3_type
),
3199 _max3(glsl_type::ivec4_type
),
3201 _max3(glsl_type::uint_type
),
3202 _max3(glsl_type::uvec2_type
),
3203 _max3(glsl_type::uvec3_type
),
3204 _max3(glsl_type::uvec4_type
),
3207 add_function("mid3",
3208 _mid3(glsl_type::float_type
),
3209 _mid3(glsl_type::vec2_type
),
3210 _mid3(glsl_type::vec3_type
),
3211 _mid3(glsl_type::vec4_type
),
3213 _mid3(glsl_type::int_type
),
3214 _mid3(glsl_type::ivec2_type
),
3215 _mid3(glsl_type::ivec3_type
),
3216 _mid3(glsl_type::ivec4_type
),
3218 _mid3(glsl_type::uint_type
),
3219 _mid3(glsl_type::uvec2_type
),
3220 _mid3(glsl_type::uvec3_type
),
3221 _mid3(glsl_type::uvec4_type
),
3224 add_image_functions(true);
3226 add_function("memoryBarrier",
3227 _memory_barrier("__intrinsic_memory_barrier",
3228 shader_image_load_store
),
3230 add_function("groupMemoryBarrier",
3231 _memory_barrier("__intrinsic_group_memory_barrier",
3234 add_function("memoryBarrierAtomicCounter",
3235 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
3236 compute_shader_supported
),
3238 add_function("memoryBarrierBuffer",
3239 _memory_barrier("__intrinsic_memory_barrier_buffer",
3240 compute_shader_supported
),
3242 add_function("memoryBarrierImage",
3243 _memory_barrier("__intrinsic_memory_barrier_image",
3244 compute_shader_supported
),
3246 add_function("memoryBarrierShared",
3247 _memory_barrier("__intrinsic_memory_barrier_shared",
3251 add_function("ballotARB", _ballot(), NULL
);
3253 add_function("readInvocationARB",
3254 _read_invocation(glsl_type::float_type
),
3255 _read_invocation(glsl_type::vec2_type
),
3256 _read_invocation(glsl_type::vec3_type
),
3257 _read_invocation(glsl_type::vec4_type
),
3259 _read_invocation(glsl_type::int_type
),
3260 _read_invocation(glsl_type::ivec2_type
),
3261 _read_invocation(glsl_type::ivec3_type
),
3262 _read_invocation(glsl_type::ivec4_type
),
3264 _read_invocation(glsl_type::uint_type
),
3265 _read_invocation(glsl_type::uvec2_type
),
3266 _read_invocation(glsl_type::uvec3_type
),
3267 _read_invocation(glsl_type::uvec4_type
),
3270 add_function("readFirstInvocationARB",
3271 _read_first_invocation(glsl_type::float_type
),
3272 _read_first_invocation(glsl_type::vec2_type
),
3273 _read_first_invocation(glsl_type::vec3_type
),
3274 _read_first_invocation(glsl_type::vec4_type
),
3276 _read_first_invocation(glsl_type::int_type
),
3277 _read_first_invocation(glsl_type::ivec2_type
),
3278 _read_first_invocation(glsl_type::ivec3_type
),
3279 _read_first_invocation(glsl_type::ivec4_type
),
3281 _read_first_invocation(glsl_type::uint_type
),
3282 _read_first_invocation(glsl_type::uvec2_type
),
3283 _read_first_invocation(glsl_type::uvec3_type
),
3284 _read_first_invocation(glsl_type::uvec4_type
),
3287 add_function("clock2x32ARB",
3288 _shader_clock(shader_clock
,
3289 glsl_type::uvec2_type
),
3292 add_function("clockARB",
3293 _shader_clock(shader_clock_int64
,
3294 glsl_type::uint64_t_type
),
3297 add_function("anyInvocationARB",
3298 _vote("__intrinsic_vote_any", vote
),
3301 add_function("allInvocationsARB",
3302 _vote("__intrinsic_vote_all", vote
),
3305 add_function("allInvocationsEqualARB",
3306 _vote("__intrinsic_vote_eq", vote
),
3309 add_function("anyInvocation",
3310 _vote("__intrinsic_vote_any", v460_desktop
),
3313 add_function("allInvocations",
3314 _vote("__intrinsic_vote_all", v460_desktop
),
3317 add_function("allInvocationsEqual",
3318 _vote("__intrinsic_vote_eq", v460_desktop
),
3321 add_function("__builtin_idiv64",
3322 generate_ir::idiv64(mem_ctx
, integer_functions_supported
),
3325 add_function("__builtin_imod64",
3326 generate_ir::imod64(mem_ctx
, integer_functions_supported
),
3329 add_function("__builtin_sign64",
3330 generate_ir::sign64(mem_ctx
, integer_functions_supported
),
3333 add_function("__builtin_udiv64",
3334 generate_ir::udiv64(mem_ctx
, integer_functions_supported
),
3337 add_function("__builtin_umod64",
3338 generate_ir::umod64(mem_ctx
, integer_functions_supported
),
3341 add_function("__builtin_umul64",
3342 generate_ir::umul64(mem_ctx
, integer_functions_supported
),
3353 builtin_builder::add_function(const char *name
, ...)
3357 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3361 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
3367 stuff
.push_tail(sig
);
3368 validate_ir_tree(&stuff
);
3371 f
->add_signature(sig
);
3375 shader
->symbols
->add_function(f
);
3379 builtin_builder::add_image_function(const char *name
,
3380 const char *intrinsic_name
,
3381 image_prototype_ctr prototype
,
3382 unsigned num_arguments
,
3384 enum ir_intrinsic_id intrinsic_id
)
3386 static const glsl_type
*const types
[] = {
3387 glsl_type::image1D_type
,
3388 glsl_type::image2D_type
,
3389 glsl_type::image3D_type
,
3390 glsl_type::image2DRect_type
,
3391 glsl_type::imageCube_type
,
3392 glsl_type::imageBuffer_type
,
3393 glsl_type::image1DArray_type
,
3394 glsl_type::image2DArray_type
,
3395 glsl_type::imageCubeArray_type
,
3396 glsl_type::image2DMS_type
,
3397 glsl_type::image2DMSArray_type
,
3398 glsl_type::iimage1D_type
,
3399 glsl_type::iimage2D_type
,
3400 glsl_type::iimage3D_type
,
3401 glsl_type::iimage2DRect_type
,
3402 glsl_type::iimageCube_type
,
3403 glsl_type::iimageBuffer_type
,
3404 glsl_type::iimage1DArray_type
,
3405 glsl_type::iimage2DArray_type
,
3406 glsl_type::iimageCubeArray_type
,
3407 glsl_type::iimage2DMS_type
,
3408 glsl_type::iimage2DMSArray_type
,
3409 glsl_type::uimage1D_type
,
3410 glsl_type::uimage2D_type
,
3411 glsl_type::uimage3D_type
,
3412 glsl_type::uimage2DRect_type
,
3413 glsl_type::uimageCube_type
,
3414 glsl_type::uimageBuffer_type
,
3415 glsl_type::uimage1DArray_type
,
3416 glsl_type::uimage2DArray_type
,
3417 glsl_type::uimageCubeArray_type
,
3418 glsl_type::uimage2DMS_type
,
3419 glsl_type::uimage2DMSArray_type
3422 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3424 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3425 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3426 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3427 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3428 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3429 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3430 num_arguments
, flags
, intrinsic_id
));
3433 shader
->symbols
->add_function(f
);
3437 builtin_builder::add_image_functions(bool glsl
)
3439 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3441 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3442 "__intrinsic_image_load",
3443 &builtin_builder::_image_prototype
, 0,
3444 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3445 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3446 IMAGE_FUNCTION_READ_ONLY
),
3447 ir_intrinsic_image_load
);
3449 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3450 "__intrinsic_image_store",
3451 &builtin_builder::_image_prototype
, 1,
3452 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3453 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3454 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3455 IMAGE_FUNCTION_WRITE_ONLY
),
3456 ir_intrinsic_image_store
);
3458 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3460 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3461 "__intrinsic_image_atomic_add",
3462 &builtin_builder::_image_prototype
, 1, atom_flags
,
3463 ir_intrinsic_image_atomic_add
);
3465 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3466 "__intrinsic_image_atomic_min",
3467 &builtin_builder::_image_prototype
, 1, atom_flags
,
3468 ir_intrinsic_image_atomic_min
);
3470 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3471 "__intrinsic_image_atomic_max",
3472 &builtin_builder::_image_prototype
, 1, atom_flags
,
3473 ir_intrinsic_image_atomic_max
);
3475 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3476 "__intrinsic_image_atomic_and",
3477 &builtin_builder::_image_prototype
, 1, atom_flags
,
3478 ir_intrinsic_image_atomic_and
);
3480 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3481 "__intrinsic_image_atomic_or",
3482 &builtin_builder::_image_prototype
, 1, atom_flags
,
3483 ir_intrinsic_image_atomic_or
);
3485 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3486 "__intrinsic_image_atomic_xor",
3487 &builtin_builder::_image_prototype
, 1, atom_flags
,
3488 ir_intrinsic_image_atomic_xor
);
3490 add_image_function((glsl
? "imageAtomicExchange" :
3491 "__intrinsic_image_atomic_exchange"),
3492 "__intrinsic_image_atomic_exchange",
3493 &builtin_builder::_image_prototype
, 1,
3494 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3495 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3496 ir_intrinsic_image_atomic_exchange
);
3498 add_image_function((glsl
? "imageAtomicCompSwap" :
3499 "__intrinsic_image_atomic_comp_swap"),
3500 "__intrinsic_image_atomic_comp_swap",
3501 &builtin_builder::_image_prototype
, 2, atom_flags
,
3502 ir_intrinsic_image_atomic_comp_swap
);
3504 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3505 "__intrinsic_image_size",
3506 &builtin_builder::_image_size_prototype
, 1,
3507 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
,
3508 ir_intrinsic_image_size
);
3510 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3511 "__intrinsic_image_samples",
3512 &builtin_builder::_image_samples_prototype
, 1,
3513 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3514 IMAGE_FUNCTION_MS_ONLY
,
3515 ir_intrinsic_image_samples
);
3519 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3521 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3525 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3527 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3531 builtin_builder::imm(bool b
, unsigned vector_elements
)
3533 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3537 builtin_builder::imm(float f
, unsigned vector_elements
)
3539 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3543 builtin_builder::imm(int i
, unsigned vector_elements
)
3545 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3549 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3551 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3555 builtin_builder::imm(double d
, unsigned vector_elements
)
3557 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3561 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3563 return new(mem_ctx
) ir_constant(type
, &data
);
3566 #define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)
3568 ir_dereference_variable
*
3569 builtin_builder::var_ref(ir_variable
*var
)
3571 return new(mem_ctx
) ir_dereference_variable(var
);
3574 ir_dereference_array
*
3575 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3577 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3580 /** Return an element of a matrix */
3582 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3584 return swizzle(array_ref(var
, column
), row
, 1);
3588 * Implementations of built-in functions:
3591 ir_function_signature
*
3592 builtin_builder::new_sig(const glsl_type
*return_type
,
3593 builtin_available_predicate avail
,
3599 ir_function_signature
*sig
=
3600 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3603 va_start(ap
, num_params
);
3604 for (int i
= 0; i
< num_params
; i
++) {
3605 plist
.push_tail(va_arg(ap
, ir_variable
*));
3609 sig
->replace_parameters(&plist
);
3613 #define MAKE_SIG(return_type, avail, ...) \
3614 ir_function_signature *sig = \
3615 new_sig(return_type, avail, __VA_ARGS__); \
3616 ir_factory body(&sig->body, mem_ctx); \
3617 sig->is_defined = true;
3619 #define MAKE_INTRINSIC(return_type, id, avail, ...) \
3620 ir_function_signature *sig = \
3621 new_sig(return_type, avail, __VA_ARGS__); \
3622 sig->intrinsic_id = id;
3624 ir_function_signature
*
3625 builtin_builder::unop(builtin_available_predicate avail
,
3626 ir_expression_operation opcode
,
3627 const glsl_type
*return_type
,
3628 const glsl_type
*param_type
)
3630 ir_variable
*x
= in_var(param_type
, "x");
3631 MAKE_SIG(return_type
, avail
, 1, x
);
3632 body
.emit(ret(expr(opcode
, x
)));
3636 #define UNOP(NAME, OPCODE, AVAIL) \
3637 ir_function_signature * \
3638 builtin_builder::_##NAME(const glsl_type *type) \
3640 return unop(&AVAIL, OPCODE, type, type); \
3643 #define UNOPA(NAME, OPCODE) \
3644 ir_function_signature * \
3645 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3647 return unop(avail, OPCODE, type, type); \
3650 ir_function_signature
*
3651 builtin_builder::binop(builtin_available_predicate avail
,
3652 ir_expression_operation opcode
,
3653 const glsl_type
*return_type
,
3654 const glsl_type
*param0_type
,
3655 const glsl_type
*param1_type
,
3658 ir_variable
*x
= in_var(param0_type
, "x");
3659 ir_variable
*y
= in_var(param1_type
, "y");
3660 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3663 body
.emit(ret(expr(opcode
, y
, x
)));
3665 body
.emit(ret(expr(opcode
, x
, y
)));
3670 #define BINOP(NAME, OPCODE, AVAIL) \
3671 ir_function_signature * \
3672 builtin_builder::_##NAME(const glsl_type *return_type, \
3673 const glsl_type *param0_type, \
3674 const glsl_type *param1_type) \
3676 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3680 * Angle and Trigonometry Functions @{
3683 ir_function_signature
*
3684 builtin_builder::_radians(const glsl_type
*type
)
3686 ir_variable
*degrees
= in_var(type
, "degrees");
3687 MAKE_SIG(type
, always_available
, 1, degrees
);
3688 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3692 ir_function_signature
*
3693 builtin_builder::_degrees(const glsl_type
*type
)
3695 ir_variable
*radians
= in_var(type
, "radians");
3696 MAKE_SIG(type
, always_available
, 1, radians
);
3697 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3701 UNOP(sin
, ir_unop_sin
, always_available
)
3702 UNOP(cos
, ir_unop_cos
, always_available
)
3704 ir_function_signature
*
3705 builtin_builder::_tan(const glsl_type
*type
)
3707 ir_variable
*theta
= in_var(type
, "theta");
3708 MAKE_SIG(type
, always_available
, 1, theta
);
3709 body
.emit(ret(div(sin(theta
), cos(theta
))));
3714 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3718 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3721 add(imm(M_PI_4f
- 1.0f
),
3724 mul(abs(x
), imm(p1
))))))))));
3728 * Generate a ir_call to a function with a set of parameters
3730 * The input \c params can either be a list of \c ir_variable or a list of
3731 * \c ir_dereference_variable. In the latter case, all nodes will be removed
3732 * from \c params and used directly as the parameters to the generated
3736 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3738 exec_list actual_params
;
3740 foreach_in_list_safe(ir_instruction
, ir
, ¶ms
) {
3741 ir_dereference_variable
*d
= ir
->as_dereference_variable();
3744 actual_params
.push_tail(d
);
3746 ir_variable
*var
= ir
->as_variable();
3747 assert(var
!= NULL
);
3748 actual_params
.push_tail(var_ref(var
));
3752 ir_function_signature
*sig
=
3753 f
->exact_matching_signature(NULL
, &actual_params
);
3757 ir_dereference_variable
*deref
=
3758 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3760 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3763 ir_function_signature
*
3764 builtin_builder::_asin(const glsl_type
*type
)
3766 ir_variable
*x
= in_var(type
, "x");
3767 MAKE_SIG(type
, always_available
, 1, x
);
3769 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3774 ir_function_signature
*
3775 builtin_builder::_acos(const glsl_type
*type
)
3777 ir_variable
*x
= in_var(type
, "x");
3778 MAKE_SIG(type
, always_available
, 1, x
);
3780 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3785 ir_function_signature
*
3786 builtin_builder::_atan2(const glsl_type
*type
)
3788 const unsigned n
= type
->vector_elements
;
3789 ir_variable
*y
= in_var(type
, "y");
3790 ir_variable
*x
= in_var(type
, "x");
3791 MAKE_SIG(type
, always_available
, 2, y
, x
);
3793 /* If we're on the left half-plane rotate the coordinates π/2 clock-wise
3794 * for the y=0 discontinuity to end up aligned with the vertical
3795 * discontinuity of atan(s/t) along t=0. This also makes sure that we
3796 * don't attempt to divide by zero along the vertical line, which may give
3797 * unspecified results on non-GLSL 4.1-capable hardware.
3799 ir_variable
*flip
= body
.make_temp(glsl_type::bvec(n
), "flip");
3800 body
.emit(assign(flip
, gequal(imm(0.0f
, n
), x
)));
3801 ir_variable
*s
= body
.make_temp(type
, "s");
3802 body
.emit(assign(s
, csel(flip
, abs(x
), y
)));
3803 ir_variable
*t
= body
.make_temp(type
, "t");
3804 body
.emit(assign(t
, csel(flip
, y
, abs(x
))));
3806 /* If the magnitude of the denominator exceeds some huge value, scale down
3807 * the arguments in order to prevent the reciprocal operation from flushing
3808 * its result to zero, which would cause precision problems, and for s
3809 * infinite would cause us to return a NaN instead of the correct finite
3812 * If fmin and fmax are respectively the smallest and largest positive
3813 * normalized floating point values representable by the implementation,
3814 * the constants below should be in agreement with:
3817 * scale <= 1 / fmin / fmax (for |t| >= huge)
3819 * In addition scale should be a negative power of two in order to avoid
3820 * loss of precision. The values chosen below should work for most usual
3821 * floating point representations with at least the dynamic range of ATI's
3822 * 24-bit representation.
3824 ir_constant
*huge
= imm(1e18f
, n
);
3825 ir_variable
*scale
= body
.make_temp(type
, "scale");
3826 body
.emit(assign(scale
, csel(gequal(abs(t
), huge
),
3827 imm(0.25f
, n
), imm(1.0f
, n
))));
3828 ir_variable
*rcp_scaled_t
= body
.make_temp(type
, "rcp_scaled_t");
3829 body
.emit(assign(rcp_scaled_t
, rcp(mul(t
, scale
))));
3830 ir_expression
*s_over_t
= mul(mul(s
, scale
), rcp_scaled_t
);
3832 /* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily
3833 * that ∞/∞ = 1) in order to comply with the rather artificial rules
3834 * inherited from IEEE 754-2008, namely:
3836 * "atan2(±∞, −∞) is ±3π/4
3837 * atan2(±∞, +∞) is ±π/4"
3839 * Note that this is inconsistent with the rules for the neighborhood of
3840 * zero that are based on iterated limits:
3842 * "atan2(±0, −0) is ±π
3843 * atan2(±0, +0) is ±0"
3845 * but GLSL specifically allows implementations to deviate from IEEE rules
3846 * at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as
3849 ir_expression
*tan
= csel(equal(abs(x
), abs(y
)),
3850 imm(1.0f
, n
), abs(s_over_t
));
3852 /* Calculate the arctangent and fix up the result if we had flipped the
3853 * coordinate system.
3855 ir_variable
*arc
= body
.make_temp(type
, "arc");
3856 do_atan(body
, type
, arc
, tan
);
3857 body
.emit(assign(arc
, add(arc
, mul(b2f(flip
), imm(M_PI_2f
)))));
3859 /* Rather convoluted calculation of the sign of the result. When x < 0 we
3860 * cannot use fsign because we need to be able to distinguish between
3861 * negative and positive zero. Unfortunately we cannot use bitwise
3862 * arithmetic tricks either because of back-ends without integer support.
3863 * When x >= 0 rcp_scaled_t will always be non-negative so this won't be
3864 * able to distinguish between negative and positive zero, but we don't
3865 * care because atan2 is continuous along the whole positive y = 0
3866 * half-line, so it won't affect the result significantly.
3868 body
.emit(ret(csel(less(min2(y
, rcp_scaled_t
), imm(0.0f
, n
)),
3875 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3878 * range-reduction, first step:
3880 * / y_over_x if |y_over_x| <= 1.0;
3882 * \ 1.0 / y_over_x otherwise
3884 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3885 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3891 * approximate atan by evaluating polynomial:
3893 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3894 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3895 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3897 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3898 body
.emit(assign(tmp
, mul(x
, x
)));
3899 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3901 imm(0.0536813784310406f
)),
3903 imm(0.1173503194786851f
)),
3905 imm(0.1938924977115610f
)),
3907 imm(0.3326756418091246f
)),
3909 imm(0.9999793128310355f
)),
3912 /* range-reduction fixup */
3913 body
.emit(assign(tmp
, add(tmp
,
3914 mul(b2f(greater(abs(y_over_x
),
3915 imm(1.0f
, type
->components()))),
3921 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3924 ir_function_signature
*
3925 builtin_builder::_atan(const glsl_type
*type
)
3927 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3928 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3930 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3931 do_atan(body
, type
, tmp
, y_over_x
);
3932 body
.emit(ret(tmp
));
3937 ir_function_signature
*
3938 builtin_builder::_sinh(const glsl_type
*type
)
3940 ir_variable
*x
= in_var(type
, "x");
3941 MAKE_SIG(type
, v130
, 1, x
);
3943 /* 0.5 * (e^x - e^(-x)) */
3944 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3949 ir_function_signature
*
3950 builtin_builder::_cosh(const glsl_type
*type
)
3952 ir_variable
*x
= in_var(type
, "x");
3953 MAKE_SIG(type
, v130
, 1, x
);
3955 /* 0.5 * (e^x + e^(-x)) */
3956 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3961 ir_function_signature
*
3962 builtin_builder::_tanh(const glsl_type
*type
)
3964 ir_variable
*x
= in_var(type
, "x");
3965 MAKE_SIG(type
, v130
, 1, x
);
3967 /* tanh(x) := (0.5 * (e^x - e^(-x))) / (0.5 * (e^x + e^(-x)))
3969 * With a little algebra this reduces to (e^2x - 1) / (e^2x + 1)
3971 * Clamp x to (-inf, +10] to avoid precision problems. When x > 10, e^2x
3972 * is so much larger than 1.0 that 1.0 gets flushed to zero in the
3973 * computation e^2x +/- 1 so it can be ignored.
3975 ir_variable
*t
= body
.make_temp(type
, "tmp");
3976 body
.emit(assign(t
, min2(x
, imm(10.0f
))));
3978 body
.emit(ret(div(sub(exp(mul(t
, imm(2.0f
))), imm(1.0f
)),
3979 add(exp(mul(t
, imm(2.0f
))), imm(1.0f
)))));
3984 ir_function_signature
*
3985 builtin_builder::_asinh(const glsl_type
*type
)
3987 ir_variable
*x
= in_var(type
, "x");
3988 MAKE_SIG(type
, v130
, 1, x
);
3990 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3995 ir_function_signature
*
3996 builtin_builder::_acosh(const glsl_type
*type
)
3998 ir_variable
*x
= in_var(type
, "x");
3999 MAKE_SIG(type
, v130
, 1, x
);
4001 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
4005 ir_function_signature
*
4006 builtin_builder::_atanh(const glsl_type
*type
)
4008 ir_variable
*x
= in_var(type
, "x");
4009 MAKE_SIG(type
, v130
, 1, x
);
4011 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
4012 sub(imm(1.0f
), x
))))));
4018 * Exponential Functions @{
4021 ir_function_signature
*
4022 builtin_builder::_pow(const glsl_type
*type
)
4024 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
4027 UNOP(exp
, ir_unop_exp
, always_available
)
4028 UNOP(log
, ir_unop_log
, always_available
)
4029 UNOP(exp2
, ir_unop_exp2
, always_available
)
4030 UNOP(log2
, ir_unop_log2
, always_available
)
4031 UNOPA(sqrt
, ir_unop_sqrt
)
4032 UNOPA(inversesqrt
, ir_unop_rsq
)
4036 UNOPA(abs
, ir_unop_abs
)
4037 UNOPA(sign
, ir_unop_sign
)
4038 UNOPA(floor
, ir_unop_floor
)
4039 UNOPA(trunc
, ir_unop_trunc
)
4040 UNOPA(round
, ir_unop_round_even
)
4041 UNOPA(roundEven
, ir_unop_round_even
)
4042 UNOPA(ceil
, ir_unop_ceil
)
4043 UNOPA(fract
, ir_unop_fract
)
4045 ir_function_signature
*
4046 builtin_builder::_mod(builtin_available_predicate avail
,
4047 const glsl_type
*x_type
, const glsl_type
*y_type
)
4049 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
4052 ir_function_signature
*
4053 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
4055 ir_variable
*x
= in_var(type
, "x");
4056 ir_variable
*i
= out_var(type
, "i");
4057 MAKE_SIG(type
, avail
, 2, x
, i
);
4059 ir_variable
*t
= body
.make_temp(type
, "t");
4060 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
4061 body
.emit(assign(i
, t
));
4062 body
.emit(ret(sub(x
, t
)));
4067 ir_function_signature
*
4068 builtin_builder::_min(builtin_available_predicate avail
,
4069 const glsl_type
*x_type
, const glsl_type
*y_type
)
4071 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
4074 ir_function_signature
*
4075 builtin_builder::_max(builtin_available_predicate avail
,
4076 const glsl_type
*x_type
, const glsl_type
*y_type
)
4078 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
4081 ir_function_signature
*
4082 builtin_builder::_clamp(builtin_available_predicate avail
,
4083 const glsl_type
*val_type
, const glsl_type
*bound_type
)
4085 ir_variable
*x
= in_var(val_type
, "x");
4086 ir_variable
*minVal
= in_var(bound_type
, "minVal");
4087 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
4088 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
4090 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
4095 ir_function_signature
*
4096 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
4098 ir_variable
*x
= in_var(val_type
, "x");
4099 ir_variable
*y
= in_var(val_type
, "y");
4100 ir_variable
*a
= in_var(blend_type
, "a");
4101 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4103 body
.emit(ret(lrp(x
, y
, a
)));
4108 ir_function_signature
*
4109 builtin_builder::_mix_sel(builtin_available_predicate avail
,
4110 const glsl_type
*val_type
,
4111 const glsl_type
*blend_type
)
4113 ir_variable
*x
= in_var(val_type
, "x");
4114 ir_variable
*y
= in_var(val_type
, "y");
4115 ir_variable
*a
= in_var(blend_type
, "a");
4116 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4118 /* csel matches the ternary operator in that a selector of true choses the
4119 * first argument. This differs from mix(x, y, false) which choses the
4120 * second argument (to remain consistent with the interpolating version of
4121 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
4123 * To handle the behavior mismatch, reverse the x and y arguments.
4125 body
.emit(ret(csel(a
, y
, x
)));
4130 ir_function_signature
*
4131 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4133 ir_variable
*edge
= in_var(edge_type
, "edge");
4134 ir_variable
*x
= in_var(x_type
, "x");
4135 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
4137 ir_variable
*t
= body
.make_temp(x_type
, "t");
4138 if (x_type
->vector_elements
== 1) {
4139 /* Both are floats */
4140 if (edge_type
->is_double())
4141 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
4143 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
4144 } else if (edge_type
->vector_elements
== 1) {
4145 /* x is a vector but edge is a float */
4146 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4147 if (edge_type
->is_double())
4148 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
4150 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
4153 /* Both are vectors */
4154 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4155 if (edge_type
->is_double())
4156 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
4159 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
4169 ir_function_signature
*
4170 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4172 ir_variable
*edge0
= in_var(edge_type
, "edge0");
4173 ir_variable
*edge1
= in_var(edge_type
, "edge1");
4174 ir_variable
*x
= in_var(x_type
, "x");
4175 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
4177 /* From the GLSL 1.10 specification:
4180 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
4181 * return t * t * (3 - 2 * t);
4184 ir_variable
*t
= body
.make_temp(x_type
, "t");
4185 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
4186 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
4188 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
4193 ir_function_signature
*
4194 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
4196 ir_variable
*x
= in_var(type
, "x");
4197 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4199 body
.emit(ret(nequal(x
, x
)));
4204 ir_function_signature
*
4205 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
4207 ir_variable
*x
= in_var(type
, "x");
4208 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4210 ir_constant_data infinities
;
4211 for (int i
= 0; i
< type
->vector_elements
; i
++) {
4212 switch (type
->base_type
) {
4213 case GLSL_TYPE_FLOAT
:
4214 infinities
.f
[i
] = INFINITY
;
4216 case GLSL_TYPE_DOUBLE
:
4217 infinities
.d
[i
] = INFINITY
;
4220 unreachable("unknown type");
4224 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
4229 ir_function_signature
*
4230 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
4232 ir_variable
*x
= in_var(type
, "x");
4233 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4234 body
.emit(ret(bitcast_f2i(x
)));
4238 ir_function_signature
*
4239 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
4241 ir_variable
*x
= in_var(type
, "x");
4242 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4243 body
.emit(ret(bitcast_f2u(x
)));
4247 ir_function_signature
*
4248 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
4250 ir_variable
*x
= in_var(type
, "x");
4251 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4252 body
.emit(ret(bitcast_i2f(x
)));
4256 ir_function_signature
*
4257 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
4259 ir_variable
*x
= in_var(type
, "x");
4260 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4261 body
.emit(ret(bitcast_u2f(x
)));
4265 ir_function_signature
*
4266 builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail
, const glsl_type
*type
)
4268 ir_variable
*x
= in_var(type
, "x");
4269 MAKE_SIG(glsl_type::i64vec(type
->vector_elements
), avail
, 1, x
);
4270 body
.emit(ret(bitcast_d2i64(x
)));
4274 ir_function_signature
*
4275 builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail
, const glsl_type
*type
)
4277 ir_variable
*x
= in_var(type
, "x");
4278 MAKE_SIG(glsl_type::u64vec(type
->vector_elements
), avail
, 1, x
);
4279 body
.emit(ret(bitcast_d2u64(x
)));
4283 ir_function_signature
*
4284 builtin_builder::_int64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4286 ir_variable
*x
= in_var(type
, "x");
4287 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4288 body
.emit(ret(bitcast_i642d(x
)));
4292 ir_function_signature
*
4293 builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4295 ir_variable
*x
= in_var(type
, "x");
4296 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4297 body
.emit(ret(bitcast_u642d(x
)));
4301 ir_function_signature
*
4302 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
4304 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4305 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4306 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
4310 ir_function_signature
*
4311 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
4313 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4314 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4315 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
4319 ir_function_signature
*
4320 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
4322 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4323 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4324 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
4328 ir_function_signature
*
4329 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
4331 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4332 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4333 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
4337 ir_function_signature
*
4338 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
4340 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4341 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4342 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
4346 ir_function_signature
*
4347 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
4349 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4350 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4351 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
4356 ir_function_signature
*
4357 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
4359 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4360 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4361 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
4365 ir_function_signature
*
4366 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
4368 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4369 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4370 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
4374 ir_function_signature
*
4375 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
4377 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4378 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4379 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
4383 ir_function_signature
*
4384 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
4386 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4387 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4388 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
4392 ir_function_signature
*
4393 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
4395 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4396 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
4397 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
4401 ir_function_signature
*
4402 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
4404 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
4405 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4406 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
4410 ir_function_signature
*
4411 builtin_builder::_packInt2x32(builtin_available_predicate avail
)
4413 ir_variable
*v
= in_var(glsl_type::ivec2_type
, "v");
4414 MAKE_SIG(glsl_type::int64_t_type
, avail
, 1, v
);
4415 body
.emit(ret(expr(ir_unop_pack_int_2x32
, v
)));
4419 ir_function_signature
*
4420 builtin_builder::_unpackInt2x32(builtin_available_predicate avail
)
4422 ir_variable
*p
= in_var(glsl_type::int64_t_type
, "p");
4423 MAKE_SIG(glsl_type::ivec2_type
, avail
, 1, p
);
4424 body
.emit(ret(expr(ir_unop_unpack_int_2x32
, p
)));
4428 ir_function_signature
*
4429 builtin_builder::_packUint2x32(builtin_available_predicate avail
)
4431 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4432 MAKE_SIG(glsl_type::uint64_t_type
, avail
, 1, v
);
4433 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, v
)));
4437 ir_function_signature
*
4438 builtin_builder::_unpackUint2x32(builtin_available_predicate avail
)
4440 ir_variable
*p
= in_var(glsl_type::uint64_t_type
, "p");
4441 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4442 body
.emit(ret(expr(ir_unop_unpack_uint_2x32
, p
)));
4446 ir_function_signature
*
4447 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
4449 ir_variable
*x
= in_var(type
, "x");
4450 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
4452 body
.emit(ret(sqrt(dot(x
, x
))));
4457 ir_function_signature
*
4458 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
4460 ir_variable
*p0
= in_var(type
, "p0");
4461 ir_variable
*p1
= in_var(type
, "p1");
4462 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
4464 if (type
->vector_elements
== 1) {
4465 body
.emit(ret(abs(sub(p0
, p1
))));
4467 ir_variable
*p
= body
.make_temp(type
, "p");
4468 body
.emit(assign(p
, sub(p0
, p1
)));
4469 body
.emit(ret(sqrt(dot(p
, p
))));
4475 ir_function_signature
*
4476 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
4478 if (type
->vector_elements
== 1)
4479 return binop(avail
, ir_binop_mul
, type
, type
, type
);
4481 return binop(avail
, ir_binop_dot
,
4482 type
->get_base_type(), type
, type
);
4485 ir_function_signature
*
4486 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
4488 ir_variable
*a
= in_var(type
, "a");
4489 ir_variable
*b
= in_var(type
, "b");
4490 MAKE_SIG(type
, avail
, 2, a
, b
);
4492 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
4493 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
4495 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
4496 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
4501 ir_function_signature
*
4502 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
4504 ir_variable
*x
= in_var(type
, "x");
4505 MAKE_SIG(type
, avail
, 1, x
);
4507 if (type
->vector_elements
== 1) {
4508 body
.emit(ret(sign(x
)));
4510 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
4516 ir_function_signature
*
4517 builtin_builder::_ftransform()
4519 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
4521 /* ftransform() refers to global variables, and is always emitted
4522 * directly by ast_function.cpp. Just emit a prototype here so we
4523 * can recognize calls to it.
4528 ir_function_signature
*
4529 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
4531 ir_variable
*N
= in_var(type
, "N");
4532 ir_variable
*I
= in_var(type
, "I");
4533 ir_variable
*Nref
= in_var(type
, "Nref");
4534 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
4536 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
4537 ret(N
), ret(neg(N
))));
4542 ir_function_signature
*
4543 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
4545 ir_variable
*I
= in_var(type
, "I");
4546 ir_variable
*N
= in_var(type
, "N");
4547 MAKE_SIG(type
, avail
, 2, I
, N
);
4549 /* I - 2 * dot(N, I) * N */
4550 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
4555 ir_function_signature
*
4556 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
4558 ir_variable
*I
= in_var(type
, "I");
4559 ir_variable
*N
= in_var(type
, "N");
4560 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
4561 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4563 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4564 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4566 /* From the GLSL 1.10 specification:
4567 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4569 * return genType(0.0)
4571 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4573 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4574 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4575 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4576 mul(n_dot_i
, n_dot_i
)))))));
4577 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4578 ret(ir_constant::zero(mem_ctx
, type
)),
4579 ret(sub(mul(eta
, I
),
4580 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4585 ir_function_signature
*
4586 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4588 ir_variable
*x
= in_var(type
, "x");
4589 ir_variable
*y
= in_var(type
, "y");
4590 MAKE_SIG(type
, avail
, 2, x
, y
);
4592 ir_variable
*z
= body
.make_temp(type
, "z");
4593 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4594 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4601 ir_function_signature
*
4602 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4607 if (type
->is_double()) {
4608 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4609 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4611 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4612 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4614 MAKE_SIG(type
, avail
, 2, c
, r
);
4616 ir_variable
*m
= body
.make_temp(type
, "m");
4617 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4618 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4625 ir_function_signature
*
4626 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4628 const glsl_type
*transpose_type
=
4629 glsl_type::get_instance(orig_type
->base_type
,
4630 orig_type
->matrix_columns
,
4631 orig_type
->vector_elements
);
4633 ir_variable
*m
= in_var(orig_type
, "m");
4634 MAKE_SIG(transpose_type
, avail
, 1, m
);
4636 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4637 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4638 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4639 body
.emit(assign(array_ref(t
, j
),
4640 matrix_elt(m
, i
, j
),
4649 ir_function_signature
*
4650 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4652 ir_variable
*m
= in_var(type
, "m");
4653 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4655 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4656 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4661 ir_function_signature
*
4662 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4664 ir_variable
*m
= in_var(type
, "m");
4665 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4668 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4669 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4672 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4673 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4676 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4677 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4679 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4680 mul(matrix_elt(m
, 0, 1), f2
)),
4681 mul(matrix_elt(m
, 0, 2), f3
))));
4686 ir_function_signature
*
4687 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4689 ir_variable
*m
= in_var(type
, "m");
4690 const glsl_type
*btype
= type
->get_base_type();
4691 MAKE_SIG(btype
, avail
, 1, m
);
4693 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4694 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4695 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4696 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4697 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4698 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4699 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4700 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4701 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4702 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4703 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4704 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4705 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4706 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4707 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4708 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4709 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4710 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4711 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4713 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)))));
4714 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)))));
4715 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)))));
4716 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)))));
4717 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)))));
4718 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)))));
4719 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)))));
4720 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)))));
4721 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)))));
4722 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)))));
4723 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)))));
4724 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)))));
4725 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)))));
4726 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)))));
4727 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)))));
4728 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)))));
4729 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)))));
4730 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)))));
4731 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)))));
4733 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4735 body
.emit(assign(adj_0
,
4736 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4737 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4738 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4740 body
.emit(assign(adj_0
, neg(
4741 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4742 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4743 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4745 body
.emit(assign(adj_0
,
4746 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4747 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4748 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4750 body
.emit(assign(adj_0
, neg(
4751 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4752 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4753 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4756 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4761 ir_function_signature
*
4762 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4764 ir_variable
*m
= in_var(type
, "m");
4765 MAKE_SIG(type
, avail
, 1, m
);
4767 ir_variable
*adj
= body
.make_temp(type
, "adj");
4768 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4769 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4770 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4771 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4773 ir_expression
*det
=
4774 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4775 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4777 body
.emit(ret(div(adj
, det
)));
4781 ir_function_signature
*
4782 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4784 ir_variable
*m
= in_var(type
, "m");
4785 const glsl_type
*btype
= type
->get_base_type();
4786 MAKE_SIG(type
, avail
, 1, m
);
4788 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4789 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4790 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4792 body
.emit(assign(f11_22_21_12
,
4793 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4794 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4795 body
.emit(assign(f10_22_20_12
,
4796 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4797 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4798 body
.emit(assign(f10_21_20_11
,
4799 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4800 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4802 ir_variable
*adj
= body
.make_temp(type
, "adj");
4803 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4804 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4805 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4807 body
.emit(assign(array_ref(adj
, 0), neg(
4808 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4809 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4811 body
.emit(assign(array_ref(adj
, 1),
4812 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4813 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4815 body
.emit(assign(array_ref(adj
, 2), neg(
4816 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4817 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4820 body
.emit(assign(array_ref(adj
, 0),
4821 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4822 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4824 body
.emit(assign(array_ref(adj
, 1), neg(
4825 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4826 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4828 body
.emit(assign(array_ref(adj
, 2),
4829 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4830 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4833 ir_expression
*det
=
4834 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4835 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4836 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4838 body
.emit(ret(div(adj
, det
)));
4843 ir_function_signature
*
4844 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4846 ir_variable
*m
= in_var(type
, "m");
4847 const glsl_type
*btype
= type
->get_base_type();
4848 MAKE_SIG(type
, avail
, 1, m
);
4850 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4851 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4852 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4853 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4854 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4855 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4856 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4857 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4858 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4859 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4860 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4861 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4862 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4863 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4864 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4865 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4866 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4867 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4868 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4870 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)))));
4871 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)))));
4872 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)))));
4873 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)))));
4874 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)))));
4875 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)))));
4876 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)))));
4877 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)))));
4878 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)))));
4879 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)))));
4880 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)))));
4881 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)))));
4882 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)))));
4883 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)))));
4884 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)))));
4885 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)))));
4886 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)))));
4887 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)))));
4888 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)))));
4890 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4891 body
.emit(assign(array_ref(adj
, 0),
4892 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4893 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4894 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4896 body
.emit(assign(array_ref(adj
, 1), neg(
4897 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4898 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4899 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4901 body
.emit(assign(array_ref(adj
, 2),
4902 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4903 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4904 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4906 body
.emit(assign(array_ref(adj
, 3), neg(
4907 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4908 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4909 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4912 body
.emit(assign(array_ref(adj
, 0), neg(
4913 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4914 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4915 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4917 body
.emit(assign(array_ref(adj
, 1),
4918 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4919 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4920 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4922 body
.emit(assign(array_ref(adj
, 2), neg(
4923 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4924 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4925 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4927 body
.emit(assign(array_ref(adj
, 3),
4928 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4929 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4930 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4933 body
.emit(assign(array_ref(adj
, 0),
4934 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4935 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4936 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4938 body
.emit(assign(array_ref(adj
, 1), neg(
4939 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4940 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4941 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4943 body
.emit(assign(array_ref(adj
, 2),
4944 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4945 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4946 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4948 body
.emit(assign(array_ref(adj
, 3), neg(
4949 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4950 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4951 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4954 body
.emit(assign(array_ref(adj
, 0), neg(
4955 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4956 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4957 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4959 body
.emit(assign(array_ref(adj
, 1),
4960 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4961 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4962 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4964 body
.emit(assign(array_ref(adj
, 2), neg(
4965 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4966 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4967 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4969 body
.emit(assign(array_ref(adj
, 3),
4970 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4971 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4972 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4975 ir_expression
*det
=
4976 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4977 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4978 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4979 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4981 body
.emit(ret(div(adj
, det
)));
4987 ir_function_signature
*
4988 builtin_builder::_lessThan(builtin_available_predicate avail
,
4989 const glsl_type
*type
)
4991 return binop(avail
, ir_binop_less
,
4992 glsl_type::bvec(type
->vector_elements
), type
, type
);
4995 ir_function_signature
*
4996 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4997 const glsl_type
*type
)
4999 return binop(avail
, ir_binop_gequal
,
5000 glsl_type::bvec(type
->vector_elements
), type
, type
,
5004 ir_function_signature
*
5005 builtin_builder::_greaterThan(builtin_available_predicate avail
,
5006 const glsl_type
*type
)
5008 return binop(avail
, ir_binop_less
,
5009 glsl_type::bvec(type
->vector_elements
), type
, type
,
5013 ir_function_signature
*
5014 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
5015 const glsl_type
*type
)
5017 return binop(avail
, ir_binop_gequal
,
5018 glsl_type::bvec(type
->vector_elements
), type
, type
);
5021 ir_function_signature
*
5022 builtin_builder::_equal(builtin_available_predicate avail
,
5023 const glsl_type
*type
)
5025 return binop(avail
, ir_binop_equal
,
5026 glsl_type::bvec(type
->vector_elements
), type
, type
);
5029 ir_function_signature
*
5030 builtin_builder::_notEqual(builtin_available_predicate avail
,
5031 const glsl_type
*type
)
5033 return binop(avail
, ir_binop_nequal
,
5034 glsl_type::bvec(type
->vector_elements
), type
, type
);
5037 ir_function_signature
*
5038 builtin_builder::_any(const glsl_type
*type
)
5040 ir_variable
*v
= in_var(type
, "v");
5041 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5043 const unsigned vec_elem
= v
->type
->vector_elements
;
5044 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
5049 ir_function_signature
*
5050 builtin_builder::_all(const glsl_type
*type
)
5052 ir_variable
*v
= in_var(type
, "v");
5053 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5055 const unsigned vec_elem
= v
->type
->vector_elements
;
5056 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
5061 UNOP(not, ir_unop_logic_not
, always_available
)
5064 has_lod(const glsl_type
*sampler_type
)
5066 assert(sampler_type
->is_sampler());
5068 switch (sampler_type
->sampler_dimensionality
) {
5069 case GLSL_SAMPLER_DIM_RECT
:
5070 case GLSL_SAMPLER_DIM_BUF
:
5071 case GLSL_SAMPLER_DIM_MS
:
5078 ir_function_signature
*
5079 builtin_builder::_textureSize(builtin_available_predicate avail
,
5080 const glsl_type
*return_type
,
5081 const glsl_type
*sampler_type
)
5083 ir_variable
*s
= in_var(sampler_type
, "sampler");
5084 /* The sampler always exists; add optional lod later. */
5085 MAKE_SIG(return_type
, avail
, 1, s
);
5087 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
5088 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
5090 if (has_lod(sampler_type
)) {
5091 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5092 sig
->parameters
.push_tail(lod
);
5093 tex
->lod_info
.lod
= var_ref(lod
);
5095 tex
->lod_info
.lod
= imm(0u);
5098 body
.emit(ret(tex
));
5103 ir_function_signature
*
5104 builtin_builder::_textureSamples(builtin_available_predicate avail
,
5105 const glsl_type
*sampler_type
)
5107 ir_variable
*s
= in_var(sampler_type
, "sampler");
5108 MAKE_SIG(glsl_type::int_type
, avail
, 1, s
);
5110 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
5111 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
5112 body
.emit(ret(tex
));
5117 ir_function_signature
*
5118 builtin_builder::_texture(ir_texture_opcode opcode
,
5119 builtin_available_predicate avail
,
5120 const glsl_type
*return_type
,
5121 const glsl_type
*sampler_type
,
5122 const glsl_type
*coord_type
,
5125 ir_variable
*s
= in_var(sampler_type
, "sampler");
5126 ir_variable
*P
= in_var(coord_type
, "P");
5127 /* The sampler and coordinate always exist; add optional parameters later. */
5128 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5130 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
5131 tex
->set_sampler(var_ref(s
), return_type
);
5133 const int coord_size
= sampler_type
->coordinate_components();
5135 if (coord_size
== coord_type
->vector_elements
) {
5136 tex
->coordinate
= var_ref(P
);
5138 /* The incoming coordinate also has the projector or shadow comparator,
5139 * so we need to swizzle those away.
5141 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
5144 /* The projector is always in the last component. */
5145 if (flags
& TEX_PROJECT
)
5146 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
5148 if (sampler_type
->sampler_shadow
) {
5149 if (opcode
== ir_tg4
) {
5150 /* gather has refz as a separate parameter, immediately after the
5153 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
5154 sig
->parameters
.push_tail(refz
);
5155 tex
->shadow_comparator
= var_ref(refz
);
5157 /* The shadow comparator is normally in the Z component, but a few types
5158 * have sufficiently large coordinates that it's in W.
5160 tex
->shadow_comparator
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
5164 if (opcode
== ir_txl
) {
5165 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
5166 sig
->parameters
.push_tail(lod
);
5167 tex
->lod_info
.lod
= var_ref(lod
);
5168 } else if (opcode
== ir_txd
) {
5169 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5170 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
5171 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
5172 sig
->parameters
.push_tail(dPdx
);
5173 sig
->parameters
.push_tail(dPdy
);
5174 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
5175 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
5178 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
5179 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5180 ir_variable
*offset
=
5181 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
5182 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
5183 sig
->parameters
.push_tail(offset
);
5184 tex
->offset
= var_ref(offset
);
5187 if (flags
& TEX_OFFSET_ARRAY
) {
5188 ir_variable
*offsets
=
5189 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
5190 "offsets", ir_var_const_in
);
5191 sig
->parameters
.push_tail(offsets
);
5192 tex
->offset
= var_ref(offsets
);
5195 if (opcode
== ir_tg4
) {
5196 if (flags
& TEX_COMPONENT
) {
5197 ir_variable
*component
=
5198 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
5199 sig
->parameters
.push_tail(component
);
5200 tex
->lod_info
.component
= var_ref(component
);
5203 tex
->lod_info
.component
= imm(0);
5207 /* The "bias" parameter comes /after/ the "offset" parameter, which is
5208 * inconsistent with both textureLodOffset and textureGradOffset.
5210 if (opcode
== ir_txb
) {
5211 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
5212 sig
->parameters
.push_tail(bias
);
5213 tex
->lod_info
.bias
= var_ref(bias
);
5216 body
.emit(ret(tex
));
5221 ir_function_signature
*
5222 builtin_builder::_textureCubeArrayShadow(builtin_available_predicate avail
,
5223 const glsl_type
*sampler_type
)
5225 ir_variable
*s
= in_var(sampler_type
, "sampler");
5226 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
5227 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
5228 MAKE_SIG(glsl_type::float_type
, avail
, 3, s
, P
, compare
);
5230 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
5231 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
5233 tex
->coordinate
= var_ref(P
);
5234 tex
->shadow_comparator
= var_ref(compare
);
5236 body
.emit(ret(tex
));
5241 ir_function_signature
*
5242 builtin_builder::_texelFetch(builtin_available_predicate avail
,
5243 const glsl_type
*return_type
,
5244 const glsl_type
*sampler_type
,
5245 const glsl_type
*coord_type
,
5246 const glsl_type
*offset_type
)
5248 ir_variable
*s
= in_var(sampler_type
, "sampler");
5249 ir_variable
*P
= in_var(coord_type
, "P");
5250 /* The sampler and coordinate always exist; add optional parameters later. */
5251 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5253 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
5254 tex
->coordinate
= var_ref(P
);
5255 tex
->set_sampler(var_ref(s
), return_type
);
5257 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
5258 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
5259 sig
->parameters
.push_tail(sample
);
5260 tex
->lod_info
.sample_index
= var_ref(sample
);
5261 tex
->op
= ir_txf_ms
;
5262 } else if (has_lod(sampler_type
)) {
5263 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5264 sig
->parameters
.push_tail(lod
);
5265 tex
->lod_info
.lod
= var_ref(lod
);
5267 tex
->lod_info
.lod
= imm(0u);
5270 if (offset_type
!= NULL
) {
5271 ir_variable
*offset
=
5272 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
5273 sig
->parameters
.push_tail(offset
);
5274 tex
->offset
= var_ref(offset
);
5277 body
.emit(ret(tex
));
5282 ir_function_signature
*
5283 builtin_builder::_EmitVertex()
5285 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5287 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5288 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
5293 ir_function_signature
*
5294 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
5295 const glsl_type
*stream_type
)
5297 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5299 * "Emit the current values of output variables to the current output
5300 * primitive on stream stream. The argument to stream must be a constant
5301 * integral expression."
5303 ir_variable
*stream
=
5304 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5306 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5308 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
5313 ir_function_signature
*
5314 builtin_builder::_EndPrimitive()
5316 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5318 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5319 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
5324 ir_function_signature
*
5325 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
5326 const glsl_type
*stream_type
)
5328 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5330 * "Completes the current output primitive on stream stream and starts
5331 * a new one. The argument to stream must be a constant integral
5334 ir_variable
*stream
=
5335 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5337 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5339 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
5344 ir_function_signature
*
5345 builtin_builder::_barrier()
5347 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
5349 body
.emit(new(mem_ctx
) ir_barrier());
5353 ir_function_signature
*
5354 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
5355 const glsl_type
*sampler_type
,
5356 const glsl_type
*coord_type
)
5358 ir_variable
*s
= in_var(sampler_type
, "sampler");
5359 ir_variable
*coord
= in_var(coord_type
, "coord");
5360 /* The sampler and coordinate always exist; add optional parameters later. */
5361 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
5363 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
5364 tex
->coordinate
= var_ref(coord
);
5365 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
5367 body
.emit(ret(tex
));
5372 ir_function_signature
*
5373 builtin_builder::_textureQueryLevels(builtin_available_predicate avail
,
5374 const glsl_type
*sampler_type
)
5376 ir_variable
*s
= in_var(sampler_type
, "sampler");
5377 const glsl_type
*return_type
= glsl_type::int_type
;
5378 MAKE_SIG(return_type
, avail
, 1, s
);
5380 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
5381 tex
->set_sampler(var_ref(s
), return_type
);
5383 body
.emit(ret(tex
));
5388 ir_function_signature
*
5389 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
5390 const glsl_type
*sampler_type
,
5391 const glsl_type
*coord_type
)
5393 ir_variable
*s
= in_var(sampler_type
, "sampler");
5394 ir_variable
*P
= in_var(coord_type
, "P");
5395 const glsl_type
*return_type
= glsl_type::bool_type
;
5396 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5398 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
5399 tex
->coordinate
= var_ref(P
);
5400 tex
->set_sampler(var_ref(s
), return_type
);
5402 body
.emit(ret(tex
));
5407 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
5408 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
5409 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
5410 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
5411 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
5412 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
5414 ir_function_signature
*
5415 builtin_builder::_fwidth(const glsl_type
*type
)
5417 ir_variable
*p
= in_var(type
, "p");
5418 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
5420 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
5425 ir_function_signature
*
5426 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
5428 ir_variable
*p
= in_var(type
, "p");
5429 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5431 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
5432 abs(expr(ir_unop_dFdy_coarse
, p
)))));
5437 ir_function_signature
*
5438 builtin_builder::_fwidthFine(const glsl_type
*type
)
5440 ir_variable
*p
= in_var(type
, "p");
5441 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5443 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
5444 abs(expr(ir_unop_dFdy_fine
, p
)))));
5449 ir_function_signature
*
5450 builtin_builder::_noise1(const glsl_type
*type
)
5452 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
5455 ir_function_signature
*
5456 builtin_builder::_noise2(const glsl_type
*type
)
5458 ir_variable
*p
= in_var(type
, "p");
5459 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
5461 ir_constant_data b_offset
;
5462 b_offset
.f
[0] = 601.0f
;
5463 b_offset
.f
[1] = 313.0f
;
5464 b_offset
.f
[2] = 29.0f
;
5465 b_offset
.f
[3] = 277.0f
;
5467 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5468 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5469 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
5470 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5471 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5472 body
.emit(assign(t
, a
, WRITEMASK_X
));
5473 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5479 ir_function_signature
*
5480 builtin_builder::_noise3(const glsl_type
*type
)
5482 ir_variable
*p
= in_var(type
, "p");
5483 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
5485 ir_constant_data b_offset
;
5486 b_offset
.f
[0] = 601.0f
;
5487 b_offset
.f
[1] = 313.0f
;
5488 b_offset
.f
[2] = 29.0f
;
5489 b_offset
.f
[3] = 277.0f
;
5491 ir_constant_data c_offset
;
5492 c_offset
.f
[0] = 1559.0f
;
5493 c_offset
.f
[1] = 113.0f
;
5494 c_offset
.f
[2] = 1861.0f
;
5495 c_offset
.f
[3] = 797.0f
;
5497 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5498 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5499 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5500 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
5501 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5502 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5503 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
5504 body
.emit(assign(t
, a
, WRITEMASK_X
));
5505 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5506 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5512 ir_function_signature
*
5513 builtin_builder::_noise4(const glsl_type
*type
)
5515 ir_variable
*p
= in_var(type
, "p");
5516 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
5518 ir_variable
*_p
= body
.make_temp(type
, "_p");
5520 ir_constant_data p_offset
;
5521 p_offset
.f
[0] = 1559.0f
;
5522 p_offset
.f
[1] = 113.0f
;
5523 p_offset
.f
[2] = 1861.0f
;
5524 p_offset
.f
[3] = 797.0f
;
5526 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
5528 ir_constant_data offset
;
5529 offset
.f
[0] = 601.0f
;
5530 offset
.f
[1] = 313.0f
;
5531 offset
.f
[2] = 29.0f
;
5532 offset
.f
[3] = 277.0f
;
5534 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5535 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5536 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5537 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
5538 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
5539 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5540 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
5541 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
5542 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
5543 body
.emit(assign(t
, a
, WRITEMASK_X
));
5544 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5545 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5546 body
.emit(assign(t
, d
, WRITEMASK_W
));
5552 ir_function_signature
*
5553 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
5555 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5556 ir_variable
*value
= in_var(type
, "value");
5557 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5558 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5559 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, value
, offset
,
5562 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5563 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5565 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
5566 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5567 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5572 ir_function_signature
*
5573 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5575 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5576 ir_variable
*base
= in_var(type
, "base");
5577 ir_variable
*insert
= in_var(type
, "insert");
5578 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5579 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5580 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 4, base
, insert
,
5583 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5584 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5586 body
.emit(ret(bitfield_insert(base
, insert
,
5587 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5588 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5593 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31_or_integer_functions
)
5595 ir_function_signature
*
5596 builtin_builder::_bitCount(const glsl_type
*type
)
5598 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_bit_count
,
5599 glsl_type::ivec(type
->vector_elements
), type
);
5602 ir_function_signature
*
5603 builtin_builder::_findLSB(const glsl_type
*type
)
5605 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_lsb
,
5606 glsl_type::ivec(type
->vector_elements
), type
);
5609 ir_function_signature
*
5610 builtin_builder::_findMSB(const glsl_type
*type
)
5612 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_msb
,
5613 glsl_type::ivec(type
->vector_elements
), type
);
5616 ir_function_signature
*
5617 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5619 ir_variable
*a
= in_var(type
, "a");
5620 ir_variable
*b
= in_var(type
, "b");
5621 ir_variable
*c
= in_var(type
, "c");
5622 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5624 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5629 ir_function_signature
*
5630 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5632 return binop(x_type
->is_double() ? fp64
: gpu_shader5_or_es31_or_integer_functions
,
5633 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5636 ir_function_signature
*
5637 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5639 ir_variable
*x
= in_var(x_type
, "x");
5640 ir_variable
*exponent
= out_var(exp_type
, "exp");
5641 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5643 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5645 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5649 ir_function_signature
*
5650 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5652 ir_variable
*x
= in_var(x_type
, "x");
5653 ir_variable
*exponent
= out_var(exp_type
, "exp");
5654 MAKE_SIG(x_type
, gpu_shader5_or_es31_or_integer_functions
, 2, x
, exponent
);
5656 const unsigned vec_elem
= x_type
->vector_elements
;
5657 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5658 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5660 /* Single-precision floating-point values are stored as
5665 * An exponent shift of 23 will shift the mantissa out, leaving only the
5666 * exponent and sign bit (which itself may be zero, if the absolute value
5667 * was taken before the bitcast and shift.
5669 ir_constant
*exponent_shift
= imm(23);
5670 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5672 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5674 /* Exponent of floating-point values in the range [0.5, 1.0). */
5675 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5677 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5678 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5680 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5681 * to unsigned integers to ensure that 1 bits aren't shifted in.
5683 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5684 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5685 imm(0, vec_elem
)))));
5687 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5688 body
.emit(assign(bits
, bitcast_f2u(x
)));
5689 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5690 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5691 imm(0u, vec_elem
)))));
5692 body
.emit(ret(bitcast_u2f(bits
)));
5697 ir_function_signature
*
5698 builtin_builder::_uaddCarry(const glsl_type
*type
)
5700 ir_variable
*x
= in_var(type
, "x");
5701 ir_variable
*y
= in_var(type
, "y");
5702 ir_variable
*carry
= out_var(type
, "carry");
5703 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, carry
);
5705 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5706 body
.emit(ret(add(x
, y
)));
5711 ir_function_signature
*
5712 builtin_builder::_usubBorrow(const glsl_type
*type
)
5714 ir_variable
*x
= in_var(type
, "x");
5715 ir_variable
*y
= in_var(type
, "y");
5716 ir_variable
*borrow
= out_var(type
, "borrow");
5717 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, borrow
);
5719 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5720 body
.emit(ret(sub(x
, y
)));
5726 * For both imulExtended() and umulExtended() built-ins.
5728 ir_function_signature
*
5729 builtin_builder::_mulExtended(const glsl_type
*type
)
5731 ir_variable
*x
= in_var(type
, "x");
5732 ir_variable
*y
= in_var(type
, "y");
5733 ir_variable
*msb
= out_var(type
, "msb");
5734 ir_variable
*lsb
= out_var(type
, "lsb");
5735 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31_or_integer_functions
, 4, x
, y
, msb
, lsb
);
5737 body
.emit(assign(msb
, imul_high(x
, y
)));
5738 body
.emit(assign(lsb
, mul(x
, y
)));
5743 ir_function_signature
*
5744 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5746 ir_variable
*interpolant
= in_var(type
, "interpolant");
5747 interpolant
->data
.must_be_shader_input
= 1;
5748 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5750 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5755 ir_function_signature
*
5756 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5758 ir_variable
*interpolant
= in_var(type
, "interpolant");
5759 interpolant
->data
.must_be_shader_input
= 1;
5760 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5761 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5763 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5768 ir_function_signature
*
5769 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5771 ir_variable
*interpolant
= in_var(type
, "interpolant");
5772 interpolant
->data
.must_be_shader_input
= 1;
5773 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5774 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5776 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5781 ir_function_signature
*
5782 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
,
5783 enum ir_intrinsic_id id
)
5785 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5786 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 1, counter
);
5790 ir_function_signature
*
5791 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
,
5792 enum ir_intrinsic_id id
)
5794 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5795 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5796 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 2, counter
, data
);
5800 ir_function_signature
*
5801 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
,
5802 enum ir_intrinsic_id id
)
5804 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5805 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5806 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5807 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 3, counter
, compare
, data
);
5811 ir_function_signature
*
5812 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5813 const glsl_type
*type
,
5814 enum ir_intrinsic_id id
)
5816 ir_variable
*atomic
= in_var(type
, "atomic");
5817 ir_variable
*data
= in_var(type
, "data");
5818 MAKE_INTRINSIC(type
, id
, avail
, 2, atomic
, data
);
5822 ir_function_signature
*
5823 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5824 const glsl_type
*type
,
5825 enum ir_intrinsic_id id
)
5827 ir_variable
*atomic
= in_var(type
, "atomic");
5828 ir_variable
*data1
= in_var(type
, "data1");
5829 ir_variable
*data2
= in_var(type
, "data2");
5830 MAKE_INTRINSIC(type
, id
, avail
, 3, atomic
, data1
, data2
);
5834 ir_function_signature
*
5835 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5836 builtin_available_predicate avail
)
5838 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5839 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5841 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5842 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5844 body
.emit(ret(retval
));
5848 ir_function_signature
*
5849 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5850 builtin_available_predicate avail
)
5852 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5853 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5854 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5856 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5858 /* Instead of generating an __intrinsic_atomic_sub, generate an
5859 * __intrinsic_atomic_add with the data parameter negated.
5861 if (strcmp("__intrinsic_atomic_sub", intrinsic
) == 0) {
5862 ir_variable
*const neg_data
=
5863 body
.make_temp(glsl_type::uint_type
, "neg_data");
5865 body
.emit(assign(neg_data
, neg(data
)));
5867 exec_list parameters
;
5869 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(counter
));
5870 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(neg_data
));
5872 ir_function
*const func
=
5873 shader
->symbols
->get_function("__intrinsic_atomic_add");
5874 ir_instruction
*const c
= call(func
, retval
, parameters
);
5877 assert(parameters
.is_empty());
5881 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5885 body
.emit(ret(retval
));
5889 ir_function_signature
*
5890 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
5891 builtin_available_predicate avail
)
5893 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5894 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5895 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5896 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5898 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5899 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5901 body
.emit(ret(retval
));
5905 ir_function_signature
*
5906 builtin_builder::_atomic_op2(const char *intrinsic
,
5907 builtin_available_predicate avail
,
5908 const glsl_type
*type
)
5910 ir_variable
*atomic
= in_var(type
, "atomic_var");
5911 ir_variable
*data
= in_var(type
, "atomic_data");
5912 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5914 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5915 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5917 body
.emit(ret(retval
));
5921 ir_function_signature
*
5922 builtin_builder::_atomic_op3(const char *intrinsic
,
5923 builtin_available_predicate avail
,
5924 const glsl_type
*type
)
5926 ir_variable
*atomic
= in_var(type
, "atomic_var");
5927 ir_variable
*data1
= in_var(type
, "atomic_data1");
5928 ir_variable
*data2
= in_var(type
, "atomic_data2");
5929 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5931 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5932 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5934 body
.emit(ret(retval
));
5938 ir_function_signature
*
5939 builtin_builder::_min3(const glsl_type
*type
)
5941 ir_variable
*x
= in_var(type
, "x");
5942 ir_variable
*y
= in_var(type
, "y");
5943 ir_variable
*z
= in_var(type
, "z");
5944 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5946 ir_expression
*min3
= min2(x
, min2(y
,z
));
5947 body
.emit(ret(min3
));
5952 ir_function_signature
*
5953 builtin_builder::_max3(const glsl_type
*type
)
5955 ir_variable
*x
= in_var(type
, "x");
5956 ir_variable
*y
= in_var(type
, "y");
5957 ir_variable
*z
= in_var(type
, "z");
5958 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5960 ir_expression
*max3
= max2(x
, max2(y
,z
));
5961 body
.emit(ret(max3
));
5966 ir_function_signature
*
5967 builtin_builder::_mid3(const glsl_type
*type
)
5969 ir_variable
*x
= in_var(type
, "x");
5970 ir_variable
*y
= in_var(type
, "y");
5971 ir_variable
*z
= in_var(type
, "z");
5972 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5974 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5975 body
.emit(ret(mid3
));
5980 static builtin_available_predicate
5981 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
5983 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
5984 type
->sampled_type
== GLSL_TYPE_FLOAT
)
5985 return shader_image_atomic_exchange_float
;
5987 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
5988 IMAGE_FUNCTION_AVAIL_ATOMIC
))
5989 return shader_image_atomic
;
5992 return shader_image_load_store
;
5995 ir_function_signature
*
5996 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5997 unsigned num_arguments
,
6000 const glsl_type
*data_type
= glsl_type::get_instance(
6001 image_type
->sampled_type
,
6002 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
6004 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
6005 glsl_type::void_type
: data_type
);
6007 /* Addressing arguments that are always present. */
6008 ir_variable
*image
= in_var(image_type
, "image");
6009 ir_variable
*coord
= in_var(
6010 glsl_type::ivec(image_type
->coordinate_components()), "coord");
6012 ir_function_signature
*sig
= new_sig(
6013 ret_type
, get_image_available_predicate(image_type
, flags
),
6016 /* Sample index for multisample images. */
6017 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
6018 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
6020 /* Data arguments. */
6021 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
6022 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
6023 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
6024 ralloc_free(arg_name
);
6027 /* Set the maximal set of qualifiers allowed for this image
6028 * built-in. Function calls with arguments having fewer
6029 * qualifiers than present in the prototype are allowed by the
6030 * spec, but not with more, i.e. this will make the compiler
6031 * accept everything that needs to be accepted, and reject cases
6032 * like loads from write-only or stores to read-only images.
6034 image
->data
.memory_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
6035 image
->data
.memory_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
6036 image
->data
.memory_coherent
= true;
6037 image
->data
.memory_volatile
= true;
6038 image
->data
.memory_restrict
= true;
6043 ir_function_signature
*
6044 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
6045 unsigned /* num_arguments */,
6046 unsigned /* flags */)
6048 const glsl_type
*ret_type
;
6049 unsigned num_components
= image_type
->coordinate_components();
6051 /* From the ARB_shader_image_size extension:
6052 * "Cube images return the dimensions of one face."
6054 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
6055 !image_type
->sampler_array
) {
6059 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
6060 * supported by mesa.
6062 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
6064 ir_variable
*image
= in_var(image_type
, "image");
6065 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
6067 /* Set the maximal set of qualifiers allowed for this image
6068 * built-in. Function calls with arguments having fewer
6069 * qualifiers than present in the prototype are allowed by the
6070 * spec, but not with more, i.e. this will make the compiler
6071 * accept everything that needs to be accepted, and reject cases
6072 * like loads from write-only or stores to read-only images.
6074 image
->data
.memory_read_only
= true;
6075 image
->data
.memory_write_only
= true;
6076 image
->data
.memory_coherent
= true;
6077 image
->data
.memory_volatile
= true;
6078 image
->data
.memory_restrict
= true;
6083 ir_function_signature
*
6084 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
6085 unsigned /* num_arguments */,
6086 unsigned /* flags */)
6088 ir_variable
*image
= in_var(image_type
, "image");
6089 ir_function_signature
*sig
=
6090 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
6092 /* Set the maximal set of qualifiers allowed for this image
6093 * built-in. Function calls with arguments having fewer
6094 * qualifiers than present in the prototype are allowed by the
6095 * spec, but not with more, i.e. this will make the compiler
6096 * accept everything that needs to be accepted, and reject cases
6097 * like loads from write-only or stores to read-only images.
6099 image
->data
.memory_read_only
= true;
6100 image
->data
.memory_write_only
= true;
6101 image
->data
.memory_coherent
= true;
6102 image
->data
.memory_volatile
= true;
6103 image
->data
.memory_restrict
= true;
6108 ir_function_signature
*
6109 builtin_builder::_image(image_prototype_ctr prototype
,
6110 const glsl_type
*image_type
,
6111 const char *intrinsic_name
,
6112 unsigned num_arguments
,
6114 enum ir_intrinsic_id id
)
6116 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
6117 num_arguments
, flags
);
6119 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
6120 ir_factory
body(&sig
->body
, mem_ctx
);
6121 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
6123 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
6124 body
.emit(call(f
, NULL
, sig
->parameters
));
6126 ir_variable
*ret_val
=
6127 body
.make_temp(sig
->return_type
, "_ret_val");
6128 body
.emit(call(f
, ret_val
, sig
->parameters
));
6129 body
.emit(ret(ret_val
));
6132 sig
->is_defined
= true;
6135 sig
->intrinsic_id
= id
;
6141 ir_function_signature
*
6142 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
,
6143 enum ir_intrinsic_id id
)
6145 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6149 ir_function_signature
*
6150 builtin_builder::_memory_barrier(const char *intrinsic_name
,
6151 builtin_available_predicate avail
)
6153 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6154 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6155 NULL
, sig
->parameters
));
6159 ir_function_signature
*
6160 builtin_builder::_ballot_intrinsic()
6162 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6163 MAKE_INTRINSIC(glsl_type::uint64_t_type
, ir_intrinsic_ballot
, shader_ballot
,
6168 ir_function_signature
*
6169 builtin_builder::_ballot()
6171 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6173 MAKE_SIG(glsl_type::uint64_t_type
, shader_ballot
, 1, value
);
6174 ir_variable
*retval
= body
.make_temp(glsl_type::uint64_t_type
, "retval");
6176 body
.emit(call(shader
->symbols
->get_function("__intrinsic_ballot"),
6177 retval
, sig
->parameters
));
6178 body
.emit(ret(retval
));
6182 ir_function_signature
*
6183 builtin_builder::_read_first_invocation_intrinsic(const glsl_type
*type
)
6185 ir_variable
*value
= in_var(type
, "value");
6186 MAKE_INTRINSIC(type
, ir_intrinsic_read_first_invocation
, shader_ballot
,
6191 ir_function_signature
*
6192 builtin_builder::_read_first_invocation(const glsl_type
*type
)
6194 ir_variable
*value
= in_var(type
, "value");
6196 MAKE_SIG(type
, shader_ballot
, 1, value
);
6197 ir_variable
*retval
= body
.make_temp(type
, "retval");
6199 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_first_invocation"),
6200 retval
, sig
->parameters
));
6201 body
.emit(ret(retval
));
6205 ir_function_signature
*
6206 builtin_builder::_read_invocation_intrinsic(const glsl_type
*type
)
6208 ir_variable
*value
= in_var(type
, "value");
6209 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6210 MAKE_INTRINSIC(type
, ir_intrinsic_read_invocation
, shader_ballot
,
6211 2, value
, invocation
);
6215 ir_function_signature
*
6216 builtin_builder::_read_invocation(const glsl_type
*type
)
6218 ir_variable
*value
= in_var(type
, "value");
6219 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6221 MAKE_SIG(type
, shader_ballot
, 2, value
, invocation
);
6222 ir_variable
*retval
= body
.make_temp(type
, "retval");
6224 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_invocation"),
6225 retval
, sig
->parameters
));
6226 body
.emit(ret(retval
));
6230 ir_function_signature
*
6231 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
6232 const glsl_type
*type
)
6234 MAKE_INTRINSIC(type
, ir_intrinsic_shader_clock
, avail
, 0);
6238 ir_function_signature
*
6239 builtin_builder::_shader_clock(builtin_available_predicate avail
,
6240 const glsl_type
*type
)
6242 MAKE_SIG(type
, avail
, 0);
6244 ir_variable
*retval
= body
.make_temp(glsl_type::uvec2_type
, "clock_retval");
6246 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
6247 retval
, sig
->parameters
));
6249 if (type
== glsl_type::uint64_t_type
) {
6250 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, retval
)));
6252 body
.emit(ret(retval
));
6258 ir_function_signature
*
6259 builtin_builder::_vote_intrinsic(builtin_available_predicate avail
,
6260 enum ir_intrinsic_id id
)
6262 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6263 MAKE_INTRINSIC(glsl_type::bool_type
, id
, avail
, 1, value
);
6267 ir_function_signature
*
6268 builtin_builder::_vote(const char *intrinsic_name
,
6269 builtin_available_predicate avail
)
6271 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6273 MAKE_SIG(glsl_type::bool_type
, avail
, 1, value
);
6275 ir_variable
*retval
= body
.make_temp(glsl_type::bool_type
, "retval");
6277 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6278 retval
, sig
->parameters
));
6279 body
.emit(ret(retval
));
6285 /******************************************************************************/
6287 /* The singleton instance of builtin_builder. */
6288 static builtin_builder builtins
;
6289 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
6292 * External API (exposing the built-in module to the rest of the compiler):
6296 _mesa_glsl_initialize_builtin_functions()
6298 mtx_lock(&builtins_lock
);
6299 builtins
.initialize();
6300 mtx_unlock(&builtins_lock
);
6304 _mesa_glsl_release_builtin_functions()
6306 mtx_lock(&builtins_lock
);
6308 mtx_unlock(&builtins_lock
);
6311 ir_function_signature
*
6312 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
6313 const char *name
, exec_list
*actual_parameters
)
6315 ir_function_signature
*s
;
6316 mtx_lock(&builtins_lock
);
6317 s
= builtins
.find(state
, name
, actual_parameters
);
6318 mtx_unlock(&builtins_lock
);
6324 _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state
*state
, const char *name
)
6328 mtx_lock(&builtins_lock
);
6329 f
= builtins
.shader
->symbols
->get_function(name
);
6331 foreach_in_list(ir_function_signature
, sig
, &f
->signatures
) {
6332 if (sig
->is_builtin_available(state
)) {
6338 mtx_unlock(&builtins_lock
);
6344 _mesa_glsl_get_builtin_function_shader()
6346 return builtins
.shader
;
6351 * Get the function signature for main from a shader
6353 ir_function_signature
*
6354 _mesa_get_main_function_signature(glsl_symbol_table
*symbols
)
6356 ir_function
*const f
= symbols
->get_function("main");
6358 exec_list void_parameters
;
6360 /* Look for the 'void main()' signature and ensure that it's defined.
6361 * This keeps the linker from accidentally pick a shader that just
6362 * contains a prototype for main.
6364 * We don't have to check for multiple definitions of main (in multiple
6365 * shaders) because that would have already been caught above.
6367 ir_function_signature
*sig
=
6368 f
->matching_signature(NULL
, &void_parameters
, false);
6369 if ((sig
!= NULL
) && sig
->is_defined
) {