2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * \file builtin_functions.cpp
27 * Support for GLSL built-in functions.
29 * This file is split into several main components:
31 * 1. Availability predicates
33 * A series of small functions that check whether the current shader
34 * supports the version/extensions required to expose a built-in.
36 * 2. Core builtin_builder class functionality
38 * 3. Lists of built-in functions
40 * The builtin_builder::create_builtins() function contains lists of all
41 * built-in function signatures, where they're available, what types they
44 * 4. Implementations of built-in function signatures
46 * A series of functions which create ir_function_signatures and emit IR
47 * via ir_builder to implement them.
51 * A few functions the rest of the compiler can use to interact with the
52 * built-in function module. For example, searching for a built-in by
53 * name and parameters.
58 * Unfortunately, some versions of MinGW produce bad code if this file
59 * is compiled with -O2 or -O3. The resulting driver will crash in random
60 * places if the app uses GLSL.
61 * The work-around is to disable optimizations for just this file. Luckily,
62 * this code is basically just executed once.
64 * MinGW 4.6.3 (in Ubuntu 13.10) does not have this bug.
65 * MinGW 5.3.1 (in Ubuntu 16.04) definitely has this bug.
66 * MinGW 6.2.0 (in Ubuntu 16.10) definitely has this bug.
67 * MinGW x.y.z - don't know. Assume versions after 4.6.x are buggy
70 #if defined(__MINGW32__) && ((__GNUC__ * 100) + __GNUC_MINOR >= 407)
71 #warning "disabling optimizations for this file to work around compiler bug"
72 #pragma GCC optimize("O1")
78 #include "main/mtypes.h"
79 #include "main/shaderobj.h"
80 #include "ir_builder.h"
81 #include "glsl_parser_extras.h"
82 #include "program/prog_instruction.h"
84 #include "builtin_functions.h"
85 #include "util/hash_table.h"
87 #define M_PIf ((float) M_PI)
88 #define M_PI_2f ((float) M_PI_2)
89 #define M_PI_4f ((float) M_PI_4)
91 using namespace ir_builder
;
94 * Availability predicates:
98 always_available(const _mesa_glsl_parse_state
*)
104 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
106 return state
->stage
== MESA_SHADER_VERTEX
&&
107 (state
->compat_shader
|| state
->ARB_compatibility_enable
) &&
112 fs_only(const _mesa_glsl_parse_state
*state
)
114 return state
->stage
== MESA_SHADER_FRAGMENT
;
118 gs_only(const _mesa_glsl_parse_state
*state
)
120 return state
->stage
== MESA_SHADER_GEOMETRY
;
124 v110(const _mesa_glsl_parse_state
*state
)
126 return !state
->es_shader
;
130 v110_fs_only(const _mesa_glsl_parse_state
*state
)
132 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
136 v120(const _mesa_glsl_parse_state
*state
)
138 return state
->is_version(120, 300);
142 v130(const _mesa_glsl_parse_state
*state
)
144 return state
->is_version(130, 300);
148 v130_desktop(const _mesa_glsl_parse_state
*state
)
150 return state
->is_version(130, 0);
154 v460_desktop(const _mesa_glsl_parse_state
*state
)
156 return state
->is_version(460, 0);
160 v130_fs_only(const _mesa_glsl_parse_state
*state
)
162 return state
->is_version(130, 300) &&
163 state
->stage
== MESA_SHADER_FRAGMENT
;
167 v140_or_es3(const _mesa_glsl_parse_state
*state
)
169 return state
->is_version(140, 300);
173 v400_fs_only(const _mesa_glsl_parse_state
*state
)
175 return state
->is_version(400, 0) &&
176 state
->stage
== MESA_SHADER_FRAGMENT
;
180 texture_rectangle(const _mesa_glsl_parse_state
*state
)
182 return state
->ARB_texture_rectangle_enable
;
186 texture_external(const _mesa_glsl_parse_state
*state
)
188 return state
->OES_EGL_image_external_enable
;
192 texture_external_es3(const _mesa_glsl_parse_state
*state
)
194 return state
->OES_EGL_image_external_essl3_enable
&&
196 state
->is_version(0, 300);
199 /** True if texturing functions with explicit LOD are allowed. */
201 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
203 /* Texturing functions with "Lod" in their name exist:
204 * - In the vertex shader stage (for all languages)
205 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
206 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
208 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
209 * don't need to explicitly check state->es_shader.
211 return state
->stage
== MESA_SHADER_VERTEX
||
212 state
->is_version(130, 300) ||
213 state
->ARB_shader_texture_lod_enable
;
217 v110_lod(const _mesa_glsl_parse_state
*state
)
219 return !state
->es_shader
&& lod_exists_in_stage(state
);
223 texture_buffer(const _mesa_glsl_parse_state
*state
)
225 return state
->is_version(140, 320) ||
226 state
->EXT_texture_buffer_enable
||
227 state
->OES_texture_buffer_enable
;
231 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
233 return state
->ARB_shader_texture_lod_enable
;
237 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
239 return state
->ARB_shader_texture_lod_enable
&&
240 state
->ARB_texture_rectangle_enable
;
244 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
246 return state
->is_version(330, 300) ||
247 state
->ARB_shader_bit_encoding_enable
||
248 state
->ARB_gpu_shader5_enable
;
252 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
254 return state
->is_version(450, 310) ||
255 state
->ARB_ES3_1_compatibility_enable
||
256 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
260 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
262 return state
->ARB_shading_language_packing_enable
||
263 state
->is_version(420, 300);
267 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
269 return state
->ARB_shading_language_packing_enable
||
270 state
->ARB_gpu_shader5_enable
||
271 state
->is_version(400, 300);
275 gpu_shader5(const _mesa_glsl_parse_state
*state
)
277 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
281 gpu_shader5_es(const _mesa_glsl_parse_state
*state
)
283 return state
->is_version(400, 320) ||
284 state
->ARB_gpu_shader5_enable
||
285 state
->EXT_gpu_shader5_enable
||
286 state
->OES_gpu_shader5_enable
;
290 gpu_shader5_or_OES_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
292 return state
->is_version(400, 320) ||
293 state
->ARB_gpu_shader5_enable
||
294 state
->EXT_texture_cube_map_array_enable
||
295 state
->OES_texture_cube_map_array_enable
;
299 es31_not_gs5(const _mesa_glsl_parse_state
*state
)
301 return state
->is_version(0, 310) && !gpu_shader5_es(state
);
305 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
307 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
311 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
313 return state
->ARB_shading_language_packing_enable
||
314 state
->ARB_gpu_shader5_enable
||
315 state
->is_version(400, 310);
319 gpu_shader5_or_es31_or_integer_functions(const _mesa_glsl_parse_state
*state
)
321 return gpu_shader5_or_es31(state
) ||
322 state
->MESA_shader_integer_functions_enable
;
326 fs_interpolate_at(const _mesa_glsl_parse_state
*state
)
328 return state
->stage
== MESA_SHADER_FRAGMENT
&&
329 (state
->is_version(400, 320) ||
330 state
->ARB_gpu_shader5_enable
||
331 state
->OES_shader_multisample_interpolation_enable
);
336 texture_array_lod(const _mesa_glsl_parse_state
*state
)
338 return lod_exists_in_stage(state
) &&
339 state
->EXT_texture_array_enable
;
343 fs_texture_array(const _mesa_glsl_parse_state
*state
)
345 return state
->stage
== MESA_SHADER_FRAGMENT
&&
346 state
->EXT_texture_array_enable
;
350 texture_array(const _mesa_glsl_parse_state
*state
)
352 return state
->EXT_texture_array_enable
;
356 texture_multisample(const _mesa_glsl_parse_state
*state
)
358 return state
->is_version(150, 310) ||
359 state
->ARB_texture_multisample_enable
;
363 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
365 return state
->is_version(150, 320) ||
366 state
->ARB_texture_multisample_enable
||
367 state
->OES_texture_storage_multisample_2d_array_enable
;
371 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
373 return texture_multisample(state
) &&
374 state
->EXT_shader_samples_identical_enable
;
378 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
380 return texture_multisample_array(state
) &&
381 state
->EXT_shader_samples_identical_enable
;
385 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
387 return state
->stage
== MESA_SHADER_FRAGMENT
&&
388 state
->has_texture_cube_map_array();
392 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
394 return state
->has_texture_cube_map_array();
398 texture_query_levels(const _mesa_glsl_parse_state
*state
)
400 return state
->is_version(430, 0) ||
401 state
->ARB_texture_query_levels_enable
;
405 texture_query_lod(const _mesa_glsl_parse_state
*state
)
407 return state
->stage
== MESA_SHADER_FRAGMENT
&&
408 state
->ARB_texture_query_lod_enable
;
412 texture_gather_cube_map_array(const _mesa_glsl_parse_state
*state
)
414 return state
->is_version(400, 320) ||
415 state
->ARB_texture_gather_enable
||
416 state
->ARB_gpu_shader5_enable
||
417 state
->EXT_texture_cube_map_array_enable
||
418 state
->OES_texture_cube_map_array_enable
;
422 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
424 return state
->is_version(400, 310) ||
425 state
->ARB_texture_gather_enable
||
426 state
->ARB_gpu_shader5_enable
;
429 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
430 * used for relaxation of const offset requirements.
433 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
435 return !state
->is_version(400, 320) &&
436 !state
->ARB_gpu_shader5_enable
&&
437 !state
->EXT_gpu_shader5_enable
&&
438 !state
->OES_gpu_shader5_enable
&&
439 (state
->ARB_texture_gather_enable
||
440 state
->is_version(0, 310));
443 /* Desktop GL or OES_standard_derivatives + fragment shader only */
445 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
447 return state
->stage
== MESA_SHADER_FRAGMENT
&&
448 (state
->is_version(110, 300) ||
449 state
->OES_standard_derivatives_enable
||
450 state
->ctx
->Const
.AllowGLSLRelaxedES
);
454 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
456 return state
->stage
== MESA_SHADER_FRAGMENT
&&
457 (state
->is_version(450, 0) ||
458 state
->ARB_derivative_control_enable
);
462 tex1d_lod(const _mesa_glsl_parse_state
*state
)
464 return !state
->es_shader
&& lod_exists_in_stage(state
);
467 /** True if sampler3D exists */
469 tex3d(const _mesa_glsl_parse_state
*state
)
471 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
472 * OES_texture_3D extension, and in GLSL ES 3.00.
474 return !state
->es_shader
||
475 state
->OES_texture_3D_enable
||
476 state
->language_version
>= 300;
480 fs_tex3d(const _mesa_glsl_parse_state
*state
)
482 return state
->stage
== MESA_SHADER_FRAGMENT
&&
483 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
487 tex3d_lod(const _mesa_glsl_parse_state
*state
)
489 return tex3d(state
) && lod_exists_in_stage(state
);
493 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
495 return state
->has_atomic_counters();
499 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
501 return state
->ARB_shader_atomic_counter_ops_enable
;
505 shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
507 return state
->ARB_shader_atomic_counter_ops_enable
|| v460_desktop(state
);
511 shader_ballot(const _mesa_glsl_parse_state
*state
)
513 return state
->ARB_shader_ballot_enable
;
517 supports_arb_fragment_shader_interlock(const _mesa_glsl_parse_state
*state
)
519 return state
->ARB_fragment_shader_interlock_enable
;
523 shader_clock(const _mesa_glsl_parse_state
*state
)
525 return state
->ARB_shader_clock_enable
;
529 shader_clock_int64(const _mesa_glsl_parse_state
*state
)
531 return state
->ARB_shader_clock_enable
&&
532 state
->ARB_gpu_shader_int64_enable
;
536 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
538 return state
->has_shader_storage_buffer_objects();
542 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
544 return state
->AMD_shader_trinary_minmax_enable
;
548 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
550 return (state
->is_version(420, 310) ||
551 state
->ARB_shader_image_load_store_enable
);
555 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
557 return (state
->is_version(420, 320) ||
558 state
->ARB_shader_image_load_store_enable
||
559 state
->OES_shader_image_atomic_enable
);
563 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
565 return (state
->is_version(450, 320) ||
566 state
->ARB_ES3_1_compatibility_enable
||
567 state
->OES_shader_image_atomic_enable
);
571 shader_image_size(const _mesa_glsl_parse_state
*state
)
573 return state
->is_version(430, 310) ||
574 state
->ARB_shader_image_size_enable
;
578 shader_samples(const _mesa_glsl_parse_state
*state
)
580 return state
->is_version(450, 0) ||
581 state
->ARB_shader_texture_image_samples_enable
;
585 gs_streams(const _mesa_glsl_parse_state
*state
)
587 return gpu_shader5(state
) && gs_only(state
);
591 fp64(const _mesa_glsl_parse_state
*state
)
593 return state
->has_double();
597 int64(const _mesa_glsl_parse_state
*state
)
599 return state
->has_int64();
603 int64_fp64(const _mesa_glsl_parse_state
*state
)
605 return state
->has_int64() && state
->has_double();
609 compute_shader(const _mesa_glsl_parse_state
*state
)
611 return state
->stage
== MESA_SHADER_COMPUTE
;
615 compute_shader_supported(const _mesa_glsl_parse_state
*state
)
617 return state
->has_compute_shader();
621 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
623 return compute_shader(state
) || shader_storage_buffer_object(state
);
627 barrier_supported(const _mesa_glsl_parse_state
*state
)
629 return compute_shader(state
) ||
630 state
->stage
== MESA_SHADER_TESS_CTRL
;
634 vote(const _mesa_glsl_parse_state
*state
)
636 return state
->ARB_shader_group_vote_enable
;
640 vote_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
642 return state
->ARB_shader_group_vote_enable
|| v460_desktop(state
);
646 integer_functions_supported(const _mesa_glsl_parse_state
*state
)
648 return state
->extensions
->MESA_shader_integer_functions
;
652 /******************************************************************************/
657 * builtin_builder: A singleton object representing the core of the built-in
660 * It generates IR for every built-in function signature, and organizes them
663 class builtin_builder
{
670 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
671 const char *name
, exec_list
*actual_parameters
);
674 * A shader to hold all the built-in signatures; created by this module.
676 * This includes signatures for every built-in, regardless of version or
677 * enabled extensions. The availability predicate associated with each
678 * signature allows matching_signature() to filter out the irrelevant ones.
685 void create_shader();
686 void create_intrinsics();
687 void create_builtins();
690 * IR builder helpers:
692 * These convenience functions assist in emitting IR, but don't necessarily
693 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
696 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
697 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
698 ir_constant
*imm(float f
, unsigned vector_elements
=1);
699 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
700 ir_constant
*imm(int i
, unsigned vector_elements
=1);
701 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
702 ir_constant
*imm(double d
, unsigned vector_elements
=1);
703 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
704 ir_dereference_variable
*var_ref(ir_variable
*var
);
705 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
706 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
708 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
709 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
712 * Call function \param f with parameters specified as the linked
713 * list \param params of \c ir_variable objects. \param ret should
714 * point to the ir_variable that will hold the function return
715 * value, or be \c NULL if the function has void return type.
717 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
719 /** Create a new function and add the given signatures. */
720 void add_function(const char *name
, ...);
722 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
723 unsigned num_arguments
,
727 * Create a new image built-in function for all known image types.
728 * \p flags is a bitfield of \c image_function_flags flags.
730 void add_image_function(const char *name
,
731 const char *intrinsic_name
,
732 image_prototype_ctr prototype
,
733 unsigned num_arguments
,
735 enum ir_intrinsic_id id
);
738 * Create new functions for all known image built-ins and types.
739 * If \p glsl is \c true, use the GLSL built-in names and emit code
740 * to call into the actual compiler intrinsic. If \p glsl is
741 * false, emit a function prototype with no body for each image
744 void add_image_functions(bool glsl
);
746 ir_function_signature
*new_sig(const glsl_type
*return_type
,
747 builtin_available_predicate avail
,
748 int num_params
, ...);
751 * Function signature generators:
754 ir_function_signature
*unop(builtin_available_predicate avail
,
755 ir_expression_operation opcode
,
756 const glsl_type
*return_type
,
757 const glsl_type
*param_type
);
758 ir_function_signature
*binop(builtin_available_predicate avail
,
759 ir_expression_operation opcode
,
760 const glsl_type
*return_type
,
761 const glsl_type
*param0_type
,
762 const glsl_type
*param1_type
,
763 bool swap_operands
= false);
765 #define B0(X) ir_function_signature *_##X();
766 #define B1(X) ir_function_signature *_##X(const glsl_type *);
767 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
768 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
769 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
770 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
807 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
808 const glsl_type
*val_type
,
809 const glsl_type
*blend_type
);
819 BA1(doubleBitsToInt64
)
820 BA1(doubleBitsToUint64
)
821 BA1(int64BitsToDouble
)
822 BA1(uint64BitsToDouble
)
824 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
825 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
826 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
827 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
828 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
829 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
830 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
831 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
832 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
833 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
834 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
835 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
836 ir_function_signature
*_packInt2x32(builtin_available_predicate avail
);
837 ir_function_signature
*_unpackInt2x32(builtin_available_predicate avail
);
838 ir_function_signature
*_packUint2x32(builtin_available_predicate avail
);
839 ir_function_signature
*_unpackUint2x32(builtin_available_predicate avail
);
852 BA1(determinant_mat2
);
853 BA1(determinant_mat3
);
854 BA1(determinant_mat4
);
862 BA1(greaterThanEqual
);
871 /** Flags to _texture() */
872 #define TEX_PROJECT 1
874 #define TEX_COMPONENT 4
875 #define TEX_OFFSET_NONCONST 8
876 #define TEX_OFFSET_ARRAY 16
878 ir_function_signature
*_texture(ir_texture_opcode opcode
,
879 builtin_available_predicate avail
,
880 const glsl_type
*return_type
,
881 const glsl_type
*sampler_type
,
882 const glsl_type
*coord_type
,
884 BA1(textureCubeArrayShadow
);
885 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
886 const glsl_type
*return_type
,
887 const glsl_type
*sampler_type
,
888 const glsl_type
*coord_type
,
889 const glsl_type
*offset_type
= NULL
);
893 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
894 const glsl_type
*stream_type
);
895 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
896 const glsl_type
*stream_type
);
899 BA2(textureQueryLod
);
900 BA1(textureQueryLevels
);
901 BA2(textureSamplesIdentical
);
929 B1(interpolateAtCentroid
)
930 B1(interpolateAtOffset
)
931 B1(interpolateAtSample
)
933 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
,
934 enum ir_intrinsic_id id
);
935 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
,
936 enum ir_intrinsic_id id
);
937 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
,
938 enum ir_intrinsic_id id
);
939 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
940 builtin_available_predicate avail
);
941 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
942 builtin_available_predicate avail
);
943 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
944 builtin_available_predicate avail
);
946 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
947 const glsl_type
*type
,
948 enum ir_intrinsic_id id
);
949 ir_function_signature
*_atomic_op2(const char *intrinsic
,
950 builtin_available_predicate avail
,
951 const glsl_type
*type
);
952 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
953 const glsl_type
*type
,
954 enum ir_intrinsic_id id
);
955 ir_function_signature
*_atomic_op3(const char *intrinsic
,
956 builtin_available_predicate avail
,
957 const glsl_type
*type
);
963 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
964 unsigned num_arguments
,
966 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
967 unsigned num_arguments
,
969 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
970 unsigned num_arguments
,
972 ir_function_signature
*_image(image_prototype_ctr prototype
,
973 const glsl_type
*image_type
,
974 const char *intrinsic_name
,
975 unsigned num_arguments
,
977 enum ir_intrinsic_id id
);
979 ir_function_signature
*_memory_barrier_intrinsic(
980 builtin_available_predicate avail
,
981 enum ir_intrinsic_id id
);
982 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
983 builtin_available_predicate avail
);
985 ir_function_signature
*_ballot_intrinsic();
986 ir_function_signature
*_ballot();
987 ir_function_signature
*_read_first_invocation_intrinsic(const glsl_type
*type
);
988 ir_function_signature
*_read_first_invocation(const glsl_type
*type
);
989 ir_function_signature
*_read_invocation_intrinsic(const glsl_type
*type
);
990 ir_function_signature
*_read_invocation(const glsl_type
*type
);
993 ir_function_signature
*_invocation_interlock_intrinsic(
994 builtin_available_predicate avail
,
995 enum ir_intrinsic_id id
);
996 ir_function_signature
*_invocation_interlock(
997 const char *intrinsic_name
,
998 builtin_available_predicate avail
);
1000 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
1001 const glsl_type
*type
);
1002 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
1003 const glsl_type
*type
);
1005 ir_function_signature
*_vote_intrinsic(builtin_available_predicate avail
,
1006 enum ir_intrinsic_id id
);
1007 ir_function_signature
*_vote(const char *intrinsic_name
,
1008 builtin_available_predicate avail
);
1019 enum image_function_flags
{
1020 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
1021 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
1022 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
1023 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
1024 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
1025 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
1026 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
1027 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
1028 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8)
1031 } /* anonymous namespace */
1034 * Core builtin_builder functionality:
1037 builtin_builder::builtin_builder()
1043 builtin_builder::~builtin_builder()
1045 ralloc_free(mem_ctx
);
1048 ir_function_signature
*
1049 builtin_builder::find(_mesa_glsl_parse_state
*state
,
1050 const char *name
, exec_list
*actual_parameters
)
1052 /* The shader currently being compiled requested a built-in function;
1053 * it needs to link against builtin_builder::shader in order to get them.
1055 * Even if we don't find a matching signature, we still need to do this so
1056 * that the "no matching signature" error will list potential candidates
1057 * from the available built-ins.
1059 state
->uses_builtin_functions
= true;
1061 ir_function
*f
= shader
->symbols
->get_function(name
);
1065 ir_function_signature
*sig
=
1066 f
->matching_signature(state
, actual_parameters
, true);
1074 builtin_builder::initialize()
1076 /* If already initialized, don't do it again. */
1077 if (mem_ctx
!= NULL
)
1080 mem_ctx
= ralloc_context(NULL
);
1082 create_intrinsics();
1087 builtin_builder::release()
1089 ralloc_free(mem_ctx
);
1092 ralloc_free(shader
);
1097 builtin_builder::create_shader()
1099 /* The target doesn't actually matter. There's no target for generic
1100 * GLSL utility code that could be linked against any stage, so just
1101 * arbitrarily pick GL_VERTEX_SHADER.
1103 shader
= _mesa_new_shader(0, MESA_SHADER_VERTEX
);
1104 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
1110 * Create ir_function and ir_function_signature objects for each
1114 builtin_builder::create_intrinsics()
1116 add_function("__intrinsic_atomic_read",
1117 _atomic_counter_intrinsic(shader_atomic_counters
,
1118 ir_intrinsic_atomic_counter_read
),
1120 add_function("__intrinsic_atomic_increment",
1121 _atomic_counter_intrinsic(shader_atomic_counters
,
1122 ir_intrinsic_atomic_counter_increment
),
1124 add_function("__intrinsic_atomic_predecrement",
1125 _atomic_counter_intrinsic(shader_atomic_counters
,
1126 ir_intrinsic_atomic_counter_predecrement
),
1129 add_function("__intrinsic_atomic_add",
1130 _atomic_intrinsic2(buffer_atomics_supported
,
1131 glsl_type::uint_type
,
1132 ir_intrinsic_generic_atomic_add
),
1133 _atomic_intrinsic2(buffer_atomics_supported
,
1134 glsl_type::int_type
,
1135 ir_intrinsic_generic_atomic_add
),
1136 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1137 ir_intrinsic_atomic_counter_add
),
1139 add_function("__intrinsic_atomic_min",
1140 _atomic_intrinsic2(buffer_atomics_supported
,
1141 glsl_type::uint_type
,
1142 ir_intrinsic_generic_atomic_min
),
1143 _atomic_intrinsic2(buffer_atomics_supported
,
1144 glsl_type::int_type
,
1145 ir_intrinsic_generic_atomic_min
),
1146 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1147 ir_intrinsic_atomic_counter_min
),
1149 add_function("__intrinsic_atomic_max",
1150 _atomic_intrinsic2(buffer_atomics_supported
,
1151 glsl_type::uint_type
,
1152 ir_intrinsic_generic_atomic_max
),
1153 _atomic_intrinsic2(buffer_atomics_supported
,
1154 glsl_type::int_type
,
1155 ir_intrinsic_generic_atomic_max
),
1156 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1157 ir_intrinsic_atomic_counter_max
),
1159 add_function("__intrinsic_atomic_and",
1160 _atomic_intrinsic2(buffer_atomics_supported
,
1161 glsl_type::uint_type
,
1162 ir_intrinsic_generic_atomic_and
),
1163 _atomic_intrinsic2(buffer_atomics_supported
,
1164 glsl_type::int_type
,
1165 ir_intrinsic_generic_atomic_and
),
1166 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1167 ir_intrinsic_atomic_counter_and
),
1169 add_function("__intrinsic_atomic_or",
1170 _atomic_intrinsic2(buffer_atomics_supported
,
1171 glsl_type::uint_type
,
1172 ir_intrinsic_generic_atomic_or
),
1173 _atomic_intrinsic2(buffer_atomics_supported
,
1174 glsl_type::int_type
,
1175 ir_intrinsic_generic_atomic_or
),
1176 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1177 ir_intrinsic_atomic_counter_or
),
1179 add_function("__intrinsic_atomic_xor",
1180 _atomic_intrinsic2(buffer_atomics_supported
,
1181 glsl_type::uint_type
,
1182 ir_intrinsic_generic_atomic_xor
),
1183 _atomic_intrinsic2(buffer_atomics_supported
,
1184 glsl_type::int_type
,
1185 ir_intrinsic_generic_atomic_xor
),
1186 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1187 ir_intrinsic_atomic_counter_xor
),
1189 add_function("__intrinsic_atomic_exchange",
1190 _atomic_intrinsic2(buffer_atomics_supported
,
1191 glsl_type::uint_type
,
1192 ir_intrinsic_generic_atomic_exchange
),
1193 _atomic_intrinsic2(buffer_atomics_supported
,
1194 glsl_type::int_type
,
1195 ir_intrinsic_generic_atomic_exchange
),
1196 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1197 ir_intrinsic_atomic_counter_exchange
),
1199 add_function("__intrinsic_atomic_comp_swap",
1200 _atomic_intrinsic3(buffer_atomics_supported
,
1201 glsl_type::uint_type
,
1202 ir_intrinsic_generic_atomic_comp_swap
),
1203 _atomic_intrinsic3(buffer_atomics_supported
,
1204 glsl_type::int_type
,
1205 ir_intrinsic_generic_atomic_comp_swap
),
1206 _atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop
,
1207 ir_intrinsic_atomic_counter_comp_swap
),
1210 add_image_functions(false);
1212 add_function("__intrinsic_memory_barrier",
1213 _memory_barrier_intrinsic(shader_image_load_store
,
1214 ir_intrinsic_memory_barrier
),
1216 add_function("__intrinsic_group_memory_barrier",
1217 _memory_barrier_intrinsic(compute_shader
,
1218 ir_intrinsic_group_memory_barrier
),
1220 add_function("__intrinsic_memory_barrier_atomic_counter",
1221 _memory_barrier_intrinsic(compute_shader_supported
,
1222 ir_intrinsic_memory_barrier_atomic_counter
),
1224 add_function("__intrinsic_memory_barrier_buffer",
1225 _memory_barrier_intrinsic(compute_shader_supported
,
1226 ir_intrinsic_memory_barrier_buffer
),
1228 add_function("__intrinsic_memory_barrier_image",
1229 _memory_barrier_intrinsic(compute_shader_supported
,
1230 ir_intrinsic_memory_barrier_image
),
1232 add_function("__intrinsic_memory_barrier_shared",
1233 _memory_barrier_intrinsic(compute_shader
,
1234 ir_intrinsic_memory_barrier_shared
),
1237 add_function("__intrinsic_begin_invocation_interlock",
1238 _invocation_interlock_intrinsic(
1239 supports_arb_fragment_shader_interlock
,
1240 ir_intrinsic_begin_invocation_interlock
), NULL
);
1242 add_function("__intrinsic_end_invocation_interlock",
1243 _invocation_interlock_intrinsic(
1244 supports_arb_fragment_shader_interlock
,
1245 ir_intrinsic_end_invocation_interlock
), NULL
);
1247 add_function("__intrinsic_shader_clock",
1248 _shader_clock_intrinsic(shader_clock
,
1249 glsl_type::uvec2_type
),
1252 add_function("__intrinsic_vote_all",
1253 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_all
),
1255 add_function("__intrinsic_vote_any",
1256 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_any
),
1258 add_function("__intrinsic_vote_eq",
1259 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_eq
),
1262 add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL
);
1264 add_function("__intrinsic_read_invocation",
1265 _read_invocation_intrinsic(glsl_type::float_type
),
1266 _read_invocation_intrinsic(glsl_type::vec2_type
),
1267 _read_invocation_intrinsic(glsl_type::vec3_type
),
1268 _read_invocation_intrinsic(glsl_type::vec4_type
),
1270 _read_invocation_intrinsic(glsl_type::int_type
),
1271 _read_invocation_intrinsic(glsl_type::ivec2_type
),
1272 _read_invocation_intrinsic(glsl_type::ivec3_type
),
1273 _read_invocation_intrinsic(glsl_type::ivec4_type
),
1275 _read_invocation_intrinsic(glsl_type::uint_type
),
1276 _read_invocation_intrinsic(glsl_type::uvec2_type
),
1277 _read_invocation_intrinsic(glsl_type::uvec3_type
),
1278 _read_invocation_intrinsic(glsl_type::uvec4_type
),
1281 add_function("__intrinsic_read_first_invocation",
1282 _read_first_invocation_intrinsic(glsl_type::float_type
),
1283 _read_first_invocation_intrinsic(glsl_type::vec2_type
),
1284 _read_first_invocation_intrinsic(glsl_type::vec3_type
),
1285 _read_first_invocation_intrinsic(glsl_type::vec4_type
),
1287 _read_first_invocation_intrinsic(glsl_type::int_type
),
1288 _read_first_invocation_intrinsic(glsl_type::ivec2_type
),
1289 _read_first_invocation_intrinsic(glsl_type::ivec3_type
),
1290 _read_first_invocation_intrinsic(glsl_type::ivec4_type
),
1292 _read_first_invocation_intrinsic(glsl_type::uint_type
),
1293 _read_first_invocation_intrinsic(glsl_type::uvec2_type
),
1294 _read_first_invocation_intrinsic(glsl_type::uvec3_type
),
1295 _read_first_invocation_intrinsic(glsl_type::uvec4_type
),
1301 * Create ir_function and ir_function_signature objects for each built-in.
1303 * Contains a list of every available built-in.
1306 builtin_builder::create_builtins()
1309 add_function(#NAME, \
1310 _##NAME(glsl_type::float_type), \
1311 _##NAME(glsl_type::vec2_type), \
1312 _##NAME(glsl_type::vec3_type), \
1313 _##NAME(glsl_type::vec4_type), \
1317 add_function(#NAME, \
1318 _##NAME(always_available, glsl_type::float_type), \
1319 _##NAME(always_available, glsl_type::vec2_type), \
1320 _##NAME(always_available, glsl_type::vec3_type), \
1321 _##NAME(always_available, glsl_type::vec4_type), \
1322 _##NAME(fp64, glsl_type::double_type), \
1323 _##NAME(fp64, glsl_type::dvec2_type), \
1324 _##NAME(fp64, glsl_type::dvec3_type), \
1325 _##NAME(fp64, glsl_type::dvec4_type), \
1328 #define FD130(NAME) \
1329 add_function(#NAME, \
1330 _##NAME(v130, glsl_type::float_type), \
1331 _##NAME(v130, glsl_type::vec2_type), \
1332 _##NAME(v130, glsl_type::vec3_type), \
1333 _##NAME(v130, glsl_type::vec4_type), \
1334 _##NAME(fp64, glsl_type::double_type), \
1335 _##NAME(fp64, glsl_type::dvec2_type), \
1336 _##NAME(fp64, glsl_type::dvec3_type), \
1337 _##NAME(fp64, glsl_type::dvec4_type), \
1340 #define FDGS5(NAME) \
1341 add_function(#NAME, \
1342 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1343 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1344 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1345 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1346 _##NAME(fp64, glsl_type::double_type), \
1347 _##NAME(fp64, glsl_type::dvec2_type), \
1348 _##NAME(fp64, glsl_type::dvec3_type), \
1349 _##NAME(fp64, glsl_type::dvec4_type), \
1353 add_function(#NAME, \
1354 _##NAME(glsl_type::float_type), \
1355 _##NAME(glsl_type::vec2_type), \
1356 _##NAME(glsl_type::vec3_type), \
1357 _##NAME(glsl_type::vec4_type), \
1358 _##NAME(glsl_type::int_type), \
1359 _##NAME(glsl_type::ivec2_type), \
1360 _##NAME(glsl_type::ivec3_type), \
1361 _##NAME(glsl_type::ivec4_type), \
1364 #define FI64(NAME) \
1365 add_function(#NAME, \
1366 _##NAME(always_available, glsl_type::float_type), \
1367 _##NAME(always_available, glsl_type::vec2_type), \
1368 _##NAME(always_available, glsl_type::vec3_type), \
1369 _##NAME(always_available, glsl_type::vec4_type), \
1370 _##NAME(always_available, glsl_type::int_type), \
1371 _##NAME(always_available, glsl_type::ivec2_type), \
1372 _##NAME(always_available, glsl_type::ivec3_type), \
1373 _##NAME(always_available, glsl_type::ivec4_type), \
1374 _##NAME(fp64, glsl_type::double_type), \
1375 _##NAME(fp64, glsl_type::dvec2_type), \
1376 _##NAME(fp64, glsl_type::dvec3_type), \
1377 _##NAME(fp64, glsl_type::dvec4_type), \
1378 _##NAME(int64, glsl_type::int64_t_type), \
1379 _##NAME(int64, glsl_type::i64vec2_type), \
1380 _##NAME(int64, glsl_type::i64vec3_type), \
1381 _##NAME(int64, glsl_type::i64vec4_type), \
1384 #define FIUD_VEC(NAME) \
1385 add_function(#NAME, \
1386 _##NAME(always_available, glsl_type::vec2_type), \
1387 _##NAME(always_available, glsl_type::vec3_type), \
1388 _##NAME(always_available, glsl_type::vec4_type), \
1390 _##NAME(always_available, glsl_type::ivec2_type), \
1391 _##NAME(always_available, glsl_type::ivec3_type), \
1392 _##NAME(always_available, glsl_type::ivec4_type), \
1394 _##NAME(v130, glsl_type::uvec2_type), \
1395 _##NAME(v130, glsl_type::uvec3_type), \
1396 _##NAME(v130, glsl_type::uvec4_type), \
1397 _##NAME(fp64, glsl_type::dvec2_type), \
1398 _##NAME(fp64, glsl_type::dvec3_type), \
1399 _##NAME(fp64, glsl_type::dvec4_type), \
1400 _##NAME(int64, glsl_type::int64_t_type), \
1401 _##NAME(int64, glsl_type::i64vec2_type), \
1402 _##NAME(int64, glsl_type::i64vec3_type), \
1403 _##NAME(int64, glsl_type::i64vec4_type), \
1404 _##NAME(int64, glsl_type::uint64_t_type), \
1405 _##NAME(int64, glsl_type::u64vec2_type), \
1406 _##NAME(int64, glsl_type::u64vec3_type), \
1407 _##NAME(int64, glsl_type::u64vec4_type), \
1411 add_function(#NAME, \
1412 _##NAME(glsl_type::int_type), \
1413 _##NAME(glsl_type::ivec2_type), \
1414 _##NAME(glsl_type::ivec3_type), \
1415 _##NAME(glsl_type::ivec4_type), \
1417 _##NAME(glsl_type::uint_type), \
1418 _##NAME(glsl_type::uvec2_type), \
1419 _##NAME(glsl_type::uvec3_type), \
1420 _##NAME(glsl_type::uvec4_type), \
1423 #define FIUBD_VEC(NAME) \
1424 add_function(#NAME, \
1425 _##NAME(always_available, glsl_type::vec2_type), \
1426 _##NAME(always_available, glsl_type::vec3_type), \
1427 _##NAME(always_available, glsl_type::vec4_type), \
1429 _##NAME(always_available, glsl_type::ivec2_type), \
1430 _##NAME(always_available, glsl_type::ivec3_type), \
1431 _##NAME(always_available, glsl_type::ivec4_type), \
1433 _##NAME(v130, glsl_type::uvec2_type), \
1434 _##NAME(v130, glsl_type::uvec3_type), \
1435 _##NAME(v130, glsl_type::uvec4_type), \
1437 _##NAME(always_available, glsl_type::bvec2_type), \
1438 _##NAME(always_available, glsl_type::bvec3_type), \
1439 _##NAME(always_available, glsl_type::bvec4_type), \
1441 _##NAME(fp64, glsl_type::dvec2_type), \
1442 _##NAME(fp64, glsl_type::dvec3_type), \
1443 _##NAME(fp64, glsl_type::dvec4_type), \
1444 _##NAME(int64, glsl_type::int64_t_type), \
1445 _##NAME(int64, glsl_type::i64vec2_type), \
1446 _##NAME(int64, glsl_type::i64vec3_type), \
1447 _##NAME(int64, glsl_type::i64vec4_type), \
1448 _##NAME(int64, glsl_type::uint64_t_type), \
1449 _##NAME(int64, glsl_type::u64vec2_type), \
1450 _##NAME(int64, glsl_type::u64vec3_type), \
1451 _##NAME(int64, glsl_type::u64vec4_type), \
1454 #define FIUD2_MIXED(NAME) \
1455 add_function(#NAME, \
1456 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1457 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1458 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1459 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1461 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1462 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1463 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1465 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1466 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1467 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1468 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1470 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1471 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1472 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1474 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1475 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1476 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1477 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1479 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1480 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1481 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1483 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1484 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1485 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1486 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1487 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1488 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1489 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1491 _##NAME(int64, glsl_type::int64_t_type, glsl_type::int64_t_type), \
1492 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::int64_t_type), \
1493 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::int64_t_type), \
1494 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::int64_t_type), \
1495 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::i64vec2_type), \
1496 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::i64vec3_type), \
1497 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::i64vec4_type), \
1498 _##NAME(int64, glsl_type::uint64_t_type, glsl_type::uint64_t_type), \
1499 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::uint64_t_type), \
1500 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::uint64_t_type), \
1501 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::uint64_t_type), \
1502 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::u64vec2_type), \
1503 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::u64vec3_type), \
1504 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::u64vec4_type), \
1515 add_function("atan",
1516 _atan(glsl_type::float_type
),
1517 _atan(glsl_type::vec2_type
),
1518 _atan(glsl_type::vec3_type
),
1519 _atan(glsl_type::vec4_type
),
1520 _atan2(glsl_type::float_type
),
1521 _atan2(glsl_type::vec2_type
),
1522 _atan2(glsl_type::vec3_type
),
1523 _atan2(glsl_type::vec4_type
),
1549 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1550 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1551 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1552 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1554 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1555 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1556 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1558 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1559 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1560 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1561 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1563 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1564 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1565 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1575 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1576 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1577 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1578 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1580 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1581 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1582 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1584 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1585 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1586 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1587 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1589 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1590 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1591 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1593 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1594 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1595 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1596 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1598 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1599 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1600 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1601 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1603 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1604 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1605 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1606 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1608 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1609 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1610 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1611 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1613 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1614 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1615 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1616 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1618 _mix_sel(int64
, glsl_type::int64_t_type
, glsl_type::bool_type
),
1619 _mix_sel(int64
, glsl_type::i64vec2_type
, glsl_type::bvec2_type
),
1620 _mix_sel(int64
, glsl_type::i64vec3_type
, glsl_type::bvec3_type
),
1621 _mix_sel(int64
, glsl_type::i64vec4_type
, glsl_type::bvec4_type
),
1623 _mix_sel(int64
, glsl_type::uint64_t_type
, glsl_type::bool_type
),
1624 _mix_sel(int64
, glsl_type::u64vec2_type
, glsl_type::bvec2_type
),
1625 _mix_sel(int64
, glsl_type::u64vec3_type
, glsl_type::bvec3_type
),
1626 _mix_sel(int64
, glsl_type::u64vec4_type
, glsl_type::bvec4_type
),
1629 add_function("step",
1630 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1631 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1632 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1633 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1635 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1636 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1637 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1638 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1639 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1640 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1641 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1643 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1644 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1645 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1648 add_function("smoothstep",
1649 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1650 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1651 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1652 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1654 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1655 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1656 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1657 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1658 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1659 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1660 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1662 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1663 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1664 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1672 add_function("intBitsToFloat",
1673 _intBitsToFloat(glsl_type::int_type
),
1674 _intBitsToFloat(glsl_type::ivec2_type
),
1675 _intBitsToFloat(glsl_type::ivec3_type
),
1676 _intBitsToFloat(glsl_type::ivec4_type
),
1678 add_function("uintBitsToFloat",
1679 _uintBitsToFloat(glsl_type::uint_type
),
1680 _uintBitsToFloat(glsl_type::uvec2_type
),
1681 _uintBitsToFloat(glsl_type::uvec3_type
),
1682 _uintBitsToFloat(glsl_type::uvec4_type
),
1685 add_function("doubleBitsToInt64",
1686 _doubleBitsToInt64(int64_fp64
, glsl_type::double_type
),
1687 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec2_type
),
1688 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec3_type
),
1689 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec4_type
),
1692 add_function("doubleBitsToUint64",
1693 _doubleBitsToUint64(int64_fp64
, glsl_type::double_type
),
1694 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec2_type
),
1695 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec3_type
),
1696 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec4_type
),
1699 add_function("int64BitsToDouble",
1700 _int64BitsToDouble(int64_fp64
, glsl_type::int64_t_type
),
1701 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec2_type
),
1702 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec3_type
),
1703 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec4_type
),
1706 add_function("uint64BitsToDouble",
1707 _uint64BitsToDouble(int64_fp64
, glsl_type::uint64_t_type
),
1708 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec2_type
),
1709 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec3_type
),
1710 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec4_type
),
1713 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1714 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1715 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1716 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1717 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1718 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1719 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1720 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1721 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1722 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1723 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1724 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1726 add_function("packInt2x32", _packInt2x32(int64
), NULL
);
1727 add_function("unpackInt2x32", _unpackInt2x32(int64
), NULL
);
1728 add_function("packUint2x32", _packUint2x32(int64
), NULL
);
1729 add_function("unpackUint2x32", _unpackUint2x32(int64
), NULL
);
1735 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1736 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1739 add_function("ftransform", _ftransform(), NULL
);
1744 add_function("matrixCompMult",
1745 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1746 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1747 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1748 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1749 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1750 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1751 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1752 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1753 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1754 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1755 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1756 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1757 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1758 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1759 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1760 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1761 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1762 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1764 add_function("outerProduct",
1765 _outerProduct(v120
, glsl_type::mat2_type
),
1766 _outerProduct(v120
, glsl_type::mat3_type
),
1767 _outerProduct(v120
, glsl_type::mat4_type
),
1768 _outerProduct(v120
, glsl_type::mat2x3_type
),
1769 _outerProduct(v120
, glsl_type::mat2x4_type
),
1770 _outerProduct(v120
, glsl_type::mat3x2_type
),
1771 _outerProduct(v120
, glsl_type::mat3x4_type
),
1772 _outerProduct(v120
, glsl_type::mat4x2_type
),
1773 _outerProduct(v120
, glsl_type::mat4x3_type
),
1774 _outerProduct(fp64
, glsl_type::dmat2_type
),
1775 _outerProduct(fp64
, glsl_type::dmat3_type
),
1776 _outerProduct(fp64
, glsl_type::dmat4_type
),
1777 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1778 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1779 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1780 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1781 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1782 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1784 add_function("determinant",
1785 _determinant_mat2(v120
, glsl_type::mat2_type
),
1786 _determinant_mat3(v120
, glsl_type::mat3_type
),
1787 _determinant_mat4(v120
, glsl_type::mat4_type
),
1788 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1789 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1790 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1793 add_function("inverse",
1794 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1795 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1796 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1797 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1798 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1799 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1801 add_function("transpose",
1802 _transpose(v120
, glsl_type::mat2_type
),
1803 _transpose(v120
, glsl_type::mat3_type
),
1804 _transpose(v120
, glsl_type::mat4_type
),
1805 _transpose(v120
, glsl_type::mat2x3_type
),
1806 _transpose(v120
, glsl_type::mat2x4_type
),
1807 _transpose(v120
, glsl_type::mat3x2_type
),
1808 _transpose(v120
, glsl_type::mat3x4_type
),
1809 _transpose(v120
, glsl_type::mat4x2_type
),
1810 _transpose(v120
, glsl_type::mat4x3_type
),
1811 _transpose(fp64
, glsl_type::dmat2_type
),
1812 _transpose(fp64
, glsl_type::dmat3_type
),
1813 _transpose(fp64
, glsl_type::dmat4_type
),
1814 _transpose(fp64
, glsl_type::dmat2x3_type
),
1815 _transpose(fp64
, glsl_type::dmat2x4_type
),
1816 _transpose(fp64
, glsl_type::dmat3x2_type
),
1817 _transpose(fp64
, glsl_type::dmat3x4_type
),
1818 _transpose(fp64
, glsl_type::dmat4x2_type
),
1819 _transpose(fp64
, glsl_type::dmat4x3_type
),
1822 FIUD_VEC(lessThanEqual
)
1823 FIUD_VEC(greaterThan
)
1824 FIUD_VEC(greaterThanEqual
)
1829 _any(glsl_type::bvec2_type
),
1830 _any(glsl_type::bvec3_type
),
1831 _any(glsl_type::bvec4_type
),
1835 _all(glsl_type::bvec2_type
),
1836 _all(glsl_type::bvec3_type
),
1837 _all(glsl_type::bvec4_type
),
1841 _not(glsl_type::bvec2_type
),
1842 _not(glsl_type::bvec3_type
),
1843 _not(glsl_type::bvec4_type
),
1846 add_function("textureSize",
1847 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1848 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1849 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1851 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1852 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1853 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1855 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1856 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1857 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1859 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1860 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1861 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1863 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1864 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1865 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1867 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1868 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1869 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1870 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1871 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1872 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1874 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1875 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1877 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1878 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1879 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1880 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1882 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1883 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1884 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1885 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1887 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1888 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1889 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1890 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1891 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1892 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1894 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1895 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1896 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1899 add_function("textureSamples",
1900 _textureSamples(shader_samples
, glsl_type::sampler2DMS_type
),
1901 _textureSamples(shader_samples
, glsl_type::isampler2DMS_type
),
1902 _textureSamples(shader_samples
, glsl_type::usampler2DMS_type
),
1904 _textureSamples(shader_samples
, glsl_type::sampler2DMSArray_type
),
1905 _textureSamples(shader_samples
, glsl_type::isampler2DMSArray_type
),
1906 _textureSamples(shader_samples
, glsl_type::usampler2DMSArray_type
),
1909 add_function("texture",
1910 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1911 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1912 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1914 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1915 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1916 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1918 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1919 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1920 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1922 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1923 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1924 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1926 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1927 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1928 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1930 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1931 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1932 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1934 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1935 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1936 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1938 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1939 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1940 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1942 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1943 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1944 /* samplerCubeArrayShadow is special; it has an extra parameter
1945 * for the shadow comparator since there is no vec5 type.
1947 _textureCubeArrayShadow(texture_cube_map_array
, glsl_type::samplerCubeArrayShadow_type
),
1949 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1950 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1951 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1953 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1955 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
1957 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1958 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1959 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1961 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1962 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1963 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1965 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1966 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1967 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1969 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1970 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1971 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1973 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1974 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1975 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1977 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1978 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1979 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1981 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1982 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1983 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1985 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1986 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1987 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1989 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1992 add_function("textureLod",
1993 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1994 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1995 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1997 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1998 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1999 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2001 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2002 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2003 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2005 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2006 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2007 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2009 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2010 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2012 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2013 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2014 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2016 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2017 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2018 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2020 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2021 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2022 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2024 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2027 add_function("textureOffset",
2028 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2029 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2030 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2032 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2033 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2034 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2036 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2037 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2038 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2040 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2041 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2042 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2044 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2046 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2047 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2049 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2050 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2051 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2053 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2054 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2055 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2057 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2058 /* The next one was forgotten in GLSL 1.30 spec. It's from
2059 * EXT_gpu_shader4 originally. It was added in 4.30 with the
2060 * wrong syntax. This was corrected in 4.40. 4.30 indicates
2061 * that it was intended to be included previously, so allow it
2064 _texture(ir_tex
, v130_desktop
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2066 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2067 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2068 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2070 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2071 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2072 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2074 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2075 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2076 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2078 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2079 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2081 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2082 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2083 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2085 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2086 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2087 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2089 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2092 add_function("textureProj",
2093 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2094 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2095 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2096 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2097 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2098 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2100 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2101 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2102 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2103 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2104 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2105 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2107 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2108 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2109 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2111 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2112 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2114 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2115 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2116 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2117 _texture(ir_tex
, texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2119 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2120 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2121 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2122 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2124 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2126 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2127 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2128 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2129 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2130 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2131 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2133 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2134 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2135 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2136 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2137 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2138 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2140 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2141 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2142 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2144 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2145 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2148 add_function("texelFetch",
2149 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
2150 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
2151 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
2153 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
2154 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
2155 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
2157 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
2158 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
2159 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
2161 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
2162 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
2163 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
2165 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
2166 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
2167 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
2169 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
2170 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
2171 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
2173 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
2174 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
2175 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
2177 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2178 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2179 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2181 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2182 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2183 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2185 _texelFetch(texture_external_es3
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::ivec2_type
),
2190 add_function("texelFetchOffset",
2191 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2192 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2193 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2195 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2196 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2197 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2199 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2200 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2201 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2203 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2204 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2205 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2207 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2208 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2209 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2211 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2212 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2213 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2217 add_function("textureProjOffset",
2218 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2219 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2220 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2221 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2222 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2223 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2225 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2226 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2227 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2228 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2229 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2230 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2232 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2233 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2234 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2236 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2237 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2239 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2240 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2241 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2242 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2243 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2244 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2246 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2248 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2249 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2250 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2251 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2252 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2253 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2255 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2256 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2257 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2258 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2259 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2260 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2262 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2263 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2264 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2266 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2267 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2270 add_function("textureLodOffset",
2271 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2272 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2273 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2275 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2276 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2277 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2279 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2280 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2281 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2283 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2284 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2286 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2287 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2288 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2290 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2291 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2292 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2294 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2297 add_function("textureProjLod",
2298 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2299 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2300 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2301 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2302 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2303 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2305 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2306 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2307 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2308 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2309 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2310 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2312 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2313 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2314 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2316 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2317 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2320 add_function("textureProjLodOffset",
2321 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2322 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2323 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2324 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2325 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2326 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2328 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2329 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2330 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2331 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2332 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2333 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2335 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2336 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2337 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2339 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2340 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2343 add_function("textureGrad",
2344 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2345 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2346 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2348 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2349 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2350 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2352 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2353 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2354 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2356 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2357 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2358 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2360 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2361 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2362 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2364 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2366 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2367 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2368 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2370 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2371 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2372 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2374 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2375 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2376 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2378 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2379 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2380 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2382 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2383 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2386 add_function("textureGradOffset",
2387 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2388 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2389 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2391 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2392 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2393 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2395 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2396 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2397 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2399 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2400 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2401 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2403 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2405 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2406 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2408 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2409 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2410 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2412 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2413 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2414 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2416 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2417 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2420 add_function("textureProjGrad",
2421 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2422 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2423 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2424 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2425 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2426 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2428 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2429 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2430 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2431 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2432 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2433 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2435 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2436 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2437 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2439 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2440 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2441 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2442 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2443 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2444 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2446 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2448 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2449 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2452 add_function("textureProjGradOffset",
2453 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2454 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2455 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2456 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2457 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2458 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2460 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2461 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2462 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2463 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2464 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2465 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2467 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2468 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2469 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2471 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2472 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2473 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2474 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2475 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2476 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2478 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2480 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2481 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2484 add_function("EmitVertex", _EmitVertex(), NULL
);
2485 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2486 add_function("EmitStreamVertex",
2487 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2488 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2490 add_function("EndStreamPrimitive",
2491 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2492 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2494 add_function("barrier", _barrier(), NULL
);
2496 add_function("textureQueryLOD",
2497 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2498 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2499 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2501 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2502 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2503 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2505 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2506 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2507 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2509 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2510 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2511 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2513 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2514 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2515 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2517 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2518 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2519 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2521 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2522 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2523 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2525 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2526 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2527 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2528 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2529 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2530 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2533 add_function("textureQueryLod",
2534 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2535 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2536 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2538 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2539 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2540 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2542 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2543 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2544 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2546 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2547 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2548 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2550 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2551 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2552 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2554 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2555 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2556 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2558 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2559 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2560 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2562 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2563 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2564 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2565 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2566 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2567 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2570 add_function("textureQueryLevels",
2571 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1D_type
),
2572 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2D_type
),
2573 _textureQueryLevels(texture_query_levels
, glsl_type::sampler3D_type
),
2574 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCube_type
),
2575 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArray_type
),
2576 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArray_type
),
2577 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArray_type
),
2578 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DShadow_type
),
2579 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DShadow_type
),
2580 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeShadow_type
),
2581 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArrayShadow_type
),
2582 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArrayShadow_type
),
2583 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArrayShadow_type
),
2585 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1D_type
),
2586 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2D_type
),
2587 _textureQueryLevels(texture_query_levels
, glsl_type::isampler3D_type
),
2588 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCube_type
),
2589 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1DArray_type
),
2590 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2DArray_type
),
2591 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCubeArray_type
),
2593 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1D_type
),
2594 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2D_type
),
2595 _textureQueryLevels(texture_query_levels
, glsl_type::usampler3D_type
),
2596 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCube_type
),
2597 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1DArray_type
),
2598 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2DArray_type
),
2599 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCubeArray_type
),
2603 add_function("textureSamplesIdenticalEXT",
2604 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2605 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2606 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2608 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2609 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2610 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2613 add_function("texture1D",
2614 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2615 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2618 add_function("texture1DArray",
2619 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2620 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2623 add_function("texture1DProj",
2624 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2625 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2626 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2627 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2630 add_function("texture1DLod",
2631 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2634 add_function("texture1DArrayLod",
2635 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2638 add_function("texture1DProjLod",
2639 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2640 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2643 add_function("texture2D",
2644 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2645 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2646 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2649 add_function("texture2DArray",
2650 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2651 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2654 add_function("texture2DProj",
2655 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2656 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2657 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2658 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2659 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2660 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2663 add_function("texture2DLod",
2664 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2667 add_function("texture2DArrayLod",
2668 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2671 add_function("texture2DProjLod",
2672 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2673 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2676 add_function("texture3D",
2677 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2678 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2681 add_function("texture3DProj",
2682 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2683 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2686 add_function("texture3DLod",
2687 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2690 add_function("texture3DProjLod",
2691 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2694 add_function("textureCube",
2695 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2696 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2699 add_function("textureCubeLod",
2700 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2703 add_function("texture2DRect",
2704 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2707 add_function("texture2DRectProj",
2708 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2709 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2712 add_function("shadow1D",
2713 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2714 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2717 add_function("shadow1DArray",
2718 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2719 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2722 add_function("shadow2D",
2723 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2724 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2727 add_function("shadow2DArray",
2728 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2729 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2732 add_function("shadow1DProj",
2733 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2734 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2737 add_function("shadow2DProj",
2738 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2739 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2742 add_function("shadow1DLod",
2743 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2746 add_function("shadow2DLod",
2747 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2750 add_function("shadow1DArrayLod",
2751 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2754 add_function("shadow1DProjLod",
2755 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2758 add_function("shadow2DProjLod",
2759 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2762 add_function("shadow2DRect",
2763 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2766 add_function("shadow2DRectProj",
2767 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2770 add_function("texture1DGradARB",
2771 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2774 add_function("texture1DProjGradARB",
2775 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2776 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2779 add_function("texture2DGradARB",
2780 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2783 add_function("texture2DProjGradARB",
2784 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2785 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2788 add_function("texture3DGradARB",
2789 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2792 add_function("texture3DProjGradARB",
2793 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2796 add_function("textureCubeGradARB",
2797 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2800 add_function("shadow1DGradARB",
2801 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2804 add_function("shadow1DProjGradARB",
2805 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2808 add_function("shadow2DGradARB",
2809 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2812 add_function("shadow2DProjGradARB",
2813 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2816 add_function("texture2DRectGradARB",
2817 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2820 add_function("texture2DRectProjGradARB",
2821 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2822 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2825 add_function("shadow2DRectGradARB",
2826 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2829 add_function("shadow2DRectProjGradARB",
2830 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2833 add_function("textureGather",
2834 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2835 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2836 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2838 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2839 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2840 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2842 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2843 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2844 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2846 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2847 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2848 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2850 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2851 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2852 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2854 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2855 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2856 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2858 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2859 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2860 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2862 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2863 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2864 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2866 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2867 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2868 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2870 _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
),
2871 _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
),
2872 _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
),
2874 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2875 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2876 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2877 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2878 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2881 add_function("textureGatherOffset",
2882 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2883 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2884 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2886 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2887 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2888 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2890 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2891 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2892 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2894 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2895 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2896 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2898 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2899 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2900 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2902 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2903 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2904 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2906 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2907 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2908 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2910 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2911 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2912 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2914 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2915 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2916 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2918 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2919 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2920 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2922 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2923 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2924 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2926 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2927 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2930 add_function("textureGatherOffsets",
2931 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2932 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2933 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2935 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2936 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2937 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2939 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2940 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2941 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2943 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2944 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2945 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2947 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2948 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2949 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2951 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2952 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2953 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2955 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2956 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2957 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2982 add_function("ldexp",
2983 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2984 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2985 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2986 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2987 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2988 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2989 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2990 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2993 add_function("frexp",
2994 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2995 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2996 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2997 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2998 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2999 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
3000 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
3001 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
3003 add_function("uaddCarry",
3004 _uaddCarry(glsl_type::uint_type
),
3005 _uaddCarry(glsl_type::uvec2_type
),
3006 _uaddCarry(glsl_type::uvec3_type
),
3007 _uaddCarry(glsl_type::uvec4_type
),
3009 add_function("usubBorrow",
3010 _usubBorrow(glsl_type::uint_type
),
3011 _usubBorrow(glsl_type::uvec2_type
),
3012 _usubBorrow(glsl_type::uvec3_type
),
3013 _usubBorrow(glsl_type::uvec4_type
),
3015 add_function("imulExtended",
3016 _mulExtended(glsl_type::int_type
),
3017 _mulExtended(glsl_type::ivec2_type
),
3018 _mulExtended(glsl_type::ivec3_type
),
3019 _mulExtended(glsl_type::ivec4_type
),
3021 add_function("umulExtended",
3022 _mulExtended(glsl_type::uint_type
),
3023 _mulExtended(glsl_type::uvec2_type
),
3024 _mulExtended(glsl_type::uvec3_type
),
3025 _mulExtended(glsl_type::uvec4_type
),
3027 add_function("interpolateAtCentroid",
3028 _interpolateAtCentroid(glsl_type::float_type
),
3029 _interpolateAtCentroid(glsl_type::vec2_type
),
3030 _interpolateAtCentroid(glsl_type::vec3_type
),
3031 _interpolateAtCentroid(glsl_type::vec4_type
),
3033 add_function("interpolateAtOffset",
3034 _interpolateAtOffset(glsl_type::float_type
),
3035 _interpolateAtOffset(glsl_type::vec2_type
),
3036 _interpolateAtOffset(glsl_type::vec3_type
),
3037 _interpolateAtOffset(glsl_type::vec4_type
),
3039 add_function("interpolateAtSample",
3040 _interpolateAtSample(glsl_type::float_type
),
3041 _interpolateAtSample(glsl_type::vec2_type
),
3042 _interpolateAtSample(glsl_type::vec3_type
),
3043 _interpolateAtSample(glsl_type::vec4_type
),
3046 add_function("atomicCounter",
3047 _atomic_counter_op("__intrinsic_atomic_read",
3048 shader_atomic_counters
),
3050 add_function("atomicCounterIncrement",
3051 _atomic_counter_op("__intrinsic_atomic_increment",
3052 shader_atomic_counters
),
3054 add_function("atomicCounterDecrement",
3055 _atomic_counter_op("__intrinsic_atomic_predecrement",
3056 shader_atomic_counters
),
3059 add_function("atomicCounterAddARB",
3060 _atomic_counter_op1("__intrinsic_atomic_add",
3061 shader_atomic_counter_ops
),
3063 add_function("atomicCounterSubtractARB",
3064 _atomic_counter_op1("__intrinsic_atomic_sub",
3065 shader_atomic_counter_ops
),
3067 add_function("atomicCounterMinARB",
3068 _atomic_counter_op1("__intrinsic_atomic_min",
3069 shader_atomic_counter_ops
),
3071 add_function("atomicCounterMaxARB",
3072 _atomic_counter_op1("__intrinsic_atomic_max",
3073 shader_atomic_counter_ops
),
3075 add_function("atomicCounterAndARB",
3076 _atomic_counter_op1("__intrinsic_atomic_and",
3077 shader_atomic_counter_ops
),
3079 add_function("atomicCounterOrARB",
3080 _atomic_counter_op1("__intrinsic_atomic_or",
3081 shader_atomic_counter_ops
),
3083 add_function("atomicCounterXorARB",
3084 _atomic_counter_op1("__intrinsic_atomic_xor",
3085 shader_atomic_counter_ops
),
3087 add_function("atomicCounterExchangeARB",
3088 _atomic_counter_op1("__intrinsic_atomic_exchange",
3089 shader_atomic_counter_ops
),
3091 add_function("atomicCounterCompSwapARB",
3092 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3093 shader_atomic_counter_ops
),
3096 add_function("atomicCounterAdd",
3097 _atomic_counter_op1("__intrinsic_atomic_add",
3100 add_function("atomicCounterSubtract",
3101 _atomic_counter_op1("__intrinsic_atomic_sub",
3104 add_function("atomicCounterMin",
3105 _atomic_counter_op1("__intrinsic_atomic_min",
3108 add_function("atomicCounterMax",
3109 _atomic_counter_op1("__intrinsic_atomic_max",
3112 add_function("atomicCounterAnd",
3113 _atomic_counter_op1("__intrinsic_atomic_and",
3116 add_function("atomicCounterOr",
3117 _atomic_counter_op1("__intrinsic_atomic_or",
3120 add_function("atomicCounterXor",
3121 _atomic_counter_op1("__intrinsic_atomic_xor",
3124 add_function("atomicCounterExchange",
3125 _atomic_counter_op1("__intrinsic_atomic_exchange",
3128 add_function("atomicCounterCompSwap",
3129 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3133 add_function("atomicAdd",
3134 _atomic_op2("__intrinsic_atomic_add",
3135 buffer_atomics_supported
,
3136 glsl_type::uint_type
),
3137 _atomic_op2("__intrinsic_atomic_add",
3138 buffer_atomics_supported
,
3139 glsl_type::int_type
),
3141 add_function("atomicMin",
3142 _atomic_op2("__intrinsic_atomic_min",
3143 buffer_atomics_supported
,
3144 glsl_type::uint_type
),
3145 _atomic_op2("__intrinsic_atomic_min",
3146 buffer_atomics_supported
,
3147 glsl_type::int_type
),
3149 add_function("atomicMax",
3150 _atomic_op2("__intrinsic_atomic_max",
3151 buffer_atomics_supported
,
3152 glsl_type::uint_type
),
3153 _atomic_op2("__intrinsic_atomic_max",
3154 buffer_atomics_supported
,
3155 glsl_type::int_type
),
3157 add_function("atomicAnd",
3158 _atomic_op2("__intrinsic_atomic_and",
3159 buffer_atomics_supported
,
3160 glsl_type::uint_type
),
3161 _atomic_op2("__intrinsic_atomic_and",
3162 buffer_atomics_supported
,
3163 glsl_type::int_type
),
3165 add_function("atomicOr",
3166 _atomic_op2("__intrinsic_atomic_or",
3167 buffer_atomics_supported
,
3168 glsl_type::uint_type
),
3169 _atomic_op2("__intrinsic_atomic_or",
3170 buffer_atomics_supported
,
3171 glsl_type::int_type
),
3173 add_function("atomicXor",
3174 _atomic_op2("__intrinsic_atomic_xor",
3175 buffer_atomics_supported
,
3176 glsl_type::uint_type
),
3177 _atomic_op2("__intrinsic_atomic_xor",
3178 buffer_atomics_supported
,
3179 glsl_type::int_type
),
3181 add_function("atomicExchange",
3182 _atomic_op2("__intrinsic_atomic_exchange",
3183 buffer_atomics_supported
,
3184 glsl_type::uint_type
),
3185 _atomic_op2("__intrinsic_atomic_exchange",
3186 buffer_atomics_supported
,
3187 glsl_type::int_type
),
3189 add_function("atomicCompSwap",
3190 _atomic_op3("__intrinsic_atomic_comp_swap",
3191 buffer_atomics_supported
,
3192 glsl_type::uint_type
),
3193 _atomic_op3("__intrinsic_atomic_comp_swap",
3194 buffer_atomics_supported
,
3195 glsl_type::int_type
),
3198 add_function("min3",
3199 _min3(glsl_type::float_type
),
3200 _min3(glsl_type::vec2_type
),
3201 _min3(glsl_type::vec3_type
),
3202 _min3(glsl_type::vec4_type
),
3204 _min3(glsl_type::int_type
),
3205 _min3(glsl_type::ivec2_type
),
3206 _min3(glsl_type::ivec3_type
),
3207 _min3(glsl_type::ivec4_type
),
3209 _min3(glsl_type::uint_type
),
3210 _min3(glsl_type::uvec2_type
),
3211 _min3(glsl_type::uvec3_type
),
3212 _min3(glsl_type::uvec4_type
),
3215 add_function("max3",
3216 _max3(glsl_type::float_type
),
3217 _max3(glsl_type::vec2_type
),
3218 _max3(glsl_type::vec3_type
),
3219 _max3(glsl_type::vec4_type
),
3221 _max3(glsl_type::int_type
),
3222 _max3(glsl_type::ivec2_type
),
3223 _max3(glsl_type::ivec3_type
),
3224 _max3(glsl_type::ivec4_type
),
3226 _max3(glsl_type::uint_type
),
3227 _max3(glsl_type::uvec2_type
),
3228 _max3(glsl_type::uvec3_type
),
3229 _max3(glsl_type::uvec4_type
),
3232 add_function("mid3",
3233 _mid3(glsl_type::float_type
),
3234 _mid3(glsl_type::vec2_type
),
3235 _mid3(glsl_type::vec3_type
),
3236 _mid3(glsl_type::vec4_type
),
3238 _mid3(glsl_type::int_type
),
3239 _mid3(glsl_type::ivec2_type
),
3240 _mid3(glsl_type::ivec3_type
),
3241 _mid3(glsl_type::ivec4_type
),
3243 _mid3(glsl_type::uint_type
),
3244 _mid3(glsl_type::uvec2_type
),
3245 _mid3(glsl_type::uvec3_type
),
3246 _mid3(glsl_type::uvec4_type
),
3249 add_image_functions(true);
3251 add_function("memoryBarrier",
3252 _memory_barrier("__intrinsic_memory_barrier",
3253 shader_image_load_store
),
3255 add_function("groupMemoryBarrier",
3256 _memory_barrier("__intrinsic_group_memory_barrier",
3259 add_function("memoryBarrierAtomicCounter",
3260 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
3261 compute_shader_supported
),
3263 add_function("memoryBarrierBuffer",
3264 _memory_barrier("__intrinsic_memory_barrier_buffer",
3265 compute_shader_supported
),
3267 add_function("memoryBarrierImage",
3268 _memory_barrier("__intrinsic_memory_barrier_image",
3269 compute_shader_supported
),
3271 add_function("memoryBarrierShared",
3272 _memory_barrier("__intrinsic_memory_barrier_shared",
3276 add_function("ballotARB", _ballot(), NULL
);
3278 add_function("readInvocationARB",
3279 _read_invocation(glsl_type::float_type
),
3280 _read_invocation(glsl_type::vec2_type
),
3281 _read_invocation(glsl_type::vec3_type
),
3282 _read_invocation(glsl_type::vec4_type
),
3284 _read_invocation(glsl_type::int_type
),
3285 _read_invocation(glsl_type::ivec2_type
),
3286 _read_invocation(glsl_type::ivec3_type
),
3287 _read_invocation(glsl_type::ivec4_type
),
3289 _read_invocation(glsl_type::uint_type
),
3290 _read_invocation(glsl_type::uvec2_type
),
3291 _read_invocation(glsl_type::uvec3_type
),
3292 _read_invocation(glsl_type::uvec4_type
),
3295 add_function("readFirstInvocationARB",
3296 _read_first_invocation(glsl_type::float_type
),
3297 _read_first_invocation(glsl_type::vec2_type
),
3298 _read_first_invocation(glsl_type::vec3_type
),
3299 _read_first_invocation(glsl_type::vec4_type
),
3301 _read_first_invocation(glsl_type::int_type
),
3302 _read_first_invocation(glsl_type::ivec2_type
),
3303 _read_first_invocation(glsl_type::ivec3_type
),
3304 _read_first_invocation(glsl_type::ivec4_type
),
3306 _read_first_invocation(glsl_type::uint_type
),
3307 _read_first_invocation(glsl_type::uvec2_type
),
3308 _read_first_invocation(glsl_type::uvec3_type
),
3309 _read_first_invocation(glsl_type::uvec4_type
),
3312 add_function("clock2x32ARB",
3313 _shader_clock(shader_clock
,
3314 glsl_type::uvec2_type
),
3317 add_function("clockARB",
3318 _shader_clock(shader_clock_int64
,
3319 glsl_type::uint64_t_type
),
3322 add_function("beginInvocationInterlockARB",
3323 _invocation_interlock(
3324 "__intrinsic_begin_invocation_interlock",
3325 supports_arb_fragment_shader_interlock
),
3328 add_function("endInvocationInterlockARB",
3329 _invocation_interlock(
3330 "__intrinsic_end_invocation_interlock",
3331 supports_arb_fragment_shader_interlock
),
3334 add_function("anyInvocationARB",
3335 _vote("__intrinsic_vote_any", vote
),
3338 add_function("allInvocationsARB",
3339 _vote("__intrinsic_vote_all", vote
),
3342 add_function("allInvocationsEqualARB",
3343 _vote("__intrinsic_vote_eq", vote
),
3346 add_function("anyInvocation",
3347 _vote("__intrinsic_vote_any", v460_desktop
),
3350 add_function("allInvocations",
3351 _vote("__intrinsic_vote_all", v460_desktop
),
3354 add_function("allInvocationsEqual",
3355 _vote("__intrinsic_vote_eq", v460_desktop
),
3358 add_function("__builtin_idiv64",
3359 generate_ir::idiv64(mem_ctx
, integer_functions_supported
),
3362 add_function("__builtin_imod64",
3363 generate_ir::imod64(mem_ctx
, integer_functions_supported
),
3366 add_function("__builtin_sign64",
3367 generate_ir::sign64(mem_ctx
, integer_functions_supported
),
3370 add_function("__builtin_udiv64",
3371 generate_ir::udiv64(mem_ctx
, integer_functions_supported
),
3374 add_function("__builtin_umod64",
3375 generate_ir::umod64(mem_ctx
, integer_functions_supported
),
3378 add_function("__builtin_umul64",
3379 generate_ir::umul64(mem_ctx
, integer_functions_supported
),
3390 builtin_builder::add_function(const char *name
, ...)
3394 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3398 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
3404 stuff
.push_tail(sig
);
3405 validate_ir_tree(&stuff
);
3408 f
->add_signature(sig
);
3412 shader
->symbols
->add_function(f
);
3416 builtin_builder::add_image_function(const char *name
,
3417 const char *intrinsic_name
,
3418 image_prototype_ctr prototype
,
3419 unsigned num_arguments
,
3421 enum ir_intrinsic_id intrinsic_id
)
3423 static const glsl_type
*const types
[] = {
3424 glsl_type::image1D_type
,
3425 glsl_type::image2D_type
,
3426 glsl_type::image3D_type
,
3427 glsl_type::image2DRect_type
,
3428 glsl_type::imageCube_type
,
3429 glsl_type::imageBuffer_type
,
3430 glsl_type::image1DArray_type
,
3431 glsl_type::image2DArray_type
,
3432 glsl_type::imageCubeArray_type
,
3433 glsl_type::image2DMS_type
,
3434 glsl_type::image2DMSArray_type
,
3435 glsl_type::iimage1D_type
,
3436 glsl_type::iimage2D_type
,
3437 glsl_type::iimage3D_type
,
3438 glsl_type::iimage2DRect_type
,
3439 glsl_type::iimageCube_type
,
3440 glsl_type::iimageBuffer_type
,
3441 glsl_type::iimage1DArray_type
,
3442 glsl_type::iimage2DArray_type
,
3443 glsl_type::iimageCubeArray_type
,
3444 glsl_type::iimage2DMS_type
,
3445 glsl_type::iimage2DMSArray_type
,
3446 glsl_type::uimage1D_type
,
3447 glsl_type::uimage2D_type
,
3448 glsl_type::uimage3D_type
,
3449 glsl_type::uimage2DRect_type
,
3450 glsl_type::uimageCube_type
,
3451 glsl_type::uimageBuffer_type
,
3452 glsl_type::uimage1DArray_type
,
3453 glsl_type::uimage2DArray_type
,
3454 glsl_type::uimageCubeArray_type
,
3455 glsl_type::uimage2DMS_type
,
3456 glsl_type::uimage2DMSArray_type
3459 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3461 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3462 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3463 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3464 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3465 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3466 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3467 num_arguments
, flags
, intrinsic_id
));
3470 shader
->symbols
->add_function(f
);
3474 builtin_builder::add_image_functions(bool glsl
)
3476 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3478 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3479 "__intrinsic_image_load",
3480 &builtin_builder::_image_prototype
, 0,
3481 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3482 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3483 IMAGE_FUNCTION_READ_ONLY
),
3484 ir_intrinsic_image_load
);
3486 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3487 "__intrinsic_image_store",
3488 &builtin_builder::_image_prototype
, 1,
3489 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3490 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3491 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3492 IMAGE_FUNCTION_WRITE_ONLY
),
3493 ir_intrinsic_image_store
);
3495 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3497 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3498 "__intrinsic_image_atomic_add",
3499 &builtin_builder::_image_prototype
, 1, atom_flags
,
3500 ir_intrinsic_image_atomic_add
);
3502 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3503 "__intrinsic_image_atomic_min",
3504 &builtin_builder::_image_prototype
, 1, atom_flags
,
3505 ir_intrinsic_image_atomic_min
);
3507 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3508 "__intrinsic_image_atomic_max",
3509 &builtin_builder::_image_prototype
, 1, atom_flags
,
3510 ir_intrinsic_image_atomic_max
);
3512 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3513 "__intrinsic_image_atomic_and",
3514 &builtin_builder::_image_prototype
, 1, atom_flags
,
3515 ir_intrinsic_image_atomic_and
);
3517 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3518 "__intrinsic_image_atomic_or",
3519 &builtin_builder::_image_prototype
, 1, atom_flags
,
3520 ir_intrinsic_image_atomic_or
);
3522 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3523 "__intrinsic_image_atomic_xor",
3524 &builtin_builder::_image_prototype
, 1, atom_flags
,
3525 ir_intrinsic_image_atomic_xor
);
3527 add_image_function((glsl
? "imageAtomicExchange" :
3528 "__intrinsic_image_atomic_exchange"),
3529 "__intrinsic_image_atomic_exchange",
3530 &builtin_builder::_image_prototype
, 1,
3531 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3532 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3533 ir_intrinsic_image_atomic_exchange
);
3535 add_image_function((glsl
? "imageAtomicCompSwap" :
3536 "__intrinsic_image_atomic_comp_swap"),
3537 "__intrinsic_image_atomic_comp_swap",
3538 &builtin_builder::_image_prototype
, 2, atom_flags
,
3539 ir_intrinsic_image_atomic_comp_swap
);
3541 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3542 "__intrinsic_image_size",
3543 &builtin_builder::_image_size_prototype
, 1,
3544 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
,
3545 ir_intrinsic_image_size
);
3547 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3548 "__intrinsic_image_samples",
3549 &builtin_builder::_image_samples_prototype
, 1,
3550 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3551 IMAGE_FUNCTION_MS_ONLY
,
3552 ir_intrinsic_image_samples
);
3556 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3558 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3562 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3564 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3568 builtin_builder::imm(bool b
, unsigned vector_elements
)
3570 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3574 builtin_builder::imm(float f
, unsigned vector_elements
)
3576 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3580 builtin_builder::imm(int i
, unsigned vector_elements
)
3582 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3586 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3588 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3592 builtin_builder::imm(double d
, unsigned vector_elements
)
3594 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3598 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3600 return new(mem_ctx
) ir_constant(type
, &data
);
3603 #define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)
3605 ir_dereference_variable
*
3606 builtin_builder::var_ref(ir_variable
*var
)
3608 return new(mem_ctx
) ir_dereference_variable(var
);
3611 ir_dereference_array
*
3612 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3614 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3617 /** Return an element of a matrix */
3619 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3621 return swizzle(array_ref(var
, column
), row
, 1);
3625 * Implementations of built-in functions:
3628 ir_function_signature
*
3629 builtin_builder::new_sig(const glsl_type
*return_type
,
3630 builtin_available_predicate avail
,
3636 ir_function_signature
*sig
=
3637 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3640 va_start(ap
, num_params
);
3641 for (int i
= 0; i
< num_params
; i
++) {
3642 plist
.push_tail(va_arg(ap
, ir_variable
*));
3646 sig
->replace_parameters(&plist
);
3650 #define MAKE_SIG(return_type, avail, ...) \
3651 ir_function_signature *sig = \
3652 new_sig(return_type, avail, __VA_ARGS__); \
3653 ir_factory body(&sig->body, mem_ctx); \
3654 sig->is_defined = true;
3656 #define MAKE_INTRINSIC(return_type, id, avail, ...) \
3657 ir_function_signature *sig = \
3658 new_sig(return_type, avail, __VA_ARGS__); \
3659 sig->intrinsic_id = id;
3661 ir_function_signature
*
3662 builtin_builder::unop(builtin_available_predicate avail
,
3663 ir_expression_operation opcode
,
3664 const glsl_type
*return_type
,
3665 const glsl_type
*param_type
)
3667 ir_variable
*x
= in_var(param_type
, "x");
3668 MAKE_SIG(return_type
, avail
, 1, x
);
3669 body
.emit(ret(expr(opcode
, x
)));
3673 #define UNOP(NAME, OPCODE, AVAIL) \
3674 ir_function_signature * \
3675 builtin_builder::_##NAME(const glsl_type *type) \
3677 return unop(&AVAIL, OPCODE, type, type); \
3680 #define UNOPA(NAME, OPCODE) \
3681 ir_function_signature * \
3682 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3684 return unop(avail, OPCODE, type, type); \
3687 ir_function_signature
*
3688 builtin_builder::binop(builtin_available_predicate avail
,
3689 ir_expression_operation opcode
,
3690 const glsl_type
*return_type
,
3691 const glsl_type
*param0_type
,
3692 const glsl_type
*param1_type
,
3695 ir_variable
*x
= in_var(param0_type
, "x");
3696 ir_variable
*y
= in_var(param1_type
, "y");
3697 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3700 body
.emit(ret(expr(opcode
, y
, x
)));
3702 body
.emit(ret(expr(opcode
, x
, y
)));
3707 #define BINOP(NAME, OPCODE, AVAIL) \
3708 ir_function_signature * \
3709 builtin_builder::_##NAME(const glsl_type *return_type, \
3710 const glsl_type *param0_type, \
3711 const glsl_type *param1_type) \
3713 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3717 * Angle and Trigonometry Functions @{
3720 ir_function_signature
*
3721 builtin_builder::_radians(const glsl_type
*type
)
3723 ir_variable
*degrees
= in_var(type
, "degrees");
3724 MAKE_SIG(type
, always_available
, 1, degrees
);
3725 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3729 ir_function_signature
*
3730 builtin_builder::_degrees(const glsl_type
*type
)
3732 ir_variable
*radians
= in_var(type
, "radians");
3733 MAKE_SIG(type
, always_available
, 1, radians
);
3734 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3738 UNOP(sin
, ir_unop_sin
, always_available
)
3739 UNOP(cos
, ir_unop_cos
, always_available
)
3741 ir_function_signature
*
3742 builtin_builder::_tan(const glsl_type
*type
)
3744 ir_variable
*theta
= in_var(type
, "theta");
3745 MAKE_SIG(type
, always_available
, 1, theta
);
3746 body
.emit(ret(div(sin(theta
), cos(theta
))));
3751 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3755 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3758 add(imm(M_PI_4f
- 1.0f
),
3761 mul(abs(x
), imm(p1
))))))))));
3765 * Generate a ir_call to a function with a set of parameters
3767 * The input \c params can either be a list of \c ir_variable or a list of
3768 * \c ir_dereference_variable. In the latter case, all nodes will be removed
3769 * from \c params and used directly as the parameters to the generated
3773 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3775 exec_list actual_params
;
3777 foreach_in_list_safe(ir_instruction
, ir
, ¶ms
) {
3778 ir_dereference_variable
*d
= ir
->as_dereference_variable();
3781 actual_params
.push_tail(d
);
3783 ir_variable
*var
= ir
->as_variable();
3784 assert(var
!= NULL
);
3785 actual_params
.push_tail(var_ref(var
));
3789 ir_function_signature
*sig
=
3790 f
->exact_matching_signature(NULL
, &actual_params
);
3794 ir_dereference_variable
*deref
=
3795 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3797 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3800 ir_function_signature
*
3801 builtin_builder::_asin(const glsl_type
*type
)
3803 ir_variable
*x
= in_var(type
, "x");
3804 MAKE_SIG(type
, always_available
, 1, x
);
3806 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3811 ir_function_signature
*
3812 builtin_builder::_acos(const glsl_type
*type
)
3814 ir_variable
*x
= in_var(type
, "x");
3815 MAKE_SIG(type
, always_available
, 1, x
);
3817 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3822 ir_function_signature
*
3823 builtin_builder::_atan2(const glsl_type
*type
)
3825 const unsigned n
= type
->vector_elements
;
3826 ir_variable
*y
= in_var(type
, "y");
3827 ir_variable
*x
= in_var(type
, "x");
3828 MAKE_SIG(type
, always_available
, 2, y
, x
);
3830 /* If we're on the left half-plane rotate the coordinates π/2 clock-wise
3831 * for the y=0 discontinuity to end up aligned with the vertical
3832 * discontinuity of atan(s/t) along t=0. This also makes sure that we
3833 * don't attempt to divide by zero along the vertical line, which may give
3834 * unspecified results on non-GLSL 4.1-capable hardware.
3836 ir_variable
*flip
= body
.make_temp(glsl_type::bvec(n
), "flip");
3837 body
.emit(assign(flip
, gequal(imm(0.0f
, n
), x
)));
3838 ir_variable
*s
= body
.make_temp(type
, "s");
3839 body
.emit(assign(s
, csel(flip
, abs(x
), y
)));
3840 ir_variable
*t
= body
.make_temp(type
, "t");
3841 body
.emit(assign(t
, csel(flip
, y
, abs(x
))));
3843 /* If the magnitude of the denominator exceeds some huge value, scale down
3844 * the arguments in order to prevent the reciprocal operation from flushing
3845 * its result to zero, which would cause precision problems, and for s
3846 * infinite would cause us to return a NaN instead of the correct finite
3849 * If fmin and fmax are respectively the smallest and largest positive
3850 * normalized floating point values representable by the implementation,
3851 * the constants below should be in agreement with:
3854 * scale <= 1 / fmin / fmax (for |t| >= huge)
3856 * In addition scale should be a negative power of two in order to avoid
3857 * loss of precision. The values chosen below should work for most usual
3858 * floating point representations with at least the dynamic range of ATI's
3859 * 24-bit representation.
3861 ir_constant
*huge
= imm(1e18f
, n
);
3862 ir_variable
*scale
= body
.make_temp(type
, "scale");
3863 body
.emit(assign(scale
, csel(gequal(abs(t
), huge
),
3864 imm(0.25f
, n
), imm(1.0f
, n
))));
3865 ir_variable
*rcp_scaled_t
= body
.make_temp(type
, "rcp_scaled_t");
3866 body
.emit(assign(rcp_scaled_t
, rcp(mul(t
, scale
))));
3867 ir_expression
*s_over_t
= mul(mul(s
, scale
), rcp_scaled_t
);
3869 /* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily
3870 * that ∞/∞ = 1) in order to comply with the rather artificial rules
3871 * inherited from IEEE 754-2008, namely:
3873 * "atan2(±∞, −∞) is ±3π/4
3874 * atan2(±∞, +∞) is ±π/4"
3876 * Note that this is inconsistent with the rules for the neighborhood of
3877 * zero that are based on iterated limits:
3879 * "atan2(±0, −0) is ±π
3880 * atan2(±0, +0) is ±0"
3882 * but GLSL specifically allows implementations to deviate from IEEE rules
3883 * at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as
3886 ir_expression
*tan
= csel(equal(abs(x
), abs(y
)),
3887 imm(1.0f
, n
), abs(s_over_t
));
3889 /* Calculate the arctangent and fix up the result if we had flipped the
3890 * coordinate system.
3892 ir_variable
*arc
= body
.make_temp(type
, "arc");
3893 do_atan(body
, type
, arc
, tan
);
3894 body
.emit(assign(arc
, add(arc
, mul(b2f(flip
), imm(M_PI_2f
)))));
3896 /* Rather convoluted calculation of the sign of the result. When x < 0 we
3897 * cannot use fsign because we need to be able to distinguish between
3898 * negative and positive zero. Unfortunately we cannot use bitwise
3899 * arithmetic tricks either because of back-ends without integer support.
3900 * When x >= 0 rcp_scaled_t will always be non-negative so this won't be
3901 * able to distinguish between negative and positive zero, but we don't
3902 * care because atan2 is continuous along the whole positive y = 0
3903 * half-line, so it won't affect the result significantly.
3905 body
.emit(ret(csel(less(min2(y
, rcp_scaled_t
), imm(0.0f
, n
)),
3912 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3915 * range-reduction, first step:
3917 * / y_over_x if |y_over_x| <= 1.0;
3919 * \ 1.0 / y_over_x otherwise
3921 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3922 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3928 * approximate atan by evaluating polynomial:
3930 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3931 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3932 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3934 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3935 body
.emit(assign(tmp
, mul(x
, x
)));
3936 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3938 imm(0.0536813784310406f
)),
3940 imm(0.1173503194786851f
)),
3942 imm(0.1938924977115610f
)),
3944 imm(0.3326756418091246f
)),
3946 imm(0.9999793128310355f
)),
3949 /* range-reduction fixup */
3950 body
.emit(assign(tmp
, add(tmp
,
3951 mul(b2f(greater(abs(y_over_x
),
3952 imm(1.0f
, type
->components()))),
3958 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3961 ir_function_signature
*
3962 builtin_builder::_atan(const glsl_type
*type
)
3964 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3965 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3967 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3968 do_atan(body
, type
, tmp
, y_over_x
);
3969 body
.emit(ret(tmp
));
3974 ir_function_signature
*
3975 builtin_builder::_sinh(const glsl_type
*type
)
3977 ir_variable
*x
= in_var(type
, "x");
3978 MAKE_SIG(type
, v130
, 1, x
);
3980 /* 0.5 * (e^x - e^(-x)) */
3981 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3986 ir_function_signature
*
3987 builtin_builder::_cosh(const glsl_type
*type
)
3989 ir_variable
*x
= in_var(type
, "x");
3990 MAKE_SIG(type
, v130
, 1, x
);
3992 /* 0.5 * (e^x + e^(-x)) */
3993 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3998 ir_function_signature
*
3999 builtin_builder::_tanh(const glsl_type
*type
)
4001 ir_variable
*x
= in_var(type
, "x");
4002 MAKE_SIG(type
, v130
, 1, x
);
4004 /* tanh(x) := (0.5 * (e^x - e^(-x))) / (0.5 * (e^x + e^(-x)))
4006 * With a little algebra this reduces to (e^2x - 1) / (e^2x + 1)
4008 * Clamp x to (-inf, +10] to avoid precision problems. When x > 10, e^2x
4009 * is so much larger than 1.0 that 1.0 gets flushed to zero in the
4010 * computation e^2x +/- 1 so it can be ignored.
4012 ir_variable
*t
= body
.make_temp(type
, "tmp");
4013 body
.emit(assign(t
, min2(x
, imm(10.0f
))));
4015 body
.emit(ret(div(sub(exp(mul(t
, imm(2.0f
))), imm(1.0f
)),
4016 add(exp(mul(t
, imm(2.0f
))), imm(1.0f
)))));
4021 ir_function_signature
*
4022 builtin_builder::_asinh(const glsl_type
*type
)
4024 ir_variable
*x
= in_var(type
, "x");
4025 MAKE_SIG(type
, v130
, 1, x
);
4027 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
4032 ir_function_signature
*
4033 builtin_builder::_acosh(const glsl_type
*type
)
4035 ir_variable
*x
= in_var(type
, "x");
4036 MAKE_SIG(type
, v130
, 1, x
);
4038 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
4042 ir_function_signature
*
4043 builtin_builder::_atanh(const glsl_type
*type
)
4045 ir_variable
*x
= in_var(type
, "x");
4046 MAKE_SIG(type
, v130
, 1, x
);
4048 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
4049 sub(imm(1.0f
), x
))))));
4055 * Exponential Functions @{
4058 ir_function_signature
*
4059 builtin_builder::_pow(const glsl_type
*type
)
4061 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
4064 UNOP(exp
, ir_unop_exp
, always_available
)
4065 UNOP(log
, ir_unop_log
, always_available
)
4066 UNOP(exp2
, ir_unop_exp2
, always_available
)
4067 UNOP(log2
, ir_unop_log2
, always_available
)
4068 UNOPA(sqrt
, ir_unop_sqrt
)
4069 UNOPA(inversesqrt
, ir_unop_rsq
)
4073 UNOPA(abs
, ir_unop_abs
)
4074 UNOPA(sign
, ir_unop_sign
)
4075 UNOPA(floor
, ir_unop_floor
)
4076 UNOPA(trunc
, ir_unop_trunc
)
4077 UNOPA(round
, ir_unop_round_even
)
4078 UNOPA(roundEven
, ir_unop_round_even
)
4079 UNOPA(ceil
, ir_unop_ceil
)
4080 UNOPA(fract
, ir_unop_fract
)
4082 ir_function_signature
*
4083 builtin_builder::_mod(builtin_available_predicate avail
,
4084 const glsl_type
*x_type
, const glsl_type
*y_type
)
4086 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
4089 ir_function_signature
*
4090 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
4092 ir_variable
*x
= in_var(type
, "x");
4093 ir_variable
*i
= out_var(type
, "i");
4094 MAKE_SIG(type
, avail
, 2, x
, i
);
4096 ir_variable
*t
= body
.make_temp(type
, "t");
4097 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
4098 body
.emit(assign(i
, t
));
4099 body
.emit(ret(sub(x
, t
)));
4104 ir_function_signature
*
4105 builtin_builder::_min(builtin_available_predicate avail
,
4106 const glsl_type
*x_type
, const glsl_type
*y_type
)
4108 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
4111 ir_function_signature
*
4112 builtin_builder::_max(builtin_available_predicate avail
,
4113 const glsl_type
*x_type
, const glsl_type
*y_type
)
4115 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
4118 ir_function_signature
*
4119 builtin_builder::_clamp(builtin_available_predicate avail
,
4120 const glsl_type
*val_type
, const glsl_type
*bound_type
)
4122 ir_variable
*x
= in_var(val_type
, "x");
4123 ir_variable
*minVal
= in_var(bound_type
, "minVal");
4124 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
4125 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
4127 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
4132 ir_function_signature
*
4133 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
4135 ir_variable
*x
= in_var(val_type
, "x");
4136 ir_variable
*y
= in_var(val_type
, "y");
4137 ir_variable
*a
= in_var(blend_type
, "a");
4138 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4140 body
.emit(ret(lrp(x
, y
, a
)));
4145 ir_function_signature
*
4146 builtin_builder::_mix_sel(builtin_available_predicate avail
,
4147 const glsl_type
*val_type
,
4148 const glsl_type
*blend_type
)
4150 ir_variable
*x
= in_var(val_type
, "x");
4151 ir_variable
*y
= in_var(val_type
, "y");
4152 ir_variable
*a
= in_var(blend_type
, "a");
4153 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4155 /* csel matches the ternary operator in that a selector of true choses the
4156 * first argument. This differs from mix(x, y, false) which choses the
4157 * second argument (to remain consistent with the interpolating version of
4158 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
4160 * To handle the behavior mismatch, reverse the x and y arguments.
4162 body
.emit(ret(csel(a
, y
, x
)));
4167 ir_function_signature
*
4168 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4170 ir_variable
*edge
= in_var(edge_type
, "edge");
4171 ir_variable
*x
= in_var(x_type
, "x");
4172 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
4174 ir_variable
*t
= body
.make_temp(x_type
, "t");
4175 if (x_type
->vector_elements
== 1) {
4176 /* Both are floats */
4177 if (edge_type
->is_double())
4178 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
4180 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
4181 } else if (edge_type
->vector_elements
== 1) {
4182 /* x is a vector but edge is a float */
4183 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4184 if (edge_type
->is_double())
4185 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
4187 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
4190 /* Both are vectors */
4191 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4192 if (edge_type
->is_double())
4193 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
4196 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
4206 ir_function_signature
*
4207 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4209 ir_variable
*edge0
= in_var(edge_type
, "edge0");
4210 ir_variable
*edge1
= in_var(edge_type
, "edge1");
4211 ir_variable
*x
= in_var(x_type
, "x");
4212 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
4214 /* From the GLSL 1.10 specification:
4217 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
4218 * return t * t * (3 - 2 * t);
4221 ir_variable
*t
= body
.make_temp(x_type
, "t");
4222 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
4223 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
4225 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
4230 ir_function_signature
*
4231 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
4233 ir_variable
*x
= in_var(type
, "x");
4234 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4236 body
.emit(ret(nequal(x
, x
)));
4241 ir_function_signature
*
4242 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
4244 ir_variable
*x
= in_var(type
, "x");
4245 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4247 ir_constant_data infinities
;
4248 for (int i
= 0; i
< type
->vector_elements
; i
++) {
4249 switch (type
->base_type
) {
4250 case GLSL_TYPE_FLOAT
:
4251 infinities
.f
[i
] = INFINITY
;
4253 case GLSL_TYPE_DOUBLE
:
4254 infinities
.d
[i
] = INFINITY
;
4257 unreachable("unknown type");
4261 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
4266 ir_function_signature
*
4267 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
4269 ir_variable
*x
= in_var(type
, "x");
4270 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4271 body
.emit(ret(bitcast_f2i(x
)));
4275 ir_function_signature
*
4276 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
4278 ir_variable
*x
= in_var(type
, "x");
4279 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4280 body
.emit(ret(bitcast_f2u(x
)));
4284 ir_function_signature
*
4285 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
4287 ir_variable
*x
= in_var(type
, "x");
4288 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4289 body
.emit(ret(bitcast_i2f(x
)));
4293 ir_function_signature
*
4294 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
4296 ir_variable
*x
= in_var(type
, "x");
4297 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4298 body
.emit(ret(bitcast_u2f(x
)));
4302 ir_function_signature
*
4303 builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail
, const glsl_type
*type
)
4305 ir_variable
*x
= in_var(type
, "x");
4306 MAKE_SIG(glsl_type::i64vec(type
->vector_elements
), avail
, 1, x
);
4307 body
.emit(ret(bitcast_d2i64(x
)));
4311 ir_function_signature
*
4312 builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail
, const glsl_type
*type
)
4314 ir_variable
*x
= in_var(type
, "x");
4315 MAKE_SIG(glsl_type::u64vec(type
->vector_elements
), avail
, 1, x
);
4316 body
.emit(ret(bitcast_d2u64(x
)));
4320 ir_function_signature
*
4321 builtin_builder::_int64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4323 ir_variable
*x
= in_var(type
, "x");
4324 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4325 body
.emit(ret(bitcast_i642d(x
)));
4329 ir_function_signature
*
4330 builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4332 ir_variable
*x
= in_var(type
, "x");
4333 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4334 body
.emit(ret(bitcast_u642d(x
)));
4338 ir_function_signature
*
4339 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
4341 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4342 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4343 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
4347 ir_function_signature
*
4348 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
4350 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4351 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4352 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
4356 ir_function_signature
*
4357 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
4359 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4360 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4361 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
4365 ir_function_signature
*
4366 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
4368 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4369 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4370 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
4374 ir_function_signature
*
4375 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
4377 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4378 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4379 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
4383 ir_function_signature
*
4384 builtin_builder::_unpackSnorm2x16(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_snorm_2x16
, p
)));
4393 ir_function_signature
*
4394 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
4396 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4397 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4398 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
4402 ir_function_signature
*
4403 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
4405 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4406 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4407 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
4411 ir_function_signature
*
4412 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
4414 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4415 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4416 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
4420 ir_function_signature
*
4421 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
4423 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4424 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4425 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
4429 ir_function_signature
*
4430 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
4432 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4433 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
4434 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
4438 ir_function_signature
*
4439 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
4441 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
4442 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4443 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
4447 ir_function_signature
*
4448 builtin_builder::_packInt2x32(builtin_available_predicate avail
)
4450 ir_variable
*v
= in_var(glsl_type::ivec2_type
, "v");
4451 MAKE_SIG(glsl_type::int64_t_type
, avail
, 1, v
);
4452 body
.emit(ret(expr(ir_unop_pack_int_2x32
, v
)));
4456 ir_function_signature
*
4457 builtin_builder::_unpackInt2x32(builtin_available_predicate avail
)
4459 ir_variable
*p
= in_var(glsl_type::int64_t_type
, "p");
4460 MAKE_SIG(glsl_type::ivec2_type
, avail
, 1, p
);
4461 body
.emit(ret(expr(ir_unop_unpack_int_2x32
, p
)));
4465 ir_function_signature
*
4466 builtin_builder::_packUint2x32(builtin_available_predicate avail
)
4468 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4469 MAKE_SIG(glsl_type::uint64_t_type
, avail
, 1, v
);
4470 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, v
)));
4474 ir_function_signature
*
4475 builtin_builder::_unpackUint2x32(builtin_available_predicate avail
)
4477 ir_variable
*p
= in_var(glsl_type::uint64_t_type
, "p");
4478 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4479 body
.emit(ret(expr(ir_unop_unpack_uint_2x32
, p
)));
4483 ir_function_signature
*
4484 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
4486 ir_variable
*x
= in_var(type
, "x");
4487 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
4489 body
.emit(ret(sqrt(dot(x
, x
))));
4494 ir_function_signature
*
4495 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
4497 ir_variable
*p0
= in_var(type
, "p0");
4498 ir_variable
*p1
= in_var(type
, "p1");
4499 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
4501 if (type
->vector_elements
== 1) {
4502 body
.emit(ret(abs(sub(p0
, p1
))));
4504 ir_variable
*p
= body
.make_temp(type
, "p");
4505 body
.emit(assign(p
, sub(p0
, p1
)));
4506 body
.emit(ret(sqrt(dot(p
, p
))));
4512 ir_function_signature
*
4513 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
4515 if (type
->vector_elements
== 1)
4516 return binop(avail
, ir_binop_mul
, type
, type
, type
);
4518 return binop(avail
, ir_binop_dot
,
4519 type
->get_base_type(), type
, type
);
4522 ir_function_signature
*
4523 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
4525 ir_variable
*a
= in_var(type
, "a");
4526 ir_variable
*b
= in_var(type
, "b");
4527 MAKE_SIG(type
, avail
, 2, a
, b
);
4529 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
4530 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
4532 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
4533 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
4538 ir_function_signature
*
4539 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
4541 ir_variable
*x
= in_var(type
, "x");
4542 MAKE_SIG(type
, avail
, 1, x
);
4544 if (type
->vector_elements
== 1) {
4545 body
.emit(ret(sign(x
)));
4547 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
4553 ir_function_signature
*
4554 builtin_builder::_ftransform()
4556 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
4558 /* ftransform() refers to global variables, and is always emitted
4559 * directly by ast_function.cpp. Just emit a prototype here so we
4560 * can recognize calls to it.
4565 ir_function_signature
*
4566 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
4568 ir_variable
*N
= in_var(type
, "N");
4569 ir_variable
*I
= in_var(type
, "I");
4570 ir_variable
*Nref
= in_var(type
, "Nref");
4571 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
4573 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
4574 ret(N
), ret(neg(N
))));
4579 ir_function_signature
*
4580 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
4582 ir_variable
*I
= in_var(type
, "I");
4583 ir_variable
*N
= in_var(type
, "N");
4584 MAKE_SIG(type
, avail
, 2, I
, N
);
4586 /* I - 2 * dot(N, I) * N */
4587 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
4592 ir_function_signature
*
4593 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
4595 ir_variable
*I
= in_var(type
, "I");
4596 ir_variable
*N
= in_var(type
, "N");
4597 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
4598 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4600 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4601 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4603 /* From the GLSL 1.10 specification:
4604 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4606 * return genType(0.0)
4608 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4610 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4611 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4612 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4613 mul(n_dot_i
, n_dot_i
)))))));
4614 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4615 ret(ir_constant::zero(mem_ctx
, type
)),
4616 ret(sub(mul(eta
, I
),
4617 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4622 ir_function_signature
*
4623 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4625 ir_variable
*x
= in_var(type
, "x");
4626 ir_variable
*y
= in_var(type
, "y");
4627 MAKE_SIG(type
, avail
, 2, x
, y
);
4629 ir_variable
*z
= body
.make_temp(type
, "z");
4630 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4631 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4638 ir_function_signature
*
4639 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4644 if (type
->is_double()) {
4645 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4646 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4648 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4649 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4651 MAKE_SIG(type
, avail
, 2, c
, r
);
4653 ir_variable
*m
= body
.make_temp(type
, "m");
4654 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4655 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4662 ir_function_signature
*
4663 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4665 const glsl_type
*transpose_type
=
4666 glsl_type::get_instance(orig_type
->base_type
,
4667 orig_type
->matrix_columns
,
4668 orig_type
->vector_elements
);
4670 ir_variable
*m
= in_var(orig_type
, "m");
4671 MAKE_SIG(transpose_type
, avail
, 1, m
);
4673 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4674 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4675 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4676 body
.emit(assign(array_ref(t
, j
),
4677 matrix_elt(m
, i
, j
),
4686 ir_function_signature
*
4687 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4689 ir_variable
*m
= in_var(type
, "m");
4690 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4692 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4693 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4698 ir_function_signature
*
4699 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4701 ir_variable
*m
= in_var(type
, "m");
4702 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4705 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4706 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4709 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4710 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4713 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4714 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4716 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4717 mul(matrix_elt(m
, 0, 1), f2
)),
4718 mul(matrix_elt(m
, 0, 2), f3
))));
4723 ir_function_signature
*
4724 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4726 ir_variable
*m
= in_var(type
, "m");
4727 const glsl_type
*btype
= type
->get_base_type();
4728 MAKE_SIG(btype
, avail
, 1, m
);
4730 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4731 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4732 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4733 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4734 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4735 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4736 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4737 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4738 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4739 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4740 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4741 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4742 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4743 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4744 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4745 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4746 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4747 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4748 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4750 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)))));
4751 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)))));
4752 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)))));
4753 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)))));
4754 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)))));
4755 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)))));
4756 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)))));
4757 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)))));
4758 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)))));
4759 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)))));
4760 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)))));
4761 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)))));
4762 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)))));
4763 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)))));
4764 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)))));
4765 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)))));
4766 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)))));
4767 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)))));
4768 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)))));
4770 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4772 body
.emit(assign(adj_0
,
4773 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4774 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4775 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4777 body
.emit(assign(adj_0
, neg(
4778 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4779 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4780 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4782 body
.emit(assign(adj_0
,
4783 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4784 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4785 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4787 body
.emit(assign(adj_0
, neg(
4788 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4789 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4790 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4793 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4798 ir_function_signature
*
4799 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4801 ir_variable
*m
= in_var(type
, "m");
4802 MAKE_SIG(type
, avail
, 1, m
);
4804 ir_variable
*adj
= body
.make_temp(type
, "adj");
4805 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4806 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4807 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4808 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4810 ir_expression
*det
=
4811 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4812 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4814 body
.emit(ret(div(adj
, det
)));
4818 ir_function_signature
*
4819 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4821 ir_variable
*m
= in_var(type
, "m");
4822 const glsl_type
*btype
= type
->get_base_type();
4823 MAKE_SIG(type
, avail
, 1, m
);
4825 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4826 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4827 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4829 body
.emit(assign(f11_22_21_12
,
4830 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4831 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4832 body
.emit(assign(f10_22_20_12
,
4833 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4834 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4835 body
.emit(assign(f10_21_20_11
,
4836 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4837 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4839 ir_variable
*adj
= body
.make_temp(type
, "adj");
4840 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4841 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4842 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4844 body
.emit(assign(array_ref(adj
, 0), neg(
4845 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4846 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4848 body
.emit(assign(array_ref(adj
, 1),
4849 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4850 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4852 body
.emit(assign(array_ref(adj
, 2), neg(
4853 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4854 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4857 body
.emit(assign(array_ref(adj
, 0),
4858 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4859 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4861 body
.emit(assign(array_ref(adj
, 1), neg(
4862 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4863 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4865 body
.emit(assign(array_ref(adj
, 2),
4866 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4867 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4870 ir_expression
*det
=
4871 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4872 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4873 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4875 body
.emit(ret(div(adj
, det
)));
4880 ir_function_signature
*
4881 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4883 ir_variable
*m
= in_var(type
, "m");
4884 const glsl_type
*btype
= type
->get_base_type();
4885 MAKE_SIG(type
, avail
, 1, m
);
4887 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4888 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4889 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4890 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4891 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4892 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4893 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4894 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4895 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4896 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4897 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4898 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4899 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4900 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4901 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4902 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4903 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4904 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4905 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4907 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)))));
4908 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)))));
4909 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)))));
4910 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)))));
4911 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)))));
4912 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)))));
4913 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)))));
4914 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)))));
4915 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)))));
4916 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)))));
4917 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)))));
4918 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)))));
4919 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)))));
4920 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)))));
4921 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)))));
4922 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)))));
4923 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)))));
4924 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)))));
4925 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)))));
4927 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4928 body
.emit(assign(array_ref(adj
, 0),
4929 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4930 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4931 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4933 body
.emit(assign(array_ref(adj
, 1), neg(
4934 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4935 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4936 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4938 body
.emit(assign(array_ref(adj
, 2),
4939 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4940 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4941 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4943 body
.emit(assign(array_ref(adj
, 3), neg(
4944 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4945 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4946 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4949 body
.emit(assign(array_ref(adj
, 0), neg(
4950 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4951 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4952 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4954 body
.emit(assign(array_ref(adj
, 1),
4955 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4956 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4957 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4959 body
.emit(assign(array_ref(adj
, 2), neg(
4960 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4961 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4962 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4964 body
.emit(assign(array_ref(adj
, 3),
4965 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4966 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4967 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4970 body
.emit(assign(array_ref(adj
, 0),
4971 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4972 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4973 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4975 body
.emit(assign(array_ref(adj
, 1), neg(
4976 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4977 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4978 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4980 body
.emit(assign(array_ref(adj
, 2),
4981 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4982 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4983 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4985 body
.emit(assign(array_ref(adj
, 3), neg(
4986 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4987 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4988 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4991 body
.emit(assign(array_ref(adj
, 0), neg(
4992 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4993 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4994 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4996 body
.emit(assign(array_ref(adj
, 1),
4997 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4998 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4999 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
5001 body
.emit(assign(array_ref(adj
, 2), neg(
5002 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
5003 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
5004 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
5006 body
.emit(assign(array_ref(adj
, 3),
5007 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
5008 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
5009 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
5012 ir_expression
*det
=
5013 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
5014 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
5015 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
5016 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
5018 body
.emit(ret(div(adj
, det
)));
5024 ir_function_signature
*
5025 builtin_builder::_lessThan(builtin_available_predicate avail
,
5026 const glsl_type
*type
)
5028 return binop(avail
, ir_binop_less
,
5029 glsl_type::bvec(type
->vector_elements
), type
, type
);
5032 ir_function_signature
*
5033 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
5034 const glsl_type
*type
)
5036 return binop(avail
, ir_binop_gequal
,
5037 glsl_type::bvec(type
->vector_elements
), type
, type
,
5041 ir_function_signature
*
5042 builtin_builder::_greaterThan(builtin_available_predicate avail
,
5043 const glsl_type
*type
)
5045 return binop(avail
, ir_binop_less
,
5046 glsl_type::bvec(type
->vector_elements
), type
, type
,
5050 ir_function_signature
*
5051 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
5052 const glsl_type
*type
)
5054 return binop(avail
, ir_binop_gequal
,
5055 glsl_type::bvec(type
->vector_elements
), type
, type
);
5058 ir_function_signature
*
5059 builtin_builder::_equal(builtin_available_predicate avail
,
5060 const glsl_type
*type
)
5062 return binop(avail
, ir_binop_equal
,
5063 glsl_type::bvec(type
->vector_elements
), type
, type
);
5066 ir_function_signature
*
5067 builtin_builder::_notEqual(builtin_available_predicate avail
,
5068 const glsl_type
*type
)
5070 return binop(avail
, ir_binop_nequal
,
5071 glsl_type::bvec(type
->vector_elements
), type
, type
);
5074 ir_function_signature
*
5075 builtin_builder::_any(const glsl_type
*type
)
5077 ir_variable
*v
= in_var(type
, "v");
5078 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5080 const unsigned vec_elem
= v
->type
->vector_elements
;
5081 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
5086 ir_function_signature
*
5087 builtin_builder::_all(const glsl_type
*type
)
5089 ir_variable
*v
= in_var(type
, "v");
5090 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5092 const unsigned vec_elem
= v
->type
->vector_elements
;
5093 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
5098 UNOP(not, ir_unop_logic_not
, always_available
)
5101 has_lod(const glsl_type
*sampler_type
)
5103 assert(sampler_type
->is_sampler());
5105 switch (sampler_type
->sampler_dimensionality
) {
5106 case GLSL_SAMPLER_DIM_RECT
:
5107 case GLSL_SAMPLER_DIM_BUF
:
5108 case GLSL_SAMPLER_DIM_MS
:
5115 ir_function_signature
*
5116 builtin_builder::_textureSize(builtin_available_predicate avail
,
5117 const glsl_type
*return_type
,
5118 const glsl_type
*sampler_type
)
5120 ir_variable
*s
= in_var(sampler_type
, "sampler");
5121 /* The sampler always exists; add optional lod later. */
5122 MAKE_SIG(return_type
, avail
, 1, s
);
5124 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
5125 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
5127 if (has_lod(sampler_type
)) {
5128 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5129 sig
->parameters
.push_tail(lod
);
5130 tex
->lod_info
.lod
= var_ref(lod
);
5132 tex
->lod_info
.lod
= imm(0u);
5135 body
.emit(ret(tex
));
5140 ir_function_signature
*
5141 builtin_builder::_textureSamples(builtin_available_predicate avail
,
5142 const glsl_type
*sampler_type
)
5144 ir_variable
*s
= in_var(sampler_type
, "sampler");
5145 MAKE_SIG(glsl_type::int_type
, avail
, 1, s
);
5147 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
5148 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
5149 body
.emit(ret(tex
));
5154 ir_function_signature
*
5155 builtin_builder::_texture(ir_texture_opcode opcode
,
5156 builtin_available_predicate avail
,
5157 const glsl_type
*return_type
,
5158 const glsl_type
*sampler_type
,
5159 const glsl_type
*coord_type
,
5162 ir_variable
*s
= in_var(sampler_type
, "sampler");
5163 ir_variable
*P
= in_var(coord_type
, "P");
5164 /* The sampler and coordinate always exist; add optional parameters later. */
5165 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5167 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
5168 tex
->set_sampler(var_ref(s
), return_type
);
5170 const int coord_size
= sampler_type
->coordinate_components();
5172 if (coord_size
== coord_type
->vector_elements
) {
5173 tex
->coordinate
= var_ref(P
);
5175 /* The incoming coordinate also has the projector or shadow comparator,
5176 * so we need to swizzle those away.
5178 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
5181 /* The projector is always in the last component. */
5182 if (flags
& TEX_PROJECT
)
5183 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
5185 if (sampler_type
->sampler_shadow
) {
5186 if (opcode
== ir_tg4
) {
5187 /* gather has refz as a separate parameter, immediately after the
5190 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
5191 sig
->parameters
.push_tail(refz
);
5192 tex
->shadow_comparator
= var_ref(refz
);
5194 /* The shadow comparator is normally in the Z component, but a few types
5195 * have sufficiently large coordinates that it's in W.
5197 tex
->shadow_comparator
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
5201 if (opcode
== ir_txl
) {
5202 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
5203 sig
->parameters
.push_tail(lod
);
5204 tex
->lod_info
.lod
= var_ref(lod
);
5205 } else if (opcode
== ir_txd
) {
5206 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5207 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
5208 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
5209 sig
->parameters
.push_tail(dPdx
);
5210 sig
->parameters
.push_tail(dPdy
);
5211 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
5212 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
5215 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
5216 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5217 ir_variable
*offset
=
5218 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
5219 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
5220 sig
->parameters
.push_tail(offset
);
5221 tex
->offset
= var_ref(offset
);
5224 if (flags
& TEX_OFFSET_ARRAY
) {
5225 ir_variable
*offsets
=
5226 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
5227 "offsets", ir_var_const_in
);
5228 sig
->parameters
.push_tail(offsets
);
5229 tex
->offset
= var_ref(offsets
);
5232 if (opcode
== ir_tg4
) {
5233 if (flags
& TEX_COMPONENT
) {
5234 ir_variable
*component
=
5235 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
5236 sig
->parameters
.push_tail(component
);
5237 tex
->lod_info
.component
= var_ref(component
);
5240 tex
->lod_info
.component
= imm(0);
5244 /* The "bias" parameter comes /after/ the "offset" parameter, which is
5245 * inconsistent with both textureLodOffset and textureGradOffset.
5247 if (opcode
== ir_txb
) {
5248 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
5249 sig
->parameters
.push_tail(bias
);
5250 tex
->lod_info
.bias
= var_ref(bias
);
5253 body
.emit(ret(tex
));
5258 ir_function_signature
*
5259 builtin_builder::_textureCubeArrayShadow(builtin_available_predicate avail
,
5260 const glsl_type
*sampler_type
)
5262 ir_variable
*s
= in_var(sampler_type
, "sampler");
5263 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
5264 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
5265 MAKE_SIG(glsl_type::float_type
, avail
, 3, s
, P
, compare
);
5267 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
5268 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
5270 tex
->coordinate
= var_ref(P
);
5271 tex
->shadow_comparator
= var_ref(compare
);
5273 body
.emit(ret(tex
));
5278 ir_function_signature
*
5279 builtin_builder::_texelFetch(builtin_available_predicate avail
,
5280 const glsl_type
*return_type
,
5281 const glsl_type
*sampler_type
,
5282 const glsl_type
*coord_type
,
5283 const glsl_type
*offset_type
)
5285 ir_variable
*s
= in_var(sampler_type
, "sampler");
5286 ir_variable
*P
= in_var(coord_type
, "P");
5287 /* The sampler and coordinate always exist; add optional parameters later. */
5288 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5290 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
5291 tex
->coordinate
= var_ref(P
);
5292 tex
->set_sampler(var_ref(s
), return_type
);
5294 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
5295 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
5296 sig
->parameters
.push_tail(sample
);
5297 tex
->lod_info
.sample_index
= var_ref(sample
);
5298 tex
->op
= ir_txf_ms
;
5299 } else if (has_lod(sampler_type
)) {
5300 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5301 sig
->parameters
.push_tail(lod
);
5302 tex
->lod_info
.lod
= var_ref(lod
);
5304 tex
->lod_info
.lod
= imm(0u);
5307 if (offset_type
!= NULL
) {
5308 ir_variable
*offset
=
5309 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
5310 sig
->parameters
.push_tail(offset
);
5311 tex
->offset
= var_ref(offset
);
5314 body
.emit(ret(tex
));
5319 ir_function_signature
*
5320 builtin_builder::_EmitVertex()
5322 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5324 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5325 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
5330 ir_function_signature
*
5331 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
5332 const glsl_type
*stream_type
)
5334 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5336 * "Emit the current values of output variables to the current output
5337 * primitive on stream stream. The argument to stream must be a constant
5338 * integral expression."
5340 ir_variable
*stream
=
5341 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5343 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5345 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
5350 ir_function_signature
*
5351 builtin_builder::_EndPrimitive()
5353 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5355 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5356 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
5361 ir_function_signature
*
5362 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
5363 const glsl_type
*stream_type
)
5365 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5367 * "Completes the current output primitive on stream stream and starts
5368 * a new one. The argument to stream must be a constant integral
5371 ir_variable
*stream
=
5372 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5374 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5376 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
5381 ir_function_signature
*
5382 builtin_builder::_barrier()
5384 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
5386 body
.emit(new(mem_ctx
) ir_barrier());
5390 ir_function_signature
*
5391 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
5392 const glsl_type
*sampler_type
,
5393 const glsl_type
*coord_type
)
5395 ir_variable
*s
= in_var(sampler_type
, "sampler");
5396 ir_variable
*coord
= in_var(coord_type
, "coord");
5397 /* The sampler and coordinate always exist; add optional parameters later. */
5398 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
5400 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
5401 tex
->coordinate
= var_ref(coord
);
5402 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
5404 body
.emit(ret(tex
));
5409 ir_function_signature
*
5410 builtin_builder::_textureQueryLevels(builtin_available_predicate avail
,
5411 const glsl_type
*sampler_type
)
5413 ir_variable
*s
= in_var(sampler_type
, "sampler");
5414 const glsl_type
*return_type
= glsl_type::int_type
;
5415 MAKE_SIG(return_type
, avail
, 1, s
);
5417 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
5418 tex
->set_sampler(var_ref(s
), return_type
);
5420 body
.emit(ret(tex
));
5425 ir_function_signature
*
5426 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
5427 const glsl_type
*sampler_type
,
5428 const glsl_type
*coord_type
)
5430 ir_variable
*s
= in_var(sampler_type
, "sampler");
5431 ir_variable
*P
= in_var(coord_type
, "P");
5432 const glsl_type
*return_type
= glsl_type::bool_type
;
5433 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5435 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
5436 tex
->coordinate
= var_ref(P
);
5437 tex
->set_sampler(var_ref(s
), return_type
);
5439 body
.emit(ret(tex
));
5444 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
5445 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
5446 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
5447 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
5448 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
5449 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
5451 ir_function_signature
*
5452 builtin_builder::_fwidth(const glsl_type
*type
)
5454 ir_variable
*p
= in_var(type
, "p");
5455 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
5457 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
5462 ir_function_signature
*
5463 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
5465 ir_variable
*p
= in_var(type
, "p");
5466 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5468 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
5469 abs(expr(ir_unop_dFdy_coarse
, p
)))));
5474 ir_function_signature
*
5475 builtin_builder::_fwidthFine(const glsl_type
*type
)
5477 ir_variable
*p
= in_var(type
, "p");
5478 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5480 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
5481 abs(expr(ir_unop_dFdy_fine
, p
)))));
5486 ir_function_signature
*
5487 builtin_builder::_noise1(const glsl_type
*type
)
5489 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
5492 ir_function_signature
*
5493 builtin_builder::_noise2(const glsl_type
*type
)
5495 ir_variable
*p
= in_var(type
, "p");
5496 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
5498 ir_constant_data b_offset
;
5499 b_offset
.f
[0] = 601.0f
;
5500 b_offset
.f
[1] = 313.0f
;
5501 b_offset
.f
[2] = 29.0f
;
5502 b_offset
.f
[3] = 277.0f
;
5504 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5505 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5506 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
5507 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5508 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5509 body
.emit(assign(t
, a
, WRITEMASK_X
));
5510 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5516 ir_function_signature
*
5517 builtin_builder::_noise3(const glsl_type
*type
)
5519 ir_variable
*p
= in_var(type
, "p");
5520 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
5522 ir_constant_data b_offset
;
5523 b_offset
.f
[0] = 601.0f
;
5524 b_offset
.f
[1] = 313.0f
;
5525 b_offset
.f
[2] = 29.0f
;
5526 b_offset
.f
[3] = 277.0f
;
5528 ir_constant_data c_offset
;
5529 c_offset
.f
[0] = 1559.0f
;
5530 c_offset
.f
[1] = 113.0f
;
5531 c_offset
.f
[2] = 1861.0f
;
5532 c_offset
.f
[3] = 797.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
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
5538 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5539 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5540 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
5541 body
.emit(assign(t
, a
, WRITEMASK_X
));
5542 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5543 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5549 ir_function_signature
*
5550 builtin_builder::_noise4(const glsl_type
*type
)
5552 ir_variable
*p
= in_var(type
, "p");
5553 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
5555 ir_variable
*_p
= body
.make_temp(type
, "_p");
5557 ir_constant_data p_offset
;
5558 p_offset
.f
[0] = 1559.0f
;
5559 p_offset
.f
[1] = 113.0f
;
5560 p_offset
.f
[2] = 1861.0f
;
5561 p_offset
.f
[3] = 797.0f
;
5563 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
5565 ir_constant_data offset
;
5566 offset
.f
[0] = 601.0f
;
5567 offset
.f
[1] = 313.0f
;
5568 offset
.f
[2] = 29.0f
;
5569 offset
.f
[3] = 277.0f
;
5571 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5572 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5573 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5574 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
5575 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
5576 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5577 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
5578 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
5579 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
5580 body
.emit(assign(t
, a
, WRITEMASK_X
));
5581 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5582 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5583 body
.emit(assign(t
, d
, WRITEMASK_W
));
5589 ir_function_signature
*
5590 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
5592 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5593 ir_variable
*value
= in_var(type
, "value");
5594 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5595 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5596 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, value
, offset
,
5599 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5600 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5602 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
5603 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5604 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5609 ir_function_signature
*
5610 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5612 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5613 ir_variable
*base
= in_var(type
, "base");
5614 ir_variable
*insert
= in_var(type
, "insert");
5615 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5616 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5617 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 4, base
, insert
,
5620 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5621 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5623 body
.emit(ret(bitfield_insert(base
, insert
,
5624 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5625 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5630 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31_or_integer_functions
)
5632 ir_function_signature
*
5633 builtin_builder::_bitCount(const glsl_type
*type
)
5635 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_bit_count
,
5636 glsl_type::ivec(type
->vector_elements
), type
);
5639 ir_function_signature
*
5640 builtin_builder::_findLSB(const glsl_type
*type
)
5642 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_lsb
,
5643 glsl_type::ivec(type
->vector_elements
), type
);
5646 ir_function_signature
*
5647 builtin_builder::_findMSB(const glsl_type
*type
)
5649 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_msb
,
5650 glsl_type::ivec(type
->vector_elements
), type
);
5653 ir_function_signature
*
5654 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5656 ir_variable
*a
= in_var(type
, "a");
5657 ir_variable
*b
= in_var(type
, "b");
5658 ir_variable
*c
= in_var(type
, "c");
5659 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5661 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5666 ir_function_signature
*
5667 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5669 return binop(x_type
->is_double() ? fp64
: gpu_shader5_or_es31_or_integer_functions
,
5670 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5673 ir_function_signature
*
5674 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5676 ir_variable
*x
= in_var(x_type
, "x");
5677 ir_variable
*exponent
= out_var(exp_type
, "exp");
5678 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5680 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5682 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5686 ir_function_signature
*
5687 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5689 ir_variable
*x
= in_var(x_type
, "x");
5690 ir_variable
*exponent
= out_var(exp_type
, "exp");
5691 MAKE_SIG(x_type
, gpu_shader5_or_es31_or_integer_functions
, 2, x
, exponent
);
5693 const unsigned vec_elem
= x_type
->vector_elements
;
5694 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5695 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5697 /* Single-precision floating-point values are stored as
5702 * An exponent shift of 23 will shift the mantissa out, leaving only the
5703 * exponent and sign bit (which itself may be zero, if the absolute value
5704 * was taken before the bitcast and shift.
5706 ir_constant
*exponent_shift
= imm(23);
5707 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5709 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5711 /* Exponent of floating-point values in the range [0.5, 1.0). */
5712 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5714 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5715 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5717 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5718 * to unsigned integers to ensure that 1 bits aren't shifted in.
5720 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5721 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5722 imm(0, vec_elem
)))));
5724 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5725 body
.emit(assign(bits
, bitcast_f2u(x
)));
5726 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5727 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5728 imm(0u, vec_elem
)))));
5729 body
.emit(ret(bitcast_u2f(bits
)));
5734 ir_function_signature
*
5735 builtin_builder::_uaddCarry(const glsl_type
*type
)
5737 ir_variable
*x
= in_var(type
, "x");
5738 ir_variable
*y
= in_var(type
, "y");
5739 ir_variable
*carry
= out_var(type
, "carry");
5740 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, carry
);
5742 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5743 body
.emit(ret(add(x
, y
)));
5748 ir_function_signature
*
5749 builtin_builder::_usubBorrow(const glsl_type
*type
)
5751 ir_variable
*x
= in_var(type
, "x");
5752 ir_variable
*y
= in_var(type
, "y");
5753 ir_variable
*borrow
= out_var(type
, "borrow");
5754 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, borrow
);
5756 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5757 body
.emit(ret(sub(x
, y
)));
5763 * For both imulExtended() and umulExtended() built-ins.
5765 ir_function_signature
*
5766 builtin_builder::_mulExtended(const glsl_type
*type
)
5768 ir_variable
*x
= in_var(type
, "x");
5769 ir_variable
*y
= in_var(type
, "y");
5770 ir_variable
*msb
= out_var(type
, "msb");
5771 ir_variable
*lsb
= out_var(type
, "lsb");
5772 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31_or_integer_functions
, 4, x
, y
, msb
, lsb
);
5774 body
.emit(assign(msb
, imul_high(x
, y
)));
5775 body
.emit(assign(lsb
, mul(x
, y
)));
5780 ir_function_signature
*
5781 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5783 ir_variable
*interpolant
= in_var(type
, "interpolant");
5784 interpolant
->data
.must_be_shader_input
= 1;
5785 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5787 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5792 ir_function_signature
*
5793 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5795 ir_variable
*interpolant
= in_var(type
, "interpolant");
5796 interpolant
->data
.must_be_shader_input
= 1;
5797 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5798 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5800 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5805 ir_function_signature
*
5806 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5808 ir_variable
*interpolant
= in_var(type
, "interpolant");
5809 interpolant
->data
.must_be_shader_input
= 1;
5810 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5811 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5813 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5818 ir_function_signature
*
5819 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
,
5820 enum ir_intrinsic_id id
)
5822 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5823 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 1, counter
);
5827 ir_function_signature
*
5828 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
,
5829 enum ir_intrinsic_id id
)
5831 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5832 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5833 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 2, counter
, data
);
5837 ir_function_signature
*
5838 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
,
5839 enum ir_intrinsic_id id
)
5841 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5842 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5843 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5844 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 3, counter
, compare
, data
);
5848 ir_function_signature
*
5849 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5850 const glsl_type
*type
,
5851 enum ir_intrinsic_id id
)
5853 ir_variable
*atomic
= in_var(type
, "atomic");
5854 ir_variable
*data
= in_var(type
, "data");
5855 MAKE_INTRINSIC(type
, id
, avail
, 2, atomic
, data
);
5859 ir_function_signature
*
5860 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5861 const glsl_type
*type
,
5862 enum ir_intrinsic_id id
)
5864 ir_variable
*atomic
= in_var(type
, "atomic");
5865 ir_variable
*data1
= in_var(type
, "data1");
5866 ir_variable
*data2
= in_var(type
, "data2");
5867 MAKE_INTRINSIC(type
, id
, avail
, 3, atomic
, data1
, data2
);
5871 ir_function_signature
*
5872 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5873 builtin_available_predicate avail
)
5875 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5876 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5878 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5879 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5881 body
.emit(ret(retval
));
5885 ir_function_signature
*
5886 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5887 builtin_available_predicate avail
)
5889 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5890 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5891 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5893 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5895 /* Instead of generating an __intrinsic_atomic_sub, generate an
5896 * __intrinsic_atomic_add with the data parameter negated.
5898 if (strcmp("__intrinsic_atomic_sub", intrinsic
) == 0) {
5899 ir_variable
*const neg_data
=
5900 body
.make_temp(glsl_type::uint_type
, "neg_data");
5902 body
.emit(assign(neg_data
, neg(data
)));
5904 exec_list parameters
;
5906 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(counter
));
5907 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(neg_data
));
5909 ir_function
*const func
=
5910 shader
->symbols
->get_function("__intrinsic_atomic_add");
5911 ir_instruction
*const c
= call(func
, retval
, parameters
);
5914 assert(parameters
.is_empty());
5918 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5922 body
.emit(ret(retval
));
5926 ir_function_signature
*
5927 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
5928 builtin_available_predicate avail
)
5930 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5931 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5932 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5933 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5935 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5936 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5938 body
.emit(ret(retval
));
5942 ir_function_signature
*
5943 builtin_builder::_atomic_op2(const char *intrinsic
,
5944 builtin_available_predicate avail
,
5945 const glsl_type
*type
)
5947 ir_variable
*atomic
= in_var(type
, "atomic_var");
5948 ir_variable
*data
= in_var(type
, "atomic_data");
5949 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5951 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5952 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5954 body
.emit(ret(retval
));
5958 ir_function_signature
*
5959 builtin_builder::_atomic_op3(const char *intrinsic
,
5960 builtin_available_predicate avail
,
5961 const glsl_type
*type
)
5963 ir_variable
*atomic
= in_var(type
, "atomic_var");
5964 ir_variable
*data1
= in_var(type
, "atomic_data1");
5965 ir_variable
*data2
= in_var(type
, "atomic_data2");
5966 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5968 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5969 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5971 body
.emit(ret(retval
));
5975 ir_function_signature
*
5976 builtin_builder::_min3(const glsl_type
*type
)
5978 ir_variable
*x
= in_var(type
, "x");
5979 ir_variable
*y
= in_var(type
, "y");
5980 ir_variable
*z
= in_var(type
, "z");
5981 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5983 ir_expression
*min3
= min2(x
, min2(y
,z
));
5984 body
.emit(ret(min3
));
5989 ir_function_signature
*
5990 builtin_builder::_max3(const glsl_type
*type
)
5992 ir_variable
*x
= in_var(type
, "x");
5993 ir_variable
*y
= in_var(type
, "y");
5994 ir_variable
*z
= in_var(type
, "z");
5995 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5997 ir_expression
*max3
= max2(x
, max2(y
,z
));
5998 body
.emit(ret(max3
));
6003 ir_function_signature
*
6004 builtin_builder::_mid3(const glsl_type
*type
)
6006 ir_variable
*x
= in_var(type
, "x");
6007 ir_variable
*y
= in_var(type
, "y");
6008 ir_variable
*z
= in_var(type
, "z");
6009 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
6011 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
6012 body
.emit(ret(mid3
));
6017 static builtin_available_predicate
6018 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
6020 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
6021 type
->sampled_type
== GLSL_TYPE_FLOAT
)
6022 return shader_image_atomic_exchange_float
;
6024 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
6025 IMAGE_FUNCTION_AVAIL_ATOMIC
))
6026 return shader_image_atomic
;
6029 return shader_image_load_store
;
6032 ir_function_signature
*
6033 builtin_builder::_image_prototype(const glsl_type
*image_type
,
6034 unsigned num_arguments
,
6037 const glsl_type
*data_type
= glsl_type::get_instance(
6038 image_type
->sampled_type
,
6039 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
6041 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
6042 glsl_type::void_type
: data_type
);
6044 /* Addressing arguments that are always present. */
6045 ir_variable
*image
= in_var(image_type
, "image");
6046 ir_variable
*coord
= in_var(
6047 glsl_type::ivec(image_type
->coordinate_components()), "coord");
6049 ir_function_signature
*sig
= new_sig(
6050 ret_type
, get_image_available_predicate(image_type
, flags
),
6053 /* Sample index for multisample images. */
6054 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
6055 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
6057 /* Data arguments. */
6058 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
6059 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
6060 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
6061 ralloc_free(arg_name
);
6064 /* Set the maximal set of qualifiers allowed for this image
6065 * built-in. Function calls with arguments having fewer
6066 * qualifiers than present in the prototype are allowed by the
6067 * spec, but not with more, i.e. this will make the compiler
6068 * accept everything that needs to be accepted, and reject cases
6069 * like loads from write-only or stores to read-only images.
6071 image
->data
.memory_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
6072 image
->data
.memory_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
6073 image
->data
.memory_coherent
= true;
6074 image
->data
.memory_volatile
= true;
6075 image
->data
.memory_restrict
= true;
6080 ir_function_signature
*
6081 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
6082 unsigned /* num_arguments */,
6083 unsigned /* flags */)
6085 const glsl_type
*ret_type
;
6086 unsigned num_components
= image_type
->coordinate_components();
6088 /* From the ARB_shader_image_size extension:
6089 * "Cube images return the dimensions of one face."
6091 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
6092 !image_type
->sampler_array
) {
6096 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
6097 * supported by mesa.
6099 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
6101 ir_variable
*image
= in_var(image_type
, "image");
6102 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
6104 /* Set the maximal set of qualifiers allowed for this image
6105 * built-in. Function calls with arguments having fewer
6106 * qualifiers than present in the prototype are allowed by the
6107 * spec, but not with more, i.e. this will make the compiler
6108 * accept everything that needs to be accepted, and reject cases
6109 * like loads from write-only or stores to read-only images.
6111 image
->data
.memory_read_only
= true;
6112 image
->data
.memory_write_only
= true;
6113 image
->data
.memory_coherent
= true;
6114 image
->data
.memory_volatile
= true;
6115 image
->data
.memory_restrict
= true;
6120 ir_function_signature
*
6121 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
6122 unsigned /* num_arguments */,
6123 unsigned /* flags */)
6125 ir_variable
*image
= in_var(image_type
, "image");
6126 ir_function_signature
*sig
=
6127 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
6129 /* Set the maximal set of qualifiers allowed for this image
6130 * built-in. Function calls with arguments having fewer
6131 * qualifiers than present in the prototype are allowed by the
6132 * spec, but not with more, i.e. this will make the compiler
6133 * accept everything that needs to be accepted, and reject cases
6134 * like loads from write-only or stores to read-only images.
6136 image
->data
.memory_read_only
= true;
6137 image
->data
.memory_write_only
= true;
6138 image
->data
.memory_coherent
= true;
6139 image
->data
.memory_volatile
= true;
6140 image
->data
.memory_restrict
= true;
6145 ir_function_signature
*
6146 builtin_builder::_image(image_prototype_ctr prototype
,
6147 const glsl_type
*image_type
,
6148 const char *intrinsic_name
,
6149 unsigned num_arguments
,
6151 enum ir_intrinsic_id id
)
6153 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
6154 num_arguments
, flags
);
6156 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
6157 ir_factory
body(&sig
->body
, mem_ctx
);
6158 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
6160 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
6161 body
.emit(call(f
, NULL
, sig
->parameters
));
6163 ir_variable
*ret_val
=
6164 body
.make_temp(sig
->return_type
, "_ret_val");
6165 body
.emit(call(f
, ret_val
, sig
->parameters
));
6166 body
.emit(ret(ret_val
));
6169 sig
->is_defined
= true;
6172 sig
->intrinsic_id
= id
;
6178 ir_function_signature
*
6179 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
,
6180 enum ir_intrinsic_id id
)
6182 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6186 ir_function_signature
*
6187 builtin_builder::_memory_barrier(const char *intrinsic_name
,
6188 builtin_available_predicate avail
)
6190 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6191 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6192 NULL
, sig
->parameters
));
6196 ir_function_signature
*
6197 builtin_builder::_ballot_intrinsic()
6199 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6200 MAKE_INTRINSIC(glsl_type::uint64_t_type
, ir_intrinsic_ballot
, shader_ballot
,
6205 ir_function_signature
*
6206 builtin_builder::_ballot()
6208 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6210 MAKE_SIG(glsl_type::uint64_t_type
, shader_ballot
, 1, value
);
6211 ir_variable
*retval
= body
.make_temp(glsl_type::uint64_t_type
, "retval");
6213 body
.emit(call(shader
->symbols
->get_function("__intrinsic_ballot"),
6214 retval
, sig
->parameters
));
6215 body
.emit(ret(retval
));
6219 ir_function_signature
*
6220 builtin_builder::_read_first_invocation_intrinsic(const glsl_type
*type
)
6222 ir_variable
*value
= in_var(type
, "value");
6223 MAKE_INTRINSIC(type
, ir_intrinsic_read_first_invocation
, shader_ballot
,
6228 ir_function_signature
*
6229 builtin_builder::_read_first_invocation(const glsl_type
*type
)
6231 ir_variable
*value
= in_var(type
, "value");
6233 MAKE_SIG(type
, shader_ballot
, 1, value
);
6234 ir_variable
*retval
= body
.make_temp(type
, "retval");
6236 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_first_invocation"),
6237 retval
, sig
->parameters
));
6238 body
.emit(ret(retval
));
6242 ir_function_signature
*
6243 builtin_builder::_read_invocation_intrinsic(const glsl_type
*type
)
6245 ir_variable
*value
= in_var(type
, "value");
6246 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6247 MAKE_INTRINSIC(type
, ir_intrinsic_read_invocation
, shader_ballot
,
6248 2, value
, invocation
);
6252 ir_function_signature
*
6253 builtin_builder::_read_invocation(const glsl_type
*type
)
6255 ir_variable
*value
= in_var(type
, "value");
6256 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6258 MAKE_SIG(type
, shader_ballot
, 2, value
, invocation
);
6259 ir_variable
*retval
= body
.make_temp(type
, "retval");
6261 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_invocation"),
6262 retval
, sig
->parameters
));
6263 body
.emit(ret(retval
));
6267 ir_function_signature
*
6268 builtin_builder::_invocation_interlock_intrinsic(builtin_available_predicate avail
,
6269 enum ir_intrinsic_id id
)
6271 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6275 ir_function_signature
*
6276 builtin_builder::_invocation_interlock(const char *intrinsic_name
,
6277 builtin_available_predicate avail
)
6279 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6280 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6281 NULL
, sig
->parameters
));
6285 ir_function_signature
*
6286 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
6287 const glsl_type
*type
)
6289 MAKE_INTRINSIC(type
, ir_intrinsic_shader_clock
, avail
, 0);
6293 ir_function_signature
*
6294 builtin_builder::_shader_clock(builtin_available_predicate avail
,
6295 const glsl_type
*type
)
6297 MAKE_SIG(type
, avail
, 0);
6299 ir_variable
*retval
= body
.make_temp(glsl_type::uvec2_type
, "clock_retval");
6301 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
6302 retval
, sig
->parameters
));
6304 if (type
== glsl_type::uint64_t_type
) {
6305 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, retval
)));
6307 body
.emit(ret(retval
));
6313 ir_function_signature
*
6314 builtin_builder::_vote_intrinsic(builtin_available_predicate avail
,
6315 enum ir_intrinsic_id id
)
6317 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6318 MAKE_INTRINSIC(glsl_type::bool_type
, id
, avail
, 1, value
);
6322 ir_function_signature
*
6323 builtin_builder::_vote(const char *intrinsic_name
,
6324 builtin_available_predicate avail
)
6326 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6328 MAKE_SIG(glsl_type::bool_type
, avail
, 1, value
);
6330 ir_variable
*retval
= body
.make_temp(glsl_type::bool_type
, "retval");
6332 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6333 retval
, sig
->parameters
));
6334 body
.emit(ret(retval
));
6340 /******************************************************************************/
6342 /* The singleton instance of builtin_builder. */
6343 static builtin_builder builtins
;
6344 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
6347 * External API (exposing the built-in module to the rest of the compiler):
6351 _mesa_glsl_initialize_builtin_functions()
6353 mtx_lock(&builtins_lock
);
6354 builtins
.initialize();
6355 mtx_unlock(&builtins_lock
);
6359 _mesa_glsl_release_builtin_functions()
6361 mtx_lock(&builtins_lock
);
6363 mtx_unlock(&builtins_lock
);
6366 ir_function_signature
*
6367 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
6368 const char *name
, exec_list
*actual_parameters
)
6370 ir_function_signature
*s
;
6371 mtx_lock(&builtins_lock
);
6372 s
= builtins
.find(state
, name
, actual_parameters
);
6373 mtx_unlock(&builtins_lock
);
6379 _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state
*state
, const char *name
)
6383 mtx_lock(&builtins_lock
);
6384 f
= builtins
.shader
->symbols
->get_function(name
);
6386 foreach_in_list(ir_function_signature
, sig
, &f
->signatures
) {
6387 if (sig
->is_builtin_available(state
)) {
6393 mtx_unlock(&builtins_lock
);
6399 _mesa_glsl_get_builtin_function_shader()
6401 return builtins
.shader
;
6406 * Get the function signature for main from a shader
6408 ir_function_signature
*
6409 _mesa_get_main_function_signature(glsl_symbol_table
*symbols
)
6411 ir_function
*const f
= symbols
->get_function("main");
6413 exec_list void_parameters
;
6415 /* Look for the 'void main()' signature and ensure that it's defined.
6416 * This keeps the linker from accidentally pick a shader that just
6417 * contains a prototype for main.
6419 * We don't have to check for multiple definitions of main (in multiple
6420 * shaders) because that would have already been caught above.
6422 ir_function_signature
*sig
=
6423 f
->matching_signature(NULL
, &void_parameters
, false);
6424 if ((sig
!= NULL
) && sig
->is_defined
) {