2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * \file builtin_functions.cpp
27 * Support for GLSL built-in functions.
29 * This file is split into several main components:
31 * 1. Availability predicates
33 * A series of small functions that check whether the current shader
34 * supports the version/extensions required to expose a built-in.
36 * 2. Core builtin_builder class functionality
38 * 3. Lists of built-in functions
40 * The builtin_builder::create_builtins() function contains lists of all
41 * built-in function signatures, where they're available, what types they
44 * 4. Implementations of built-in function signatures
46 * A series of functions which create ir_function_signatures and emit IR
47 * via ir_builder to implement them.
51 * A few functions the rest of the compiler can use to interact with the
52 * built-in function module. For example, searching for a built-in by
53 * name and parameters.
58 * Unfortunately, some versions of MinGW produce bad code if this file
59 * is compiled with -O2 or -O3. The resulting driver will crash in random
60 * places if the app uses GLSL.
61 * The work-around is to disable optimizations for just this file. Luckily,
62 * this code is basically just executed once.
64 * MinGW 4.6.3 (in Ubuntu 13.10) does not have this bug.
65 * MinGW 5.3.1 (in Ubuntu 16.04) definitely has this bug.
66 * MinGW 6.2.0 (in Ubuntu 16.10) definitely has this bug.
67 * MinGW x.y.z - don't know. Assume versions after 4.6.x are buggy
70 #if defined(__MINGW32__) && ((__GNUC__ * 100) + __GNUC_MINOR >= 407)
71 #warning "disabling optimizations for this file to work around compiler bug"
72 #pragma GCC optimize("O1")
78 #include "main/core.h" /* for struct gl_shader */
79 #include "main/shaderobj.h"
80 #include "ir_builder.h"
81 #include "glsl_parser_extras.h"
82 #include "program/prog_instruction.h"
84 #include "builtin_functions.h"
85 #include "util/hash_table.h"
87 #define M_PIf ((float) M_PI)
88 #define M_PI_2f ((float) M_PI_2)
89 #define M_PI_4f ((float) M_PI_4)
91 using namespace ir_builder
;
94 * Availability predicates:
98 always_available(const _mesa_glsl_parse_state
*)
104 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
106 return state
->stage
== MESA_SHADER_VERTEX
&&
107 state
->language_version
<= 130 &&
112 fs_only(const _mesa_glsl_parse_state
*state
)
114 return state
->stage
== MESA_SHADER_FRAGMENT
;
118 gs_only(const _mesa_glsl_parse_state
*state
)
120 return state
->stage
== MESA_SHADER_GEOMETRY
;
124 v110(const _mesa_glsl_parse_state
*state
)
126 return !state
->es_shader
;
130 v110_fs_only(const _mesa_glsl_parse_state
*state
)
132 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
136 v120(const _mesa_glsl_parse_state
*state
)
138 return state
->is_version(120, 300);
142 v130(const _mesa_glsl_parse_state
*state
)
144 return state
->is_version(130, 300);
148 v130_desktop(const _mesa_glsl_parse_state
*state
)
150 return state
->is_version(130, 0);
154 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
;
191 /** True if texturing functions with explicit LOD are allowed. */
193 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
195 /* Texturing functions with "Lod" in their name exist:
196 * - In the vertex shader stage (for all languages)
197 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
198 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
200 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
201 * don't need to explicitly check state->es_shader.
203 return state
->stage
== MESA_SHADER_VERTEX
||
204 state
->is_version(130, 300) ||
205 state
->ARB_shader_texture_lod_enable
;
209 v110_lod(const _mesa_glsl_parse_state
*state
)
211 return !state
->es_shader
&& lod_exists_in_stage(state
);
215 texture_buffer(const _mesa_glsl_parse_state
*state
)
217 return state
->is_version(140, 320) ||
218 state
->EXT_texture_buffer_enable
||
219 state
->OES_texture_buffer_enable
;
223 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
225 return state
->ARB_shader_texture_lod_enable
;
229 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
231 return state
->ARB_shader_texture_lod_enable
&&
232 state
->ARB_texture_rectangle_enable
;
236 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
238 return state
->is_version(330, 300) ||
239 state
->ARB_shader_bit_encoding_enable
||
240 state
->ARB_gpu_shader5_enable
;
244 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
246 return state
->is_version(450, 310) ||
247 state
->ARB_ES3_1_compatibility_enable
||
248 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
252 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
254 return state
->ARB_shading_language_packing_enable
||
255 state
->is_version(420, 300);
259 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
261 return state
->ARB_shading_language_packing_enable
||
262 state
->ARB_gpu_shader5_enable
||
263 state
->is_version(400, 300);
267 gpu_shader5(const _mesa_glsl_parse_state
*state
)
269 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
273 gpu_shader5_es(const _mesa_glsl_parse_state
*state
)
275 return state
->is_version(400, 320) ||
276 state
->ARB_gpu_shader5_enable
||
277 state
->EXT_gpu_shader5_enable
||
278 state
->OES_gpu_shader5_enable
;
282 gpu_shader5_or_OES_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
284 return state
->is_version(400, 320) ||
285 state
->ARB_gpu_shader5_enable
||
286 state
->EXT_texture_cube_map_array_enable
||
287 state
->OES_texture_cube_map_array_enable
;
291 es31_not_gs5(const _mesa_glsl_parse_state
*state
)
293 return state
->is_version(0, 310) && !gpu_shader5_es(state
);
297 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
299 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
303 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
305 return state
->ARB_shading_language_packing_enable
||
306 state
->ARB_gpu_shader5_enable
||
307 state
->is_version(400, 310);
311 gpu_shader5_or_es31_or_integer_functions(const _mesa_glsl_parse_state
*state
)
313 return gpu_shader5_or_es31(state
) ||
314 state
->MESA_shader_integer_functions_enable
;
318 fs_interpolate_at(const _mesa_glsl_parse_state
*state
)
320 return state
->stage
== MESA_SHADER_FRAGMENT
&&
321 (state
->is_version(400, 320) ||
322 state
->ARB_gpu_shader5_enable
||
323 state
->OES_shader_multisample_interpolation_enable
);
328 texture_array_lod(const _mesa_glsl_parse_state
*state
)
330 return lod_exists_in_stage(state
) &&
331 state
->EXT_texture_array_enable
;
335 fs_texture_array(const _mesa_glsl_parse_state
*state
)
337 return state
->stage
== MESA_SHADER_FRAGMENT
&&
338 state
->EXT_texture_array_enable
;
342 texture_array(const _mesa_glsl_parse_state
*state
)
344 return state
->EXT_texture_array_enable
;
348 texture_multisample(const _mesa_glsl_parse_state
*state
)
350 return state
->is_version(150, 310) ||
351 state
->ARB_texture_multisample_enable
;
355 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
357 return state
->is_version(150, 320) ||
358 state
->ARB_texture_multisample_enable
||
359 state
->OES_texture_storage_multisample_2d_array_enable
;
363 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
365 return texture_multisample(state
) &&
366 state
->EXT_shader_samples_identical_enable
;
370 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
372 return texture_multisample_array(state
) &&
373 state
->EXT_shader_samples_identical_enable
;
377 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
379 return state
->stage
== MESA_SHADER_FRAGMENT
&&
380 state
->has_texture_cube_map_array();
384 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
386 return state
->has_texture_cube_map_array();
390 texture_query_levels(const _mesa_glsl_parse_state
*state
)
392 return state
->is_version(430, 0) ||
393 state
->ARB_texture_query_levels_enable
;
397 texture_query_lod(const _mesa_glsl_parse_state
*state
)
399 return state
->stage
== MESA_SHADER_FRAGMENT
&&
400 state
->ARB_texture_query_lod_enable
;
404 texture_gather_cube_map_array(const _mesa_glsl_parse_state
*state
)
406 return state
->is_version(400, 320) ||
407 state
->ARB_texture_gather_enable
||
408 state
->ARB_gpu_shader5_enable
||
409 state
->EXT_texture_cube_map_array_enable
||
410 state
->OES_texture_cube_map_array_enable
;
414 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
416 return state
->is_version(400, 310) ||
417 state
->ARB_texture_gather_enable
||
418 state
->ARB_gpu_shader5_enable
;
421 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
422 * used for relaxation of const offset requirements.
425 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
427 return !state
->is_version(400, 320) &&
428 !state
->ARB_gpu_shader5_enable
&&
429 !state
->EXT_gpu_shader5_enable
&&
430 !state
->OES_gpu_shader5_enable
&&
431 (state
->ARB_texture_gather_enable
||
432 state
->is_version(0, 310));
435 /* Desktop GL or OES_standard_derivatives + fragment shader only */
437 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
439 return state
->stage
== MESA_SHADER_FRAGMENT
&&
440 (state
->is_version(110, 300) ||
441 state
->OES_standard_derivatives_enable
);
445 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
447 return state
->stage
== MESA_SHADER_FRAGMENT
&&
448 (state
->is_version(450, 0) ||
449 state
->ARB_derivative_control_enable
);
453 tex1d_lod(const _mesa_glsl_parse_state
*state
)
455 return !state
->es_shader
&& lod_exists_in_stage(state
);
458 /** True if sampler3D exists */
460 tex3d(const _mesa_glsl_parse_state
*state
)
462 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
463 * OES_texture_3D extension, and in GLSL ES 3.00.
465 return !state
->es_shader
||
466 state
->OES_texture_3D_enable
||
467 state
->language_version
>= 300;
471 fs_tex3d(const _mesa_glsl_parse_state
*state
)
473 return state
->stage
== MESA_SHADER_FRAGMENT
&&
474 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
478 tex3d_lod(const _mesa_glsl_parse_state
*state
)
480 return tex3d(state
) && lod_exists_in_stage(state
);
484 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
486 return state
->has_atomic_counters();
490 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
492 return state
->ARB_shader_atomic_counter_ops_enable
;
496 shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
498 return state
->ARB_shader_atomic_counter_ops_enable
|| v460_desktop(state
);
502 shader_ballot(const _mesa_glsl_parse_state
*state
)
504 return state
->ARB_shader_ballot_enable
;
508 shader_clock(const _mesa_glsl_parse_state
*state
)
510 return state
->ARB_shader_clock_enable
;
514 shader_clock_int64(const _mesa_glsl_parse_state
*state
)
516 return state
->ARB_shader_clock_enable
&&
517 state
->ARB_gpu_shader_int64_enable
;
521 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
523 return state
->has_shader_storage_buffer_objects();
527 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
529 return state
->AMD_shader_trinary_minmax_enable
;
533 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
535 return (state
->is_version(420, 310) ||
536 state
->ARB_shader_image_load_store_enable
);
540 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
542 return (state
->is_version(420, 320) ||
543 state
->ARB_shader_image_load_store_enable
||
544 state
->OES_shader_image_atomic_enable
);
548 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
550 return (state
->is_version(450, 320) ||
551 state
->ARB_ES3_1_compatibility_enable
||
552 state
->OES_shader_image_atomic_enable
);
556 shader_image_size(const _mesa_glsl_parse_state
*state
)
558 return state
->is_version(430, 310) ||
559 state
->ARB_shader_image_size_enable
;
563 shader_samples(const _mesa_glsl_parse_state
*state
)
565 return state
->is_version(450, 0) ||
566 state
->ARB_shader_texture_image_samples_enable
;
570 gs_streams(const _mesa_glsl_parse_state
*state
)
572 return gpu_shader5(state
) && gs_only(state
);
576 fp64(const _mesa_glsl_parse_state
*state
)
578 return state
->has_double();
582 int64(const _mesa_glsl_parse_state
*state
)
584 return state
->has_int64();
588 int64_fp64(const _mesa_glsl_parse_state
*state
)
590 return state
->has_int64() && state
->has_double();
594 compute_shader(const _mesa_glsl_parse_state
*state
)
596 return state
->stage
== MESA_SHADER_COMPUTE
;
600 compute_shader_supported(const _mesa_glsl_parse_state
*state
)
602 return state
->has_compute_shader();
606 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
608 return compute_shader(state
) || shader_storage_buffer_object(state
);
612 barrier_supported(const _mesa_glsl_parse_state
*state
)
614 return compute_shader(state
) ||
615 state
->stage
== MESA_SHADER_TESS_CTRL
;
619 vote(const _mesa_glsl_parse_state
*state
)
621 return state
->ARB_shader_group_vote_enable
;
625 vote_or_v460_desktop(const _mesa_glsl_parse_state
*state
)
627 return state
->ARB_shader_group_vote_enable
|| v460_desktop(state
);
631 integer_functions_supported(const _mesa_glsl_parse_state
*state
)
633 return state
->extensions
->MESA_shader_integer_functions
;
637 /******************************************************************************/
642 * builtin_builder: A singleton object representing the core of the built-in
645 * It generates IR for every built-in function signature, and organizes them
648 class builtin_builder
{
655 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
656 const char *name
, exec_list
*actual_parameters
);
659 * A shader to hold all the built-in signatures; created by this module.
661 * This includes signatures for every built-in, regardless of version or
662 * enabled extensions. The availability predicate associated with each
663 * signature allows matching_signature() to filter out the irrelevant ones.
670 void create_shader();
671 void create_intrinsics();
672 void create_builtins();
675 * IR builder helpers:
677 * These convenience functions assist in emitting IR, but don't necessarily
678 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
681 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
682 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
683 ir_constant
*imm(float f
, unsigned vector_elements
=1);
684 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
685 ir_constant
*imm(int i
, unsigned vector_elements
=1);
686 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
687 ir_constant
*imm(double d
, unsigned vector_elements
=1);
688 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
689 ir_dereference_variable
*var_ref(ir_variable
*var
);
690 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
691 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
693 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
694 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
697 * Call function \param f with parameters specified as the linked
698 * list \param params of \c ir_variable objects. \param ret should
699 * point to the ir_variable that will hold the function return
700 * value, or be \c NULL if the function has void return type.
702 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
704 /** Create a new function and add the given signatures. */
705 void add_function(const char *name
, ...);
707 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
708 unsigned num_arguments
,
712 * Create a new image built-in function for all known image types.
713 * \p flags is a bitfield of \c image_function_flags flags.
715 void add_image_function(const char *name
,
716 const char *intrinsic_name
,
717 image_prototype_ctr prototype
,
718 unsigned num_arguments
,
720 enum ir_intrinsic_id id
);
723 * Create new functions for all known image built-ins and types.
724 * If \p glsl is \c true, use the GLSL built-in names and emit code
725 * to call into the actual compiler intrinsic. If \p glsl is
726 * false, emit a function prototype with no body for each image
729 void add_image_functions(bool glsl
);
731 ir_function_signature
*new_sig(const glsl_type
*return_type
,
732 builtin_available_predicate avail
,
733 int num_params
, ...);
736 * Function signature generators:
739 ir_function_signature
*unop(builtin_available_predicate avail
,
740 ir_expression_operation opcode
,
741 const glsl_type
*return_type
,
742 const glsl_type
*param_type
);
743 ir_function_signature
*binop(builtin_available_predicate avail
,
744 ir_expression_operation opcode
,
745 const glsl_type
*return_type
,
746 const glsl_type
*param0_type
,
747 const glsl_type
*param1_type
);
749 #define B0(X) ir_function_signature *_##X();
750 #define B1(X) ir_function_signature *_##X(const glsl_type *);
751 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
752 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
753 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
754 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
791 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
792 const glsl_type
*val_type
,
793 const glsl_type
*blend_type
);
803 BA1(doubleBitsToInt64
)
804 BA1(doubleBitsToUint64
)
805 BA1(int64BitsToDouble
)
806 BA1(uint64BitsToDouble
)
808 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
809 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
810 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
811 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
812 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
813 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
814 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
815 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
816 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
817 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
818 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
819 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
820 ir_function_signature
*_packInt2x32(builtin_available_predicate avail
);
821 ir_function_signature
*_unpackInt2x32(builtin_available_predicate avail
);
822 ir_function_signature
*_packUint2x32(builtin_available_predicate avail
);
823 ir_function_signature
*_unpackUint2x32(builtin_available_predicate avail
);
836 BA1(determinant_mat2
);
837 BA1(determinant_mat3
);
838 BA1(determinant_mat4
);
846 BA1(greaterThanEqual
);
855 /** Flags to _texture() */
856 #define TEX_PROJECT 1
858 #define TEX_COMPONENT 4
859 #define TEX_OFFSET_NONCONST 8
860 #define TEX_OFFSET_ARRAY 16
862 ir_function_signature
*_texture(ir_texture_opcode opcode
,
863 builtin_available_predicate avail
,
864 const glsl_type
*return_type
,
865 const glsl_type
*sampler_type
,
866 const glsl_type
*coord_type
,
868 BA1(textureCubeArrayShadow
);
869 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
870 const glsl_type
*return_type
,
871 const glsl_type
*sampler_type
,
872 const glsl_type
*coord_type
,
873 const glsl_type
*offset_type
= NULL
);
877 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
878 const glsl_type
*stream_type
);
879 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
880 const glsl_type
*stream_type
);
883 BA2(textureQueryLod
);
884 BA1(textureQueryLevels
);
885 BA2(textureSamplesIdentical
);
913 B1(interpolateAtCentroid
)
914 B1(interpolateAtOffset
)
915 B1(interpolateAtSample
)
917 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
,
918 enum ir_intrinsic_id id
);
919 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
,
920 enum ir_intrinsic_id id
);
921 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
,
922 enum ir_intrinsic_id id
);
923 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
924 builtin_available_predicate avail
);
925 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
926 builtin_available_predicate avail
);
927 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
928 builtin_available_predicate avail
);
930 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
931 const glsl_type
*type
,
932 enum ir_intrinsic_id id
);
933 ir_function_signature
*_atomic_op2(const char *intrinsic
,
934 builtin_available_predicate avail
,
935 const glsl_type
*type
);
936 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
937 const glsl_type
*type
,
938 enum ir_intrinsic_id id
);
939 ir_function_signature
*_atomic_op3(const char *intrinsic
,
940 builtin_available_predicate avail
,
941 const glsl_type
*type
);
947 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
948 unsigned num_arguments
,
950 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
951 unsigned num_arguments
,
953 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
954 unsigned num_arguments
,
956 ir_function_signature
*_image(image_prototype_ctr prototype
,
957 const glsl_type
*image_type
,
958 const char *intrinsic_name
,
959 unsigned num_arguments
,
961 enum ir_intrinsic_id id
);
963 ir_function_signature
*_memory_barrier_intrinsic(
964 builtin_available_predicate avail
,
965 enum ir_intrinsic_id id
);
966 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
967 builtin_available_predicate avail
);
969 ir_function_signature
*_ballot_intrinsic();
970 ir_function_signature
*_ballot();
971 ir_function_signature
*_read_first_invocation_intrinsic(const glsl_type
*type
);
972 ir_function_signature
*_read_first_invocation(const glsl_type
*type
);
973 ir_function_signature
*_read_invocation_intrinsic(const glsl_type
*type
);
974 ir_function_signature
*_read_invocation(const glsl_type
*type
);
976 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
977 const glsl_type
*type
);
978 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
979 const glsl_type
*type
);
981 ir_function_signature
*_vote_intrinsic(builtin_available_predicate avail
,
982 enum ir_intrinsic_id id
);
983 ir_function_signature
*_vote(const char *intrinsic_name
,
984 builtin_available_predicate avail
);
995 enum image_function_flags
{
996 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
997 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
998 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
999 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
1000 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
1001 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
1002 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
1003 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
1004 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8)
1007 } /* anonymous namespace */
1010 * Core builtin_builder functionality:
1013 builtin_builder::builtin_builder()
1019 builtin_builder::~builtin_builder()
1021 ralloc_free(mem_ctx
);
1024 ir_function_signature
*
1025 builtin_builder::find(_mesa_glsl_parse_state
*state
,
1026 const char *name
, exec_list
*actual_parameters
)
1028 /* The shader currently being compiled requested a built-in function;
1029 * it needs to link against builtin_builder::shader in order to get them.
1031 * Even if we don't find a matching signature, we still need to do this so
1032 * that the "no matching signature" error will list potential candidates
1033 * from the available built-ins.
1035 state
->uses_builtin_functions
= true;
1037 ir_function
*f
= shader
->symbols
->get_function(name
);
1041 ir_function_signature
*sig
=
1042 f
->matching_signature(state
, actual_parameters
, true);
1050 builtin_builder::initialize()
1052 /* If already initialized, don't do it again. */
1053 if (mem_ctx
!= NULL
)
1056 mem_ctx
= ralloc_context(NULL
);
1058 create_intrinsics();
1063 builtin_builder::release()
1065 ralloc_free(mem_ctx
);
1068 ralloc_free(shader
);
1073 builtin_builder::create_shader()
1075 /* The target doesn't actually matter. There's no target for generic
1076 * GLSL utility code that could be linked against any stage, so just
1077 * arbitrarily pick GL_VERTEX_SHADER.
1079 shader
= _mesa_new_shader(0, MESA_SHADER_VERTEX
);
1080 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
1086 * Create ir_function and ir_function_signature objects for each
1090 builtin_builder::create_intrinsics()
1092 add_function("__intrinsic_atomic_read",
1093 _atomic_counter_intrinsic(shader_atomic_counters
,
1094 ir_intrinsic_atomic_counter_read
),
1096 add_function("__intrinsic_atomic_increment",
1097 _atomic_counter_intrinsic(shader_atomic_counters
,
1098 ir_intrinsic_atomic_counter_increment
),
1100 add_function("__intrinsic_atomic_predecrement",
1101 _atomic_counter_intrinsic(shader_atomic_counters
,
1102 ir_intrinsic_atomic_counter_predecrement
),
1105 add_function("__intrinsic_atomic_add",
1106 _atomic_intrinsic2(buffer_atomics_supported
,
1107 glsl_type::uint_type
,
1108 ir_intrinsic_generic_atomic_add
),
1109 _atomic_intrinsic2(buffer_atomics_supported
,
1110 glsl_type::int_type
,
1111 ir_intrinsic_generic_atomic_add
),
1112 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1113 ir_intrinsic_atomic_counter_add
),
1115 add_function("__intrinsic_atomic_min",
1116 _atomic_intrinsic2(buffer_atomics_supported
,
1117 glsl_type::uint_type
,
1118 ir_intrinsic_generic_atomic_min
),
1119 _atomic_intrinsic2(buffer_atomics_supported
,
1120 glsl_type::int_type
,
1121 ir_intrinsic_generic_atomic_min
),
1122 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1123 ir_intrinsic_atomic_counter_min
),
1125 add_function("__intrinsic_atomic_max",
1126 _atomic_intrinsic2(buffer_atomics_supported
,
1127 glsl_type::uint_type
,
1128 ir_intrinsic_generic_atomic_max
),
1129 _atomic_intrinsic2(buffer_atomics_supported
,
1130 glsl_type::int_type
,
1131 ir_intrinsic_generic_atomic_max
),
1132 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1133 ir_intrinsic_atomic_counter_max
),
1135 add_function("__intrinsic_atomic_and",
1136 _atomic_intrinsic2(buffer_atomics_supported
,
1137 glsl_type::uint_type
,
1138 ir_intrinsic_generic_atomic_and
),
1139 _atomic_intrinsic2(buffer_atomics_supported
,
1140 glsl_type::int_type
,
1141 ir_intrinsic_generic_atomic_and
),
1142 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1143 ir_intrinsic_atomic_counter_and
),
1145 add_function("__intrinsic_atomic_or",
1146 _atomic_intrinsic2(buffer_atomics_supported
,
1147 glsl_type::uint_type
,
1148 ir_intrinsic_generic_atomic_or
),
1149 _atomic_intrinsic2(buffer_atomics_supported
,
1150 glsl_type::int_type
,
1151 ir_intrinsic_generic_atomic_or
),
1152 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1153 ir_intrinsic_atomic_counter_or
),
1155 add_function("__intrinsic_atomic_xor",
1156 _atomic_intrinsic2(buffer_atomics_supported
,
1157 glsl_type::uint_type
,
1158 ir_intrinsic_generic_atomic_xor
),
1159 _atomic_intrinsic2(buffer_atomics_supported
,
1160 glsl_type::int_type
,
1161 ir_intrinsic_generic_atomic_xor
),
1162 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1163 ir_intrinsic_atomic_counter_xor
),
1165 add_function("__intrinsic_atomic_exchange",
1166 _atomic_intrinsic2(buffer_atomics_supported
,
1167 glsl_type::uint_type
,
1168 ir_intrinsic_generic_atomic_exchange
),
1169 _atomic_intrinsic2(buffer_atomics_supported
,
1170 glsl_type::int_type
,
1171 ir_intrinsic_generic_atomic_exchange
),
1172 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop
,
1173 ir_intrinsic_atomic_counter_exchange
),
1175 add_function("__intrinsic_atomic_comp_swap",
1176 _atomic_intrinsic3(buffer_atomics_supported
,
1177 glsl_type::uint_type
,
1178 ir_intrinsic_generic_atomic_comp_swap
),
1179 _atomic_intrinsic3(buffer_atomics_supported
,
1180 glsl_type::int_type
,
1181 ir_intrinsic_generic_atomic_comp_swap
),
1182 _atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop
,
1183 ir_intrinsic_atomic_counter_comp_swap
),
1186 add_image_functions(false);
1188 add_function("__intrinsic_memory_barrier",
1189 _memory_barrier_intrinsic(shader_image_load_store
,
1190 ir_intrinsic_memory_barrier
),
1192 add_function("__intrinsic_group_memory_barrier",
1193 _memory_barrier_intrinsic(compute_shader
,
1194 ir_intrinsic_group_memory_barrier
),
1196 add_function("__intrinsic_memory_barrier_atomic_counter",
1197 _memory_barrier_intrinsic(compute_shader_supported
,
1198 ir_intrinsic_memory_barrier_atomic_counter
),
1200 add_function("__intrinsic_memory_barrier_buffer",
1201 _memory_barrier_intrinsic(compute_shader_supported
,
1202 ir_intrinsic_memory_barrier_buffer
),
1204 add_function("__intrinsic_memory_barrier_image",
1205 _memory_barrier_intrinsic(compute_shader_supported
,
1206 ir_intrinsic_memory_barrier_image
),
1208 add_function("__intrinsic_memory_barrier_shared",
1209 _memory_barrier_intrinsic(compute_shader
,
1210 ir_intrinsic_memory_barrier_shared
),
1213 add_function("__intrinsic_shader_clock",
1214 _shader_clock_intrinsic(shader_clock
,
1215 glsl_type::uvec2_type
),
1218 add_function("__intrinsic_vote_all",
1219 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_all
),
1221 add_function("__intrinsic_vote_any",
1222 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_any
),
1224 add_function("__intrinsic_vote_eq",
1225 _vote_intrinsic(vote_or_v460_desktop
, ir_intrinsic_vote_eq
),
1228 add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL
);
1230 add_function("__intrinsic_read_invocation",
1231 _read_invocation_intrinsic(glsl_type::float_type
),
1232 _read_invocation_intrinsic(glsl_type::vec2_type
),
1233 _read_invocation_intrinsic(glsl_type::vec3_type
),
1234 _read_invocation_intrinsic(glsl_type::vec4_type
),
1236 _read_invocation_intrinsic(glsl_type::int_type
),
1237 _read_invocation_intrinsic(glsl_type::ivec2_type
),
1238 _read_invocation_intrinsic(glsl_type::ivec3_type
),
1239 _read_invocation_intrinsic(glsl_type::ivec4_type
),
1241 _read_invocation_intrinsic(glsl_type::uint_type
),
1242 _read_invocation_intrinsic(glsl_type::uvec2_type
),
1243 _read_invocation_intrinsic(glsl_type::uvec3_type
),
1244 _read_invocation_intrinsic(glsl_type::uvec4_type
),
1247 add_function("__intrinsic_read_first_invocation",
1248 _read_first_invocation_intrinsic(glsl_type::float_type
),
1249 _read_first_invocation_intrinsic(glsl_type::vec2_type
),
1250 _read_first_invocation_intrinsic(glsl_type::vec3_type
),
1251 _read_first_invocation_intrinsic(glsl_type::vec4_type
),
1253 _read_first_invocation_intrinsic(glsl_type::int_type
),
1254 _read_first_invocation_intrinsic(glsl_type::ivec2_type
),
1255 _read_first_invocation_intrinsic(glsl_type::ivec3_type
),
1256 _read_first_invocation_intrinsic(glsl_type::ivec4_type
),
1258 _read_first_invocation_intrinsic(glsl_type::uint_type
),
1259 _read_first_invocation_intrinsic(glsl_type::uvec2_type
),
1260 _read_first_invocation_intrinsic(glsl_type::uvec3_type
),
1261 _read_first_invocation_intrinsic(glsl_type::uvec4_type
),
1267 * Create ir_function and ir_function_signature objects for each built-in.
1269 * Contains a list of every available built-in.
1272 builtin_builder::create_builtins()
1275 add_function(#NAME, \
1276 _##NAME(glsl_type::float_type), \
1277 _##NAME(glsl_type::vec2_type), \
1278 _##NAME(glsl_type::vec3_type), \
1279 _##NAME(glsl_type::vec4_type), \
1283 add_function(#NAME, \
1284 _##NAME(always_available, glsl_type::float_type), \
1285 _##NAME(always_available, glsl_type::vec2_type), \
1286 _##NAME(always_available, glsl_type::vec3_type), \
1287 _##NAME(always_available, glsl_type::vec4_type), \
1288 _##NAME(fp64, glsl_type::double_type), \
1289 _##NAME(fp64, glsl_type::dvec2_type), \
1290 _##NAME(fp64, glsl_type::dvec3_type), \
1291 _##NAME(fp64, glsl_type::dvec4_type), \
1294 #define FD130(NAME) \
1295 add_function(#NAME, \
1296 _##NAME(v130, glsl_type::float_type), \
1297 _##NAME(v130, glsl_type::vec2_type), \
1298 _##NAME(v130, glsl_type::vec3_type), \
1299 _##NAME(v130, glsl_type::vec4_type), \
1300 _##NAME(fp64, glsl_type::double_type), \
1301 _##NAME(fp64, glsl_type::dvec2_type), \
1302 _##NAME(fp64, glsl_type::dvec3_type), \
1303 _##NAME(fp64, glsl_type::dvec4_type), \
1306 #define FDGS5(NAME) \
1307 add_function(#NAME, \
1308 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1309 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1310 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1311 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1312 _##NAME(fp64, glsl_type::double_type), \
1313 _##NAME(fp64, glsl_type::dvec2_type), \
1314 _##NAME(fp64, glsl_type::dvec3_type), \
1315 _##NAME(fp64, glsl_type::dvec4_type), \
1319 add_function(#NAME, \
1320 _##NAME(glsl_type::float_type), \
1321 _##NAME(glsl_type::vec2_type), \
1322 _##NAME(glsl_type::vec3_type), \
1323 _##NAME(glsl_type::vec4_type), \
1324 _##NAME(glsl_type::int_type), \
1325 _##NAME(glsl_type::ivec2_type), \
1326 _##NAME(glsl_type::ivec3_type), \
1327 _##NAME(glsl_type::ivec4_type), \
1330 #define FI64(NAME) \
1331 add_function(#NAME, \
1332 _##NAME(always_available, glsl_type::float_type), \
1333 _##NAME(always_available, glsl_type::vec2_type), \
1334 _##NAME(always_available, glsl_type::vec3_type), \
1335 _##NAME(always_available, glsl_type::vec4_type), \
1336 _##NAME(always_available, glsl_type::int_type), \
1337 _##NAME(always_available, glsl_type::ivec2_type), \
1338 _##NAME(always_available, glsl_type::ivec3_type), \
1339 _##NAME(always_available, glsl_type::ivec4_type), \
1340 _##NAME(fp64, glsl_type::double_type), \
1341 _##NAME(fp64, glsl_type::dvec2_type), \
1342 _##NAME(fp64, glsl_type::dvec3_type), \
1343 _##NAME(fp64, glsl_type::dvec4_type), \
1344 _##NAME(int64, glsl_type::int64_t_type), \
1345 _##NAME(int64, glsl_type::i64vec2_type), \
1346 _##NAME(int64, glsl_type::i64vec3_type), \
1347 _##NAME(int64, glsl_type::i64vec4_type), \
1350 #define FIUD_VEC(NAME) \
1351 add_function(#NAME, \
1352 _##NAME(always_available, glsl_type::vec2_type), \
1353 _##NAME(always_available, glsl_type::vec3_type), \
1354 _##NAME(always_available, glsl_type::vec4_type), \
1356 _##NAME(always_available, glsl_type::ivec2_type), \
1357 _##NAME(always_available, glsl_type::ivec3_type), \
1358 _##NAME(always_available, glsl_type::ivec4_type), \
1360 _##NAME(v130, glsl_type::uvec2_type), \
1361 _##NAME(v130, glsl_type::uvec3_type), \
1362 _##NAME(v130, glsl_type::uvec4_type), \
1363 _##NAME(fp64, glsl_type::dvec2_type), \
1364 _##NAME(fp64, glsl_type::dvec3_type), \
1365 _##NAME(fp64, glsl_type::dvec4_type), \
1366 _##NAME(int64, glsl_type::int64_t_type), \
1367 _##NAME(int64, glsl_type::i64vec2_type), \
1368 _##NAME(int64, glsl_type::i64vec3_type), \
1369 _##NAME(int64, glsl_type::i64vec4_type), \
1370 _##NAME(int64, glsl_type::uint64_t_type), \
1371 _##NAME(int64, glsl_type::u64vec2_type), \
1372 _##NAME(int64, glsl_type::u64vec3_type), \
1373 _##NAME(int64, glsl_type::u64vec4_type), \
1377 add_function(#NAME, \
1378 _##NAME(glsl_type::int_type), \
1379 _##NAME(glsl_type::ivec2_type), \
1380 _##NAME(glsl_type::ivec3_type), \
1381 _##NAME(glsl_type::ivec4_type), \
1383 _##NAME(glsl_type::uint_type), \
1384 _##NAME(glsl_type::uvec2_type), \
1385 _##NAME(glsl_type::uvec3_type), \
1386 _##NAME(glsl_type::uvec4_type), \
1389 #define FIUBD_VEC(NAME) \
1390 add_function(#NAME, \
1391 _##NAME(always_available, glsl_type::vec2_type), \
1392 _##NAME(always_available, glsl_type::vec3_type), \
1393 _##NAME(always_available, glsl_type::vec4_type), \
1395 _##NAME(always_available, glsl_type::ivec2_type), \
1396 _##NAME(always_available, glsl_type::ivec3_type), \
1397 _##NAME(always_available, glsl_type::ivec4_type), \
1399 _##NAME(v130, glsl_type::uvec2_type), \
1400 _##NAME(v130, glsl_type::uvec3_type), \
1401 _##NAME(v130, glsl_type::uvec4_type), \
1403 _##NAME(always_available, glsl_type::bvec2_type), \
1404 _##NAME(always_available, glsl_type::bvec3_type), \
1405 _##NAME(always_available, glsl_type::bvec4_type), \
1407 _##NAME(fp64, glsl_type::dvec2_type), \
1408 _##NAME(fp64, glsl_type::dvec3_type), \
1409 _##NAME(fp64, glsl_type::dvec4_type), \
1410 _##NAME(int64, glsl_type::int64_t_type), \
1411 _##NAME(int64, glsl_type::i64vec2_type), \
1412 _##NAME(int64, glsl_type::i64vec3_type), \
1413 _##NAME(int64, glsl_type::i64vec4_type), \
1414 _##NAME(int64, glsl_type::uint64_t_type), \
1415 _##NAME(int64, glsl_type::u64vec2_type), \
1416 _##NAME(int64, glsl_type::u64vec3_type), \
1417 _##NAME(int64, glsl_type::u64vec4_type), \
1420 #define FIUD2_MIXED(NAME) \
1421 add_function(#NAME, \
1422 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1423 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1424 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1425 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1427 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1428 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1429 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1431 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1432 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1433 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1434 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1436 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1437 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1438 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1440 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1441 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1442 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1443 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1445 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1446 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1447 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1449 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1450 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1451 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1452 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1453 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1454 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1455 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1457 _##NAME(int64, glsl_type::int64_t_type, glsl_type::int64_t_type), \
1458 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::int64_t_type), \
1459 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::int64_t_type), \
1460 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::int64_t_type), \
1461 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::i64vec2_type), \
1462 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::i64vec3_type), \
1463 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::i64vec4_type), \
1464 _##NAME(int64, glsl_type::uint64_t_type, glsl_type::uint64_t_type), \
1465 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::uint64_t_type), \
1466 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::uint64_t_type), \
1467 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::uint64_t_type), \
1468 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::u64vec2_type), \
1469 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::u64vec3_type), \
1470 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::u64vec4_type), \
1481 add_function("atan",
1482 _atan(glsl_type::float_type
),
1483 _atan(glsl_type::vec2_type
),
1484 _atan(glsl_type::vec3_type
),
1485 _atan(glsl_type::vec4_type
),
1486 _atan2(glsl_type::float_type
),
1487 _atan2(glsl_type::vec2_type
),
1488 _atan2(glsl_type::vec3_type
),
1489 _atan2(glsl_type::vec4_type
),
1515 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1516 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1517 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1518 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1520 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1521 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1522 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1524 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1525 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1526 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1527 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1529 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1530 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1531 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1541 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1542 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1543 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1544 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1546 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1547 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1548 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1550 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1551 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1552 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1553 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1555 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1556 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1557 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1559 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1560 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1561 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1562 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1564 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1565 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1566 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1567 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1569 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1570 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1571 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1572 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1574 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1575 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1576 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1577 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1579 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1580 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1581 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1582 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1584 _mix_sel(int64
, glsl_type::int64_t_type
, glsl_type::bool_type
),
1585 _mix_sel(int64
, glsl_type::i64vec2_type
, glsl_type::bvec2_type
),
1586 _mix_sel(int64
, glsl_type::i64vec3_type
, glsl_type::bvec3_type
),
1587 _mix_sel(int64
, glsl_type::i64vec4_type
, glsl_type::bvec4_type
),
1589 _mix_sel(int64
, glsl_type::uint64_t_type
, glsl_type::bool_type
),
1590 _mix_sel(int64
, glsl_type::u64vec2_type
, glsl_type::bvec2_type
),
1591 _mix_sel(int64
, glsl_type::u64vec3_type
, glsl_type::bvec3_type
),
1592 _mix_sel(int64
, glsl_type::u64vec4_type
, glsl_type::bvec4_type
),
1595 add_function("step",
1596 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1597 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1598 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1599 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1601 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1602 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1603 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1604 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1605 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1606 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1607 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1609 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1610 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1611 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1614 add_function("smoothstep",
1615 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1616 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1617 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1618 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1620 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1621 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1622 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1623 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1624 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1625 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1626 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1628 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1629 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1630 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1638 add_function("intBitsToFloat",
1639 _intBitsToFloat(glsl_type::int_type
),
1640 _intBitsToFloat(glsl_type::ivec2_type
),
1641 _intBitsToFloat(glsl_type::ivec3_type
),
1642 _intBitsToFloat(glsl_type::ivec4_type
),
1644 add_function("uintBitsToFloat",
1645 _uintBitsToFloat(glsl_type::uint_type
),
1646 _uintBitsToFloat(glsl_type::uvec2_type
),
1647 _uintBitsToFloat(glsl_type::uvec3_type
),
1648 _uintBitsToFloat(glsl_type::uvec4_type
),
1651 add_function("doubleBitsToInt64",
1652 _doubleBitsToInt64(int64_fp64
, glsl_type::double_type
),
1653 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec2_type
),
1654 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec3_type
),
1655 _doubleBitsToInt64(int64_fp64
, glsl_type::dvec4_type
),
1658 add_function("doubleBitsToUint64",
1659 _doubleBitsToUint64(int64_fp64
, glsl_type::double_type
),
1660 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec2_type
),
1661 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec3_type
),
1662 _doubleBitsToUint64(int64_fp64
, glsl_type::dvec4_type
),
1665 add_function("int64BitsToDouble",
1666 _int64BitsToDouble(int64_fp64
, glsl_type::int64_t_type
),
1667 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec2_type
),
1668 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec3_type
),
1669 _int64BitsToDouble(int64_fp64
, glsl_type::i64vec4_type
),
1672 add_function("uint64BitsToDouble",
1673 _uint64BitsToDouble(int64_fp64
, glsl_type::uint64_t_type
),
1674 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec2_type
),
1675 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec3_type
),
1676 _uint64BitsToDouble(int64_fp64
, glsl_type::u64vec4_type
),
1679 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1680 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1681 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1682 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1683 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1684 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1685 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1686 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1687 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1688 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1689 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1690 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1692 add_function("packInt2x32", _packInt2x32(int64
), NULL
);
1693 add_function("unpackInt2x32", _unpackInt2x32(int64
), NULL
);
1694 add_function("packUint2x32", _packUint2x32(int64
), NULL
);
1695 add_function("unpackUint2x32", _unpackUint2x32(int64
), NULL
);
1701 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1702 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1705 add_function("ftransform", _ftransform(), NULL
);
1710 add_function("matrixCompMult",
1711 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1712 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1713 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1714 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1715 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1716 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1717 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1718 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1719 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1720 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1721 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1722 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1723 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1724 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1725 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1726 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1727 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1728 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1730 add_function("outerProduct",
1731 _outerProduct(v120
, glsl_type::mat2_type
),
1732 _outerProduct(v120
, glsl_type::mat3_type
),
1733 _outerProduct(v120
, glsl_type::mat4_type
),
1734 _outerProduct(v120
, glsl_type::mat2x3_type
),
1735 _outerProduct(v120
, glsl_type::mat2x4_type
),
1736 _outerProduct(v120
, glsl_type::mat3x2_type
),
1737 _outerProduct(v120
, glsl_type::mat3x4_type
),
1738 _outerProduct(v120
, glsl_type::mat4x2_type
),
1739 _outerProduct(v120
, glsl_type::mat4x3_type
),
1740 _outerProduct(fp64
, glsl_type::dmat2_type
),
1741 _outerProduct(fp64
, glsl_type::dmat3_type
),
1742 _outerProduct(fp64
, glsl_type::dmat4_type
),
1743 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1744 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1745 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1746 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1747 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1748 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1750 add_function("determinant",
1751 _determinant_mat2(v120
, glsl_type::mat2_type
),
1752 _determinant_mat3(v120
, glsl_type::mat3_type
),
1753 _determinant_mat4(v120
, glsl_type::mat4_type
),
1754 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1755 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1756 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1759 add_function("inverse",
1760 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1761 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1762 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1763 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1764 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1765 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1767 add_function("transpose",
1768 _transpose(v120
, glsl_type::mat2_type
),
1769 _transpose(v120
, glsl_type::mat3_type
),
1770 _transpose(v120
, glsl_type::mat4_type
),
1771 _transpose(v120
, glsl_type::mat2x3_type
),
1772 _transpose(v120
, glsl_type::mat2x4_type
),
1773 _transpose(v120
, glsl_type::mat3x2_type
),
1774 _transpose(v120
, glsl_type::mat3x4_type
),
1775 _transpose(v120
, glsl_type::mat4x2_type
),
1776 _transpose(v120
, glsl_type::mat4x3_type
),
1777 _transpose(fp64
, glsl_type::dmat2_type
),
1778 _transpose(fp64
, glsl_type::dmat3_type
),
1779 _transpose(fp64
, glsl_type::dmat4_type
),
1780 _transpose(fp64
, glsl_type::dmat2x3_type
),
1781 _transpose(fp64
, glsl_type::dmat2x4_type
),
1782 _transpose(fp64
, glsl_type::dmat3x2_type
),
1783 _transpose(fp64
, glsl_type::dmat3x4_type
),
1784 _transpose(fp64
, glsl_type::dmat4x2_type
),
1785 _transpose(fp64
, glsl_type::dmat4x3_type
),
1788 FIUD_VEC(lessThanEqual
)
1789 FIUD_VEC(greaterThan
)
1790 FIUD_VEC(greaterThanEqual
)
1795 _any(glsl_type::bvec2_type
),
1796 _any(glsl_type::bvec3_type
),
1797 _any(glsl_type::bvec4_type
),
1801 _all(glsl_type::bvec2_type
),
1802 _all(glsl_type::bvec3_type
),
1803 _all(glsl_type::bvec4_type
),
1807 _not(glsl_type::bvec2_type
),
1808 _not(glsl_type::bvec3_type
),
1809 _not(glsl_type::bvec4_type
),
1812 add_function("textureSize",
1813 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1814 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1815 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1817 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1818 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1819 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1821 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1822 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1823 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1825 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1826 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1827 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1829 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1830 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1831 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1833 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1834 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1835 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1836 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1837 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1838 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1840 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1841 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1843 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1844 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1845 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1846 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1848 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1849 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1850 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1851 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1853 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1854 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1855 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1856 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1857 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1858 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1860 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1861 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1862 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1865 add_function("textureSamples",
1866 _textureSamples(shader_samples
, glsl_type::sampler2DMS_type
),
1867 _textureSamples(shader_samples
, glsl_type::isampler2DMS_type
),
1868 _textureSamples(shader_samples
, glsl_type::usampler2DMS_type
),
1870 _textureSamples(shader_samples
, glsl_type::sampler2DMSArray_type
),
1871 _textureSamples(shader_samples
, glsl_type::isampler2DMSArray_type
),
1872 _textureSamples(shader_samples
, glsl_type::usampler2DMSArray_type
),
1875 add_function("texture",
1876 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1877 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1878 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1880 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1881 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1882 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1884 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1885 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1886 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1888 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1889 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1890 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1892 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1893 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1894 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1896 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1897 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1898 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1900 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1901 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1902 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1904 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1905 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1906 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1908 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1909 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1910 /* samplerCubeArrayShadow is special; it has an extra parameter
1911 * for the shadow comparator since there is no vec5 type.
1913 _textureCubeArrayShadow(texture_cube_map_array
, glsl_type::samplerCubeArrayShadow_type
),
1915 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1916 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1917 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1919 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1921 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1922 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1923 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1925 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1926 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1927 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1929 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1930 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1931 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1933 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1934 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1935 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1937 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1938 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1939 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1941 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1942 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1943 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1945 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1946 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1947 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1949 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1950 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1951 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1953 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1956 add_function("textureLod",
1957 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1958 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1959 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1961 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1962 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1963 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1965 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1966 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1967 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1969 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1970 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1971 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1973 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1974 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1976 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1977 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1978 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1980 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1981 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1982 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1984 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1985 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1986 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1988 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1991 add_function("textureOffset",
1992 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1993 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1994 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1996 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1997 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1998 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2000 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2001 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2002 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2004 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2005 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2006 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2008 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2010 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2011 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2013 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2014 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2015 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2017 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2018 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2019 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2021 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2022 /* The next one was forgotten in GLSL 1.30 spec. It's from
2023 * EXT_gpu_shader4 originally. It was added in 4.30 with the
2024 * wrong syntax. This was corrected in 4.40. 4.30 indicates
2025 * that it was intended to be included previously, so allow it
2028 _texture(ir_tex
, v130_desktop
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2030 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2031 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2032 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2034 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2035 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2036 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2038 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2039 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2040 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2042 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2043 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2045 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2046 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2047 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2049 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2050 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2051 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2053 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2056 add_function("textureProj",
2057 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2058 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2059 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2060 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2061 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2062 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2064 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2065 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2066 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2067 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2068 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2069 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2071 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2072 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2073 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2075 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2076 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2078 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2079 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2080 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2081 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2082 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2083 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2085 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2087 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2088 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2089 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2090 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2091 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2092 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2094 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2095 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2096 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2097 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2098 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2099 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2101 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2102 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2103 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2105 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2106 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2109 add_function("texelFetch",
2110 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
2111 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
2112 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
2114 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
2115 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
2116 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
2118 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
2119 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
2120 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
2122 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
2123 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
2124 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
2126 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
2127 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
2128 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
2130 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
2131 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
2132 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
2134 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
2135 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
2136 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
2138 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2139 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2140 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2142 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2143 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2144 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2147 add_function("texelFetchOffset",
2148 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2149 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2150 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
2152 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2153 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2154 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2156 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2157 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2158 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2160 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2161 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2162 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2164 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2165 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2166 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
2168 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2169 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2170 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
2174 add_function("textureProjOffset",
2175 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2176 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2177 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2178 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2179 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2180 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2182 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2183 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2184 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2185 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2186 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2187 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2189 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2190 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2191 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2193 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2194 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2196 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2197 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2198 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2199 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2200 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2201 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2203 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2205 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2206 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2207 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2208 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2209 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2210 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2212 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2213 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2214 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2215 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2216 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2217 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2219 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2220 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2221 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2223 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2224 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2227 add_function("textureLodOffset",
2228 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2229 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2230 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2232 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2233 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2234 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2236 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2237 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2238 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2240 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2241 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2243 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2244 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2245 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2247 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2248 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2249 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2251 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2254 add_function("textureProjLod",
2255 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2256 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2257 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2258 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2259 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2260 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2262 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2263 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2264 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2265 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2266 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2267 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2269 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2270 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2271 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2273 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2274 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2277 add_function("textureProjLodOffset",
2278 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2279 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2280 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2281 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2282 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2283 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2285 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2286 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2287 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2288 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2289 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2290 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2292 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2293 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2294 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2296 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2297 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2300 add_function("textureGrad",
2301 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2302 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2303 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2305 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2306 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2307 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2309 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2310 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2311 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2313 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2314 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2315 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2317 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2318 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2319 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2321 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2323 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2324 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2325 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2327 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2328 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2329 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2331 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2332 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2333 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2335 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2336 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2337 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2339 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2340 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2343 add_function("textureGradOffset",
2344 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2345 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2346 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2348 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2349 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2350 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2352 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2353 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2354 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2356 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2357 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2358 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2360 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2362 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2363 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2365 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2366 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2367 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2369 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2370 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2371 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2373 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2374 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2377 add_function("textureProjGrad",
2378 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2379 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2380 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2381 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2382 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2383 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2385 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2386 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2387 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2388 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2389 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2390 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2392 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2393 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2394 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2396 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2397 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2398 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2399 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2400 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2401 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2403 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2405 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2406 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2409 add_function("textureProjGradOffset",
2410 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2411 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2412 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2413 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2414 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2415 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2417 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2418 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2419 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2420 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2421 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2422 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2424 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2425 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2426 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2428 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2429 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2430 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2431 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2432 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2433 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2435 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2437 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2438 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2441 add_function("EmitVertex", _EmitVertex(), NULL
);
2442 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2443 add_function("EmitStreamVertex",
2444 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2445 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2447 add_function("EndStreamPrimitive",
2448 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2449 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2451 add_function("barrier", _barrier(), NULL
);
2453 add_function("textureQueryLOD",
2454 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2455 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2456 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2458 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2459 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2460 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2462 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2463 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2464 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2466 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2467 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2468 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2470 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2471 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2472 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2474 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2475 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2476 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2478 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2479 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2480 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2482 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2483 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2484 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2485 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2486 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2487 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2490 add_function("textureQueryLod",
2491 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2492 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2493 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2495 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2496 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2497 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2499 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2500 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2501 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2503 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2504 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2505 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2507 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2508 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2509 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2511 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2512 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2513 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2515 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2516 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2517 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2519 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2520 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2521 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2522 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2523 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2524 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2527 add_function("textureQueryLevels",
2528 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1D_type
),
2529 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2D_type
),
2530 _textureQueryLevels(texture_query_levels
, glsl_type::sampler3D_type
),
2531 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCube_type
),
2532 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArray_type
),
2533 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArray_type
),
2534 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArray_type
),
2535 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DShadow_type
),
2536 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DShadow_type
),
2537 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeShadow_type
),
2538 _textureQueryLevels(texture_query_levels
, glsl_type::sampler1DArrayShadow_type
),
2539 _textureQueryLevels(texture_query_levels
, glsl_type::sampler2DArrayShadow_type
),
2540 _textureQueryLevels(texture_query_levels
, glsl_type::samplerCubeArrayShadow_type
),
2542 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1D_type
),
2543 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2D_type
),
2544 _textureQueryLevels(texture_query_levels
, glsl_type::isampler3D_type
),
2545 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCube_type
),
2546 _textureQueryLevels(texture_query_levels
, glsl_type::isampler1DArray_type
),
2547 _textureQueryLevels(texture_query_levels
, glsl_type::isampler2DArray_type
),
2548 _textureQueryLevels(texture_query_levels
, glsl_type::isamplerCubeArray_type
),
2550 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1D_type
),
2551 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2D_type
),
2552 _textureQueryLevels(texture_query_levels
, glsl_type::usampler3D_type
),
2553 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCube_type
),
2554 _textureQueryLevels(texture_query_levels
, glsl_type::usampler1DArray_type
),
2555 _textureQueryLevels(texture_query_levels
, glsl_type::usampler2DArray_type
),
2556 _textureQueryLevels(texture_query_levels
, glsl_type::usamplerCubeArray_type
),
2560 add_function("textureSamplesIdenticalEXT",
2561 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2562 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2563 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2565 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2566 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2567 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2570 add_function("texture1D",
2571 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2572 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2575 add_function("texture1DArray",
2576 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2577 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2580 add_function("texture1DProj",
2581 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2582 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2583 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2584 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2587 add_function("texture1DLod",
2588 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2591 add_function("texture1DArrayLod",
2592 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2595 add_function("texture1DProjLod",
2596 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2597 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2600 add_function("texture2D",
2601 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2602 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2603 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2606 add_function("texture2DArray",
2607 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2608 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2611 add_function("texture2DProj",
2612 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2613 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2614 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2615 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2616 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2617 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2620 add_function("texture2DLod",
2621 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2624 add_function("texture2DArrayLod",
2625 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2628 add_function("texture2DProjLod",
2629 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2630 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2633 add_function("texture3D",
2634 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2635 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2638 add_function("texture3DProj",
2639 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2640 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2643 add_function("texture3DLod",
2644 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2647 add_function("texture3DProjLod",
2648 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2651 add_function("textureCube",
2652 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2653 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2656 add_function("textureCubeLod",
2657 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2660 add_function("texture2DRect",
2661 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2664 add_function("texture2DRectProj",
2665 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2666 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2669 add_function("shadow1D",
2670 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2671 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2674 add_function("shadow1DArray",
2675 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2676 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2679 add_function("shadow2D",
2680 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2681 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2684 add_function("shadow2DArray",
2685 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2686 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2689 add_function("shadow1DProj",
2690 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2691 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2694 add_function("shadow2DProj",
2695 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2696 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2699 add_function("shadow1DLod",
2700 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2703 add_function("shadow2DLod",
2704 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2707 add_function("shadow1DArrayLod",
2708 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2711 add_function("shadow1DProjLod",
2712 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2715 add_function("shadow2DProjLod",
2716 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2719 add_function("shadow2DRect",
2720 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2723 add_function("shadow2DRectProj",
2724 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2727 add_function("texture1DGradARB",
2728 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2731 add_function("texture1DProjGradARB",
2732 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2733 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2736 add_function("texture2DGradARB",
2737 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2740 add_function("texture2DProjGradARB",
2741 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2742 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2745 add_function("texture3DGradARB",
2746 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2749 add_function("texture3DProjGradARB",
2750 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2753 add_function("textureCubeGradARB",
2754 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2757 add_function("shadow1DGradARB",
2758 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2761 add_function("shadow1DProjGradARB",
2762 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2765 add_function("shadow2DGradARB",
2766 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2769 add_function("shadow2DProjGradARB",
2770 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2773 add_function("texture2DRectGradARB",
2774 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2777 add_function("texture2DRectProjGradARB",
2778 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2779 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2782 add_function("shadow2DRectGradARB",
2783 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2786 add_function("shadow2DRectProjGradARB",
2787 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2790 add_function("textureGather",
2791 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2792 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2793 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2795 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2796 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2797 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2799 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2800 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2801 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2803 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2804 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2805 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2807 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2808 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2809 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2811 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2812 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2813 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2815 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2816 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2817 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2819 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2820 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2821 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2823 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2824 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2825 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2827 _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
),
2828 _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
),
2829 _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
),
2831 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2832 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2833 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2834 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2835 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2838 add_function("textureGatherOffset",
2839 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2840 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2841 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2843 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2844 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2845 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2847 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2848 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2849 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2851 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2852 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2853 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2855 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2856 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2857 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2859 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2860 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2861 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2863 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2864 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2865 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2867 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2868 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2869 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2871 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2872 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2873 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2875 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2876 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2877 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2879 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2880 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2881 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2883 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2884 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2887 add_function("textureGatherOffsets",
2888 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2889 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2890 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2892 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2893 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2894 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2896 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2897 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2898 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2900 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2901 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2902 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2904 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2905 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2906 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2908 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2909 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2910 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2912 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2913 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2914 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2939 add_function("ldexp",
2940 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2941 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2942 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2943 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2944 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2945 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2946 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2947 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2950 add_function("frexp",
2951 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2952 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2953 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2954 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2955 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2956 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2957 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2958 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2960 add_function("uaddCarry",
2961 _uaddCarry(glsl_type::uint_type
),
2962 _uaddCarry(glsl_type::uvec2_type
),
2963 _uaddCarry(glsl_type::uvec3_type
),
2964 _uaddCarry(glsl_type::uvec4_type
),
2966 add_function("usubBorrow",
2967 _usubBorrow(glsl_type::uint_type
),
2968 _usubBorrow(glsl_type::uvec2_type
),
2969 _usubBorrow(glsl_type::uvec3_type
),
2970 _usubBorrow(glsl_type::uvec4_type
),
2972 add_function("imulExtended",
2973 _mulExtended(glsl_type::int_type
),
2974 _mulExtended(glsl_type::ivec2_type
),
2975 _mulExtended(glsl_type::ivec3_type
),
2976 _mulExtended(glsl_type::ivec4_type
),
2978 add_function("umulExtended",
2979 _mulExtended(glsl_type::uint_type
),
2980 _mulExtended(glsl_type::uvec2_type
),
2981 _mulExtended(glsl_type::uvec3_type
),
2982 _mulExtended(glsl_type::uvec4_type
),
2984 add_function("interpolateAtCentroid",
2985 _interpolateAtCentroid(glsl_type::float_type
),
2986 _interpolateAtCentroid(glsl_type::vec2_type
),
2987 _interpolateAtCentroid(glsl_type::vec3_type
),
2988 _interpolateAtCentroid(glsl_type::vec4_type
),
2990 add_function("interpolateAtOffset",
2991 _interpolateAtOffset(glsl_type::float_type
),
2992 _interpolateAtOffset(glsl_type::vec2_type
),
2993 _interpolateAtOffset(glsl_type::vec3_type
),
2994 _interpolateAtOffset(glsl_type::vec4_type
),
2996 add_function("interpolateAtSample",
2997 _interpolateAtSample(glsl_type::float_type
),
2998 _interpolateAtSample(glsl_type::vec2_type
),
2999 _interpolateAtSample(glsl_type::vec3_type
),
3000 _interpolateAtSample(glsl_type::vec4_type
),
3003 add_function("atomicCounter",
3004 _atomic_counter_op("__intrinsic_atomic_read",
3005 shader_atomic_counters
),
3007 add_function("atomicCounterIncrement",
3008 _atomic_counter_op("__intrinsic_atomic_increment",
3009 shader_atomic_counters
),
3011 add_function("atomicCounterDecrement",
3012 _atomic_counter_op("__intrinsic_atomic_predecrement",
3013 shader_atomic_counters
),
3016 add_function("atomicCounterAddARB",
3017 _atomic_counter_op1("__intrinsic_atomic_add",
3018 shader_atomic_counter_ops
),
3020 add_function("atomicCounterSubtractARB",
3021 _atomic_counter_op1("__intrinsic_atomic_sub",
3022 shader_atomic_counter_ops
),
3024 add_function("atomicCounterMinARB",
3025 _atomic_counter_op1("__intrinsic_atomic_min",
3026 shader_atomic_counter_ops
),
3028 add_function("atomicCounterMaxARB",
3029 _atomic_counter_op1("__intrinsic_atomic_max",
3030 shader_atomic_counter_ops
),
3032 add_function("atomicCounterAndARB",
3033 _atomic_counter_op1("__intrinsic_atomic_and",
3034 shader_atomic_counter_ops
),
3036 add_function("atomicCounterOrARB",
3037 _atomic_counter_op1("__intrinsic_atomic_or",
3038 shader_atomic_counter_ops
),
3040 add_function("atomicCounterXorARB",
3041 _atomic_counter_op1("__intrinsic_atomic_xor",
3042 shader_atomic_counter_ops
),
3044 add_function("atomicCounterExchangeARB",
3045 _atomic_counter_op1("__intrinsic_atomic_exchange",
3046 shader_atomic_counter_ops
),
3048 add_function("atomicCounterCompSwapARB",
3049 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3050 shader_atomic_counter_ops
),
3053 add_function("atomicCounterAdd",
3054 _atomic_counter_op1("__intrinsic_atomic_add",
3057 add_function("atomicCounterSubtract",
3058 _atomic_counter_op1("__intrinsic_atomic_sub",
3061 add_function("atomicCounterMin",
3062 _atomic_counter_op1("__intrinsic_atomic_min",
3065 add_function("atomicCounterMax",
3066 _atomic_counter_op1("__intrinsic_atomic_max",
3069 add_function("atomicCounterAnd",
3070 _atomic_counter_op1("__intrinsic_atomic_and",
3073 add_function("atomicCounterOr",
3074 _atomic_counter_op1("__intrinsic_atomic_or",
3077 add_function("atomicCounterXor",
3078 _atomic_counter_op1("__intrinsic_atomic_xor",
3081 add_function("atomicCounterExchange",
3082 _atomic_counter_op1("__intrinsic_atomic_exchange",
3085 add_function("atomicCounterCompSwap",
3086 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
3090 add_function("atomicAdd",
3091 _atomic_op2("__intrinsic_atomic_add",
3092 buffer_atomics_supported
,
3093 glsl_type::uint_type
),
3094 _atomic_op2("__intrinsic_atomic_add",
3095 buffer_atomics_supported
,
3096 glsl_type::int_type
),
3098 add_function("atomicMin",
3099 _atomic_op2("__intrinsic_atomic_min",
3100 buffer_atomics_supported
,
3101 glsl_type::uint_type
),
3102 _atomic_op2("__intrinsic_atomic_min",
3103 buffer_atomics_supported
,
3104 glsl_type::int_type
),
3106 add_function("atomicMax",
3107 _atomic_op2("__intrinsic_atomic_max",
3108 buffer_atomics_supported
,
3109 glsl_type::uint_type
),
3110 _atomic_op2("__intrinsic_atomic_max",
3111 buffer_atomics_supported
,
3112 glsl_type::int_type
),
3114 add_function("atomicAnd",
3115 _atomic_op2("__intrinsic_atomic_and",
3116 buffer_atomics_supported
,
3117 glsl_type::uint_type
),
3118 _atomic_op2("__intrinsic_atomic_and",
3119 buffer_atomics_supported
,
3120 glsl_type::int_type
),
3122 add_function("atomicOr",
3123 _atomic_op2("__intrinsic_atomic_or",
3124 buffer_atomics_supported
,
3125 glsl_type::uint_type
),
3126 _atomic_op2("__intrinsic_atomic_or",
3127 buffer_atomics_supported
,
3128 glsl_type::int_type
),
3130 add_function("atomicXor",
3131 _atomic_op2("__intrinsic_atomic_xor",
3132 buffer_atomics_supported
,
3133 glsl_type::uint_type
),
3134 _atomic_op2("__intrinsic_atomic_xor",
3135 buffer_atomics_supported
,
3136 glsl_type::int_type
),
3138 add_function("atomicExchange",
3139 _atomic_op2("__intrinsic_atomic_exchange",
3140 buffer_atomics_supported
,
3141 glsl_type::uint_type
),
3142 _atomic_op2("__intrinsic_atomic_exchange",
3143 buffer_atomics_supported
,
3144 glsl_type::int_type
),
3146 add_function("atomicCompSwap",
3147 _atomic_op3("__intrinsic_atomic_comp_swap",
3148 buffer_atomics_supported
,
3149 glsl_type::uint_type
),
3150 _atomic_op3("__intrinsic_atomic_comp_swap",
3151 buffer_atomics_supported
,
3152 glsl_type::int_type
),
3155 add_function("min3",
3156 _min3(glsl_type::float_type
),
3157 _min3(glsl_type::vec2_type
),
3158 _min3(glsl_type::vec3_type
),
3159 _min3(glsl_type::vec4_type
),
3161 _min3(glsl_type::int_type
),
3162 _min3(glsl_type::ivec2_type
),
3163 _min3(glsl_type::ivec3_type
),
3164 _min3(glsl_type::ivec4_type
),
3166 _min3(glsl_type::uint_type
),
3167 _min3(glsl_type::uvec2_type
),
3168 _min3(glsl_type::uvec3_type
),
3169 _min3(glsl_type::uvec4_type
),
3172 add_function("max3",
3173 _max3(glsl_type::float_type
),
3174 _max3(glsl_type::vec2_type
),
3175 _max3(glsl_type::vec3_type
),
3176 _max3(glsl_type::vec4_type
),
3178 _max3(glsl_type::int_type
),
3179 _max3(glsl_type::ivec2_type
),
3180 _max3(glsl_type::ivec3_type
),
3181 _max3(glsl_type::ivec4_type
),
3183 _max3(glsl_type::uint_type
),
3184 _max3(glsl_type::uvec2_type
),
3185 _max3(glsl_type::uvec3_type
),
3186 _max3(glsl_type::uvec4_type
),
3189 add_function("mid3",
3190 _mid3(glsl_type::float_type
),
3191 _mid3(glsl_type::vec2_type
),
3192 _mid3(glsl_type::vec3_type
),
3193 _mid3(glsl_type::vec4_type
),
3195 _mid3(glsl_type::int_type
),
3196 _mid3(glsl_type::ivec2_type
),
3197 _mid3(glsl_type::ivec3_type
),
3198 _mid3(glsl_type::ivec4_type
),
3200 _mid3(glsl_type::uint_type
),
3201 _mid3(glsl_type::uvec2_type
),
3202 _mid3(glsl_type::uvec3_type
),
3203 _mid3(glsl_type::uvec4_type
),
3206 add_image_functions(true);
3208 add_function("memoryBarrier",
3209 _memory_barrier("__intrinsic_memory_barrier",
3210 shader_image_load_store
),
3212 add_function("groupMemoryBarrier",
3213 _memory_barrier("__intrinsic_group_memory_barrier",
3216 add_function("memoryBarrierAtomicCounter",
3217 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
3218 compute_shader_supported
),
3220 add_function("memoryBarrierBuffer",
3221 _memory_barrier("__intrinsic_memory_barrier_buffer",
3222 compute_shader_supported
),
3224 add_function("memoryBarrierImage",
3225 _memory_barrier("__intrinsic_memory_barrier_image",
3226 compute_shader_supported
),
3228 add_function("memoryBarrierShared",
3229 _memory_barrier("__intrinsic_memory_barrier_shared",
3233 add_function("ballotARB", _ballot(), NULL
);
3235 add_function("readInvocationARB",
3236 _read_invocation(glsl_type::float_type
),
3237 _read_invocation(glsl_type::vec2_type
),
3238 _read_invocation(glsl_type::vec3_type
),
3239 _read_invocation(glsl_type::vec4_type
),
3241 _read_invocation(glsl_type::int_type
),
3242 _read_invocation(glsl_type::ivec2_type
),
3243 _read_invocation(glsl_type::ivec3_type
),
3244 _read_invocation(glsl_type::ivec4_type
),
3246 _read_invocation(glsl_type::uint_type
),
3247 _read_invocation(glsl_type::uvec2_type
),
3248 _read_invocation(glsl_type::uvec3_type
),
3249 _read_invocation(glsl_type::uvec4_type
),
3252 add_function("readFirstInvocationARB",
3253 _read_first_invocation(glsl_type::float_type
),
3254 _read_first_invocation(glsl_type::vec2_type
),
3255 _read_first_invocation(glsl_type::vec3_type
),
3256 _read_first_invocation(glsl_type::vec4_type
),
3258 _read_first_invocation(glsl_type::int_type
),
3259 _read_first_invocation(glsl_type::ivec2_type
),
3260 _read_first_invocation(glsl_type::ivec3_type
),
3261 _read_first_invocation(glsl_type::ivec4_type
),
3263 _read_first_invocation(glsl_type::uint_type
),
3264 _read_first_invocation(glsl_type::uvec2_type
),
3265 _read_first_invocation(glsl_type::uvec3_type
),
3266 _read_first_invocation(glsl_type::uvec4_type
),
3269 add_function("clock2x32ARB",
3270 _shader_clock(shader_clock
,
3271 glsl_type::uvec2_type
),
3274 add_function("clockARB",
3275 _shader_clock(shader_clock_int64
,
3276 glsl_type::uint64_t_type
),
3279 add_function("anyInvocationARB",
3280 _vote("__intrinsic_vote_any", vote
),
3283 add_function("allInvocationsARB",
3284 _vote("__intrinsic_vote_all", vote
),
3287 add_function("allInvocationsEqualARB",
3288 _vote("__intrinsic_vote_eq", vote
),
3291 add_function("anyInvocation",
3292 _vote("__intrinsic_vote_any", v460_desktop
),
3295 add_function("allInvocations",
3296 _vote("__intrinsic_vote_all", v460_desktop
),
3299 add_function("allInvocationsEqual",
3300 _vote("__intrinsic_vote_eq", v460_desktop
),
3303 add_function("__builtin_idiv64",
3304 generate_ir::idiv64(mem_ctx
, integer_functions_supported
),
3307 add_function("__builtin_imod64",
3308 generate_ir::imod64(mem_ctx
, integer_functions_supported
),
3311 add_function("__builtin_sign64",
3312 generate_ir::sign64(mem_ctx
, integer_functions_supported
),
3315 add_function("__builtin_udiv64",
3316 generate_ir::udiv64(mem_ctx
, integer_functions_supported
),
3319 add_function("__builtin_umod64",
3320 generate_ir::umod64(mem_ctx
, integer_functions_supported
),
3323 add_function("__builtin_umul64",
3324 generate_ir::umul64(mem_ctx
, integer_functions_supported
),
3335 builtin_builder::add_function(const char *name
, ...)
3339 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3343 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
3349 stuff
.push_tail(sig
);
3350 validate_ir_tree(&stuff
);
3353 f
->add_signature(sig
);
3357 shader
->symbols
->add_function(f
);
3361 builtin_builder::add_image_function(const char *name
,
3362 const char *intrinsic_name
,
3363 image_prototype_ctr prototype
,
3364 unsigned num_arguments
,
3366 enum ir_intrinsic_id intrinsic_id
)
3368 static const glsl_type
*const types
[] = {
3369 glsl_type::image1D_type
,
3370 glsl_type::image2D_type
,
3371 glsl_type::image3D_type
,
3372 glsl_type::image2DRect_type
,
3373 glsl_type::imageCube_type
,
3374 glsl_type::imageBuffer_type
,
3375 glsl_type::image1DArray_type
,
3376 glsl_type::image2DArray_type
,
3377 glsl_type::imageCubeArray_type
,
3378 glsl_type::image2DMS_type
,
3379 glsl_type::image2DMSArray_type
,
3380 glsl_type::iimage1D_type
,
3381 glsl_type::iimage2D_type
,
3382 glsl_type::iimage3D_type
,
3383 glsl_type::iimage2DRect_type
,
3384 glsl_type::iimageCube_type
,
3385 glsl_type::iimageBuffer_type
,
3386 glsl_type::iimage1DArray_type
,
3387 glsl_type::iimage2DArray_type
,
3388 glsl_type::iimageCubeArray_type
,
3389 glsl_type::iimage2DMS_type
,
3390 glsl_type::iimage2DMSArray_type
,
3391 glsl_type::uimage1D_type
,
3392 glsl_type::uimage2D_type
,
3393 glsl_type::uimage3D_type
,
3394 glsl_type::uimage2DRect_type
,
3395 glsl_type::uimageCube_type
,
3396 glsl_type::uimageBuffer_type
,
3397 glsl_type::uimage1DArray_type
,
3398 glsl_type::uimage2DArray_type
,
3399 glsl_type::uimageCubeArray_type
,
3400 glsl_type::uimage2DMS_type
,
3401 glsl_type::uimage2DMSArray_type
3404 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3406 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3407 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3408 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3409 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3410 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3411 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3412 num_arguments
, flags
, intrinsic_id
));
3415 shader
->symbols
->add_function(f
);
3419 builtin_builder::add_image_functions(bool glsl
)
3421 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3423 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3424 "__intrinsic_image_load",
3425 &builtin_builder::_image_prototype
, 0,
3426 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3427 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3428 IMAGE_FUNCTION_READ_ONLY
),
3429 ir_intrinsic_image_load
);
3431 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3432 "__intrinsic_image_store",
3433 &builtin_builder::_image_prototype
, 1,
3434 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3435 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3436 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3437 IMAGE_FUNCTION_WRITE_ONLY
),
3438 ir_intrinsic_image_store
);
3440 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3442 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3443 "__intrinsic_image_atomic_add",
3444 &builtin_builder::_image_prototype
, 1, atom_flags
,
3445 ir_intrinsic_image_atomic_add
);
3447 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3448 "__intrinsic_image_atomic_min",
3449 &builtin_builder::_image_prototype
, 1, atom_flags
,
3450 ir_intrinsic_image_atomic_min
);
3452 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3453 "__intrinsic_image_atomic_max",
3454 &builtin_builder::_image_prototype
, 1, atom_flags
,
3455 ir_intrinsic_image_atomic_max
);
3457 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3458 "__intrinsic_image_atomic_and",
3459 &builtin_builder::_image_prototype
, 1, atom_flags
,
3460 ir_intrinsic_image_atomic_and
);
3462 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3463 "__intrinsic_image_atomic_or",
3464 &builtin_builder::_image_prototype
, 1, atom_flags
,
3465 ir_intrinsic_image_atomic_or
);
3467 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3468 "__intrinsic_image_atomic_xor",
3469 &builtin_builder::_image_prototype
, 1, atom_flags
,
3470 ir_intrinsic_image_atomic_xor
);
3472 add_image_function((glsl
? "imageAtomicExchange" :
3473 "__intrinsic_image_atomic_exchange"),
3474 "__intrinsic_image_atomic_exchange",
3475 &builtin_builder::_image_prototype
, 1,
3476 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3477 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3478 ir_intrinsic_image_atomic_exchange
);
3480 add_image_function((glsl
? "imageAtomicCompSwap" :
3481 "__intrinsic_image_atomic_comp_swap"),
3482 "__intrinsic_image_atomic_comp_swap",
3483 &builtin_builder::_image_prototype
, 2, atom_flags
,
3484 ir_intrinsic_image_atomic_comp_swap
);
3486 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3487 "__intrinsic_image_size",
3488 &builtin_builder::_image_size_prototype
, 1,
3489 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
,
3490 ir_intrinsic_image_size
);
3492 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3493 "__intrinsic_image_samples",
3494 &builtin_builder::_image_samples_prototype
, 1,
3495 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3496 IMAGE_FUNCTION_MS_ONLY
,
3497 ir_intrinsic_image_samples
);
3501 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3503 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3507 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3509 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3513 builtin_builder::imm(bool b
, unsigned vector_elements
)
3515 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3519 builtin_builder::imm(float f
, unsigned vector_elements
)
3521 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3525 builtin_builder::imm(int i
, unsigned vector_elements
)
3527 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3531 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3533 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3537 builtin_builder::imm(double d
, unsigned vector_elements
)
3539 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3543 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3545 return new(mem_ctx
) ir_constant(type
, &data
);
3548 #define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)
3550 ir_dereference_variable
*
3551 builtin_builder::var_ref(ir_variable
*var
)
3553 return new(mem_ctx
) ir_dereference_variable(var
);
3556 ir_dereference_array
*
3557 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3559 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3562 /** Return an element of a matrix */
3564 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3566 return swizzle(array_ref(var
, column
), row
, 1);
3570 * Implementations of built-in functions:
3573 ir_function_signature
*
3574 builtin_builder::new_sig(const glsl_type
*return_type
,
3575 builtin_available_predicate avail
,
3581 ir_function_signature
*sig
=
3582 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3585 va_start(ap
, num_params
);
3586 for (int i
= 0; i
< num_params
; i
++) {
3587 plist
.push_tail(va_arg(ap
, ir_variable
*));
3591 sig
->replace_parameters(&plist
);
3595 #define MAKE_SIG(return_type, avail, ...) \
3596 ir_function_signature *sig = \
3597 new_sig(return_type, avail, __VA_ARGS__); \
3598 ir_factory body(&sig->body, mem_ctx); \
3599 sig->is_defined = true;
3601 #define MAKE_INTRINSIC(return_type, id, avail, ...) \
3602 ir_function_signature *sig = \
3603 new_sig(return_type, avail, __VA_ARGS__); \
3604 sig->intrinsic_id = id;
3606 ir_function_signature
*
3607 builtin_builder::unop(builtin_available_predicate avail
,
3608 ir_expression_operation opcode
,
3609 const glsl_type
*return_type
,
3610 const glsl_type
*param_type
)
3612 ir_variable
*x
= in_var(param_type
, "x");
3613 MAKE_SIG(return_type
, avail
, 1, x
);
3614 body
.emit(ret(expr(opcode
, x
)));
3618 #define UNOP(NAME, OPCODE, AVAIL) \
3619 ir_function_signature * \
3620 builtin_builder::_##NAME(const glsl_type *type) \
3622 return unop(&AVAIL, OPCODE, type, type); \
3625 #define UNOPA(NAME, OPCODE) \
3626 ir_function_signature * \
3627 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3629 return unop(avail, OPCODE, type, type); \
3632 ir_function_signature
*
3633 builtin_builder::binop(builtin_available_predicate avail
,
3634 ir_expression_operation opcode
,
3635 const glsl_type
*return_type
,
3636 const glsl_type
*param0_type
,
3637 const glsl_type
*param1_type
)
3639 ir_variable
*x
= in_var(param0_type
, "x");
3640 ir_variable
*y
= in_var(param1_type
, "y");
3641 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3642 body
.emit(ret(expr(opcode
, x
, y
)));
3646 #define BINOP(NAME, OPCODE, AVAIL) \
3647 ir_function_signature * \
3648 builtin_builder::_##NAME(const glsl_type *return_type, \
3649 const glsl_type *param0_type, \
3650 const glsl_type *param1_type) \
3652 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3656 * Angle and Trigonometry Functions @{
3659 ir_function_signature
*
3660 builtin_builder::_radians(const glsl_type
*type
)
3662 ir_variable
*degrees
= in_var(type
, "degrees");
3663 MAKE_SIG(type
, always_available
, 1, degrees
);
3664 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3668 ir_function_signature
*
3669 builtin_builder::_degrees(const glsl_type
*type
)
3671 ir_variable
*radians
= in_var(type
, "radians");
3672 MAKE_SIG(type
, always_available
, 1, radians
);
3673 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3677 UNOP(sin
, ir_unop_sin
, always_available
)
3678 UNOP(cos
, ir_unop_cos
, always_available
)
3680 ir_function_signature
*
3681 builtin_builder::_tan(const glsl_type
*type
)
3683 ir_variable
*theta
= in_var(type
, "theta");
3684 MAKE_SIG(type
, always_available
, 1, theta
);
3685 body
.emit(ret(div(sin(theta
), cos(theta
))));
3690 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3694 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3697 add(imm(M_PI_4f
- 1.0f
),
3700 mul(abs(x
), imm(p1
))))))))));
3704 * Generate a ir_call to a function with a set of parameters
3706 * The input \c params can either be a list of \c ir_variable or a list of
3707 * \c ir_dereference_variable. In the latter case, all nodes will be removed
3708 * from \c params and used directly as the parameters to the generated
3712 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3714 exec_list actual_params
;
3716 foreach_in_list_safe(ir_instruction
, ir
, ¶ms
) {
3717 ir_dereference_variable
*d
= ir
->as_dereference_variable();
3720 actual_params
.push_tail(d
);
3722 ir_variable
*var
= ir
->as_variable();
3723 assert(var
!= NULL
);
3724 actual_params
.push_tail(var_ref(var
));
3728 ir_function_signature
*sig
=
3729 f
->exact_matching_signature(NULL
, &actual_params
);
3733 ir_dereference_variable
*deref
=
3734 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3736 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3739 ir_function_signature
*
3740 builtin_builder::_asin(const glsl_type
*type
)
3742 ir_variable
*x
= in_var(type
, "x");
3743 MAKE_SIG(type
, always_available
, 1, x
);
3745 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3750 ir_function_signature
*
3751 builtin_builder::_acos(const glsl_type
*type
)
3753 ir_variable
*x
= in_var(type
, "x");
3754 MAKE_SIG(type
, always_available
, 1, x
);
3756 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3761 ir_function_signature
*
3762 builtin_builder::_atan2(const glsl_type
*type
)
3764 const unsigned n
= type
->vector_elements
;
3765 ir_variable
*y
= in_var(type
, "y");
3766 ir_variable
*x
= in_var(type
, "x");
3767 MAKE_SIG(type
, always_available
, 2, y
, x
);
3769 /* If we're on the left half-plane rotate the coordinates π/2 clock-wise
3770 * for the y=0 discontinuity to end up aligned with the vertical
3771 * discontinuity of atan(s/t) along t=0. This also makes sure that we
3772 * don't attempt to divide by zero along the vertical line, which may give
3773 * unspecified results on non-GLSL 4.1-capable hardware.
3775 ir_variable
*flip
= body
.make_temp(glsl_type::bvec(n
), "flip");
3776 body
.emit(assign(flip
, gequal(imm(0.0f
, n
), x
)));
3777 ir_variable
*s
= body
.make_temp(type
, "s");
3778 body
.emit(assign(s
, csel(flip
, abs(x
), y
)));
3779 ir_variable
*t
= body
.make_temp(type
, "t");
3780 body
.emit(assign(t
, csel(flip
, y
, abs(x
))));
3782 /* If the magnitude of the denominator exceeds some huge value, scale down
3783 * the arguments in order to prevent the reciprocal operation from flushing
3784 * its result to zero, which would cause precision problems, and for s
3785 * infinite would cause us to return a NaN instead of the correct finite
3788 * If fmin and fmax are respectively the smallest and largest positive
3789 * normalized floating point values representable by the implementation,
3790 * the constants below should be in agreement with:
3793 * scale <= 1 / fmin / fmax (for |t| >= huge)
3795 * In addition scale should be a negative power of two in order to avoid
3796 * loss of precision. The values chosen below should work for most usual
3797 * floating point representations with at least the dynamic range of ATI's
3798 * 24-bit representation.
3800 ir_constant
*huge
= imm(1e18f
, n
);
3801 ir_variable
*scale
= body
.make_temp(type
, "scale");
3802 body
.emit(assign(scale
, csel(gequal(abs(t
), huge
),
3803 imm(0.25f
, n
), imm(1.0f
, n
))));
3804 ir_variable
*rcp_scaled_t
= body
.make_temp(type
, "rcp_scaled_t");
3805 body
.emit(assign(rcp_scaled_t
, rcp(mul(t
, scale
))));
3806 ir_expression
*s_over_t
= mul(mul(s
, scale
), rcp_scaled_t
);
3808 /* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily
3809 * that ∞/∞ = 1) in order to comply with the rather artificial rules
3810 * inherited from IEEE 754-2008, namely:
3812 * "atan2(±∞, −∞) is ±3π/4
3813 * atan2(±∞, +∞) is ±π/4"
3815 * Note that this is inconsistent with the rules for the neighborhood of
3816 * zero that are based on iterated limits:
3818 * "atan2(±0, −0) is ±π
3819 * atan2(±0, +0) is ±0"
3821 * but GLSL specifically allows implementations to deviate from IEEE rules
3822 * at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as
3825 ir_expression
*tan
= csel(equal(abs(x
), abs(y
)),
3826 imm(1.0f
, n
), abs(s_over_t
));
3828 /* Calculate the arctangent and fix up the result if we had flipped the
3829 * coordinate system.
3831 ir_variable
*arc
= body
.make_temp(type
, "arc");
3832 do_atan(body
, type
, arc
, tan
);
3833 body
.emit(assign(arc
, add(arc
, mul(b2f(flip
), imm(M_PI_2f
)))));
3835 /* Rather convoluted calculation of the sign of the result. When x < 0 we
3836 * cannot use fsign because we need to be able to distinguish between
3837 * negative and positive zero. Unfortunately we cannot use bitwise
3838 * arithmetic tricks either because of back-ends without integer support.
3839 * When x >= 0 rcp_scaled_t will always be non-negative so this won't be
3840 * able to distinguish between negative and positive zero, but we don't
3841 * care because atan2 is continuous along the whole positive y = 0
3842 * half-line, so it won't affect the result significantly.
3844 body
.emit(ret(csel(less(min2(y
, rcp_scaled_t
), imm(0.0f
, n
)),
3851 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3854 * range-reduction, first step:
3856 * / y_over_x if |y_over_x| <= 1.0;
3858 * \ 1.0 / y_over_x otherwise
3860 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3861 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3867 * approximate atan by evaluating polynomial:
3869 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3870 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3871 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3873 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3874 body
.emit(assign(tmp
, mul(x
, x
)));
3875 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3877 imm(0.0536813784310406f
)),
3879 imm(0.1173503194786851f
)),
3881 imm(0.1938924977115610f
)),
3883 imm(0.3326756418091246f
)),
3885 imm(0.9999793128310355f
)),
3888 /* range-reduction fixup */
3889 body
.emit(assign(tmp
, add(tmp
,
3890 mul(b2f(greater(abs(y_over_x
),
3891 imm(1.0f
, type
->components()))),
3897 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3900 ir_function_signature
*
3901 builtin_builder::_atan(const glsl_type
*type
)
3903 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3904 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3906 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3907 do_atan(body
, type
, tmp
, y_over_x
);
3908 body
.emit(ret(tmp
));
3913 ir_function_signature
*
3914 builtin_builder::_sinh(const glsl_type
*type
)
3916 ir_variable
*x
= in_var(type
, "x");
3917 MAKE_SIG(type
, v130
, 1, x
);
3919 /* 0.5 * (e^x - e^(-x)) */
3920 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3925 ir_function_signature
*
3926 builtin_builder::_cosh(const glsl_type
*type
)
3928 ir_variable
*x
= in_var(type
, "x");
3929 MAKE_SIG(type
, v130
, 1, x
);
3931 /* 0.5 * (e^x + e^(-x)) */
3932 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3937 ir_function_signature
*
3938 builtin_builder::_tanh(const glsl_type
*type
)
3940 ir_variable
*x
= in_var(type
, "x");
3941 MAKE_SIG(type
, v130
, 1, x
);
3943 /* tanh(x) := (0.5 * (e^x - e^(-x))) / (0.5 * (e^x + e^(-x)))
3945 * With a little algebra this reduces to (e^2x - 1) / (e^2x + 1)
3947 * Clamp x to (-inf, +10] to avoid precision problems. When x > 10, e^2x
3948 * is so much larger than 1.0 that 1.0 gets flushed to zero in the
3949 * computation e^2x +/- 1 so it can be ignored.
3951 ir_variable
*t
= body
.make_temp(type
, "tmp");
3952 body
.emit(assign(t
, min2(x
, imm(10.0f
))));
3954 body
.emit(ret(div(sub(exp(mul(t
, imm(2.0f
))), imm(1.0f
)),
3955 add(exp(mul(t
, imm(2.0f
))), imm(1.0f
)))));
3960 ir_function_signature
*
3961 builtin_builder::_asinh(const glsl_type
*type
)
3963 ir_variable
*x
= in_var(type
, "x");
3964 MAKE_SIG(type
, v130
, 1, x
);
3966 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3971 ir_function_signature
*
3972 builtin_builder::_acosh(const glsl_type
*type
)
3974 ir_variable
*x
= in_var(type
, "x");
3975 MAKE_SIG(type
, v130
, 1, x
);
3977 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3981 ir_function_signature
*
3982 builtin_builder::_atanh(const glsl_type
*type
)
3984 ir_variable
*x
= in_var(type
, "x");
3985 MAKE_SIG(type
, v130
, 1, x
);
3987 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3988 sub(imm(1.0f
), x
))))));
3994 * Exponential Functions @{
3997 ir_function_signature
*
3998 builtin_builder::_pow(const glsl_type
*type
)
4000 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
4003 UNOP(exp
, ir_unop_exp
, always_available
)
4004 UNOP(log
, ir_unop_log
, always_available
)
4005 UNOP(exp2
, ir_unop_exp2
, always_available
)
4006 UNOP(log2
, ir_unop_log2
, always_available
)
4007 UNOPA(sqrt
, ir_unop_sqrt
)
4008 UNOPA(inversesqrt
, ir_unop_rsq
)
4012 UNOPA(abs
, ir_unop_abs
)
4013 UNOPA(sign
, ir_unop_sign
)
4014 UNOPA(floor
, ir_unop_floor
)
4015 UNOPA(trunc
, ir_unop_trunc
)
4016 UNOPA(round
, ir_unop_round_even
)
4017 UNOPA(roundEven
, ir_unop_round_even
)
4018 UNOPA(ceil
, ir_unop_ceil
)
4019 UNOPA(fract
, ir_unop_fract
)
4021 ir_function_signature
*
4022 builtin_builder::_mod(builtin_available_predicate avail
,
4023 const glsl_type
*x_type
, const glsl_type
*y_type
)
4025 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
4028 ir_function_signature
*
4029 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
4031 ir_variable
*x
= in_var(type
, "x");
4032 ir_variable
*i
= out_var(type
, "i");
4033 MAKE_SIG(type
, avail
, 2, x
, i
);
4035 ir_variable
*t
= body
.make_temp(type
, "t");
4036 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
4037 body
.emit(assign(i
, t
));
4038 body
.emit(ret(sub(x
, t
)));
4043 ir_function_signature
*
4044 builtin_builder::_min(builtin_available_predicate avail
,
4045 const glsl_type
*x_type
, const glsl_type
*y_type
)
4047 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
4050 ir_function_signature
*
4051 builtin_builder::_max(builtin_available_predicate avail
,
4052 const glsl_type
*x_type
, const glsl_type
*y_type
)
4054 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
4057 ir_function_signature
*
4058 builtin_builder::_clamp(builtin_available_predicate avail
,
4059 const glsl_type
*val_type
, const glsl_type
*bound_type
)
4061 ir_variable
*x
= in_var(val_type
, "x");
4062 ir_variable
*minVal
= in_var(bound_type
, "minVal");
4063 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
4064 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
4066 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
4071 ir_function_signature
*
4072 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
4074 ir_variable
*x
= in_var(val_type
, "x");
4075 ir_variable
*y
= in_var(val_type
, "y");
4076 ir_variable
*a
= in_var(blend_type
, "a");
4077 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4079 body
.emit(ret(lrp(x
, y
, a
)));
4084 ir_function_signature
*
4085 builtin_builder::_mix_sel(builtin_available_predicate avail
,
4086 const glsl_type
*val_type
,
4087 const glsl_type
*blend_type
)
4089 ir_variable
*x
= in_var(val_type
, "x");
4090 ir_variable
*y
= in_var(val_type
, "y");
4091 ir_variable
*a
= in_var(blend_type
, "a");
4092 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
4094 /* csel matches the ternary operator in that a selector of true choses the
4095 * first argument. This differs from mix(x, y, false) which choses the
4096 * second argument (to remain consistent with the interpolating version of
4097 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
4099 * To handle the behavior mismatch, reverse the x and y arguments.
4101 body
.emit(ret(csel(a
, y
, x
)));
4106 ir_function_signature
*
4107 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4109 ir_variable
*edge
= in_var(edge_type
, "edge");
4110 ir_variable
*x
= in_var(x_type
, "x");
4111 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
4113 ir_variable
*t
= body
.make_temp(x_type
, "t");
4114 if (x_type
->vector_elements
== 1) {
4115 /* Both are floats */
4116 if (edge_type
->is_double())
4117 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
4119 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
4120 } else if (edge_type
->vector_elements
== 1) {
4121 /* x is a vector but edge is a float */
4122 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4123 if (edge_type
->is_double())
4124 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
4126 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
4129 /* Both are vectors */
4130 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
4131 if (edge_type
->is_double())
4132 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
4135 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
4145 ir_function_signature
*
4146 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
4148 ir_variable
*edge0
= in_var(edge_type
, "edge0");
4149 ir_variable
*edge1
= in_var(edge_type
, "edge1");
4150 ir_variable
*x
= in_var(x_type
, "x");
4151 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
4153 /* From the GLSL 1.10 specification:
4156 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
4157 * return t * t * (3 - 2 * t);
4160 ir_variable
*t
= body
.make_temp(x_type
, "t");
4161 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
4162 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
4164 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
4169 ir_function_signature
*
4170 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
4172 ir_variable
*x
= in_var(type
, "x");
4173 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4175 body
.emit(ret(nequal(x
, x
)));
4180 ir_function_signature
*
4181 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
4183 ir_variable
*x
= in_var(type
, "x");
4184 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
4186 ir_constant_data infinities
;
4187 for (int i
= 0; i
< type
->vector_elements
; i
++) {
4188 switch (type
->base_type
) {
4189 case GLSL_TYPE_FLOAT
:
4190 infinities
.f
[i
] = INFINITY
;
4192 case GLSL_TYPE_DOUBLE
:
4193 infinities
.d
[i
] = INFINITY
;
4196 unreachable("unknown type");
4200 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
4205 ir_function_signature
*
4206 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
4208 ir_variable
*x
= in_var(type
, "x");
4209 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4210 body
.emit(ret(bitcast_f2i(x
)));
4214 ir_function_signature
*
4215 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
4217 ir_variable
*x
= in_var(type
, "x");
4218 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4219 body
.emit(ret(bitcast_f2u(x
)));
4223 ir_function_signature
*
4224 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
4226 ir_variable
*x
= in_var(type
, "x");
4227 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4228 body
.emit(ret(bitcast_i2f(x
)));
4232 ir_function_signature
*
4233 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
4235 ir_variable
*x
= in_var(type
, "x");
4236 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
4237 body
.emit(ret(bitcast_u2f(x
)));
4241 ir_function_signature
*
4242 builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail
, const glsl_type
*type
)
4244 ir_variable
*x
= in_var(type
, "x");
4245 MAKE_SIG(glsl_type::i64vec(type
->vector_elements
), avail
, 1, x
);
4246 body
.emit(ret(bitcast_d2i64(x
)));
4250 ir_function_signature
*
4251 builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail
, const glsl_type
*type
)
4253 ir_variable
*x
= in_var(type
, "x");
4254 MAKE_SIG(glsl_type::u64vec(type
->vector_elements
), avail
, 1, x
);
4255 body
.emit(ret(bitcast_d2u64(x
)));
4259 ir_function_signature
*
4260 builtin_builder::_int64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4262 ir_variable
*x
= in_var(type
, "x");
4263 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4264 body
.emit(ret(bitcast_i642d(x
)));
4268 ir_function_signature
*
4269 builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail
, const glsl_type
*type
)
4271 ir_variable
*x
= in_var(type
, "x");
4272 MAKE_SIG(glsl_type::dvec(type
->vector_elements
), avail
, 1, x
);
4273 body
.emit(ret(bitcast_u642d(x
)));
4277 ir_function_signature
*
4278 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
4280 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4281 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4282 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
4286 ir_function_signature
*
4287 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
4289 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4290 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4291 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
4295 ir_function_signature
*
4296 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
4298 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4299 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4300 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
4304 ir_function_signature
*
4305 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
4307 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
4308 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4309 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
4313 ir_function_signature
*
4314 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
4316 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4317 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4318 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
4322 ir_function_signature
*
4323 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
4325 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4326 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4327 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
4332 ir_function_signature
*
4333 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
4335 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4336 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4337 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
4341 ir_function_signature
*
4342 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
4344 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4345 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
4346 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
4350 ir_function_signature
*
4351 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
4353 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
4354 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
4355 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
4359 ir_function_signature
*
4360 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
4362 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
4363 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
4364 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
4368 ir_function_signature
*
4369 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
4371 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4372 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
4373 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
4377 ir_function_signature
*
4378 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
4380 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
4381 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4382 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
4386 ir_function_signature
*
4387 builtin_builder::_packInt2x32(builtin_available_predicate avail
)
4389 ir_variable
*v
= in_var(glsl_type::ivec2_type
, "v");
4390 MAKE_SIG(glsl_type::int64_t_type
, avail
, 1, v
);
4391 body
.emit(ret(expr(ir_unop_pack_int_2x32
, v
)));
4395 ir_function_signature
*
4396 builtin_builder::_unpackInt2x32(builtin_available_predicate avail
)
4398 ir_variable
*p
= in_var(glsl_type::int64_t_type
, "p");
4399 MAKE_SIG(glsl_type::ivec2_type
, avail
, 1, p
);
4400 body
.emit(ret(expr(ir_unop_unpack_int_2x32
, p
)));
4404 ir_function_signature
*
4405 builtin_builder::_packUint2x32(builtin_available_predicate avail
)
4407 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
4408 MAKE_SIG(glsl_type::uint64_t_type
, avail
, 1, v
);
4409 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, v
)));
4413 ir_function_signature
*
4414 builtin_builder::_unpackUint2x32(builtin_available_predicate avail
)
4416 ir_variable
*p
= in_var(glsl_type::uint64_t_type
, "p");
4417 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
4418 body
.emit(ret(expr(ir_unop_unpack_uint_2x32
, p
)));
4422 ir_function_signature
*
4423 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
4425 ir_variable
*x
= in_var(type
, "x");
4426 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
4428 body
.emit(ret(sqrt(dot(x
, x
))));
4433 ir_function_signature
*
4434 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
4436 ir_variable
*p0
= in_var(type
, "p0");
4437 ir_variable
*p1
= in_var(type
, "p1");
4438 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
4440 if (type
->vector_elements
== 1) {
4441 body
.emit(ret(abs(sub(p0
, p1
))));
4443 ir_variable
*p
= body
.make_temp(type
, "p");
4444 body
.emit(assign(p
, sub(p0
, p1
)));
4445 body
.emit(ret(sqrt(dot(p
, p
))));
4451 ir_function_signature
*
4452 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
4454 if (type
->vector_elements
== 1)
4455 return binop(avail
, ir_binop_mul
, type
, type
, type
);
4457 return binop(avail
, ir_binop_dot
,
4458 type
->get_base_type(), type
, type
);
4461 ir_function_signature
*
4462 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
4464 ir_variable
*a
= in_var(type
, "a");
4465 ir_variable
*b
= in_var(type
, "b");
4466 MAKE_SIG(type
, avail
, 2, a
, b
);
4468 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
4469 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
4471 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
4472 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
4477 ir_function_signature
*
4478 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
4480 ir_variable
*x
= in_var(type
, "x");
4481 MAKE_SIG(type
, avail
, 1, x
);
4483 if (type
->vector_elements
== 1) {
4484 body
.emit(ret(sign(x
)));
4486 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
4492 ir_function_signature
*
4493 builtin_builder::_ftransform()
4495 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
4497 /* ftransform() refers to global variables, and is always emitted
4498 * directly by ast_function.cpp. Just emit a prototype here so we
4499 * can recognize calls to it.
4504 ir_function_signature
*
4505 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
4507 ir_variable
*N
= in_var(type
, "N");
4508 ir_variable
*I
= in_var(type
, "I");
4509 ir_variable
*Nref
= in_var(type
, "Nref");
4510 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
4512 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
4513 ret(N
), ret(neg(N
))));
4518 ir_function_signature
*
4519 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
4521 ir_variable
*I
= in_var(type
, "I");
4522 ir_variable
*N
= in_var(type
, "N");
4523 MAKE_SIG(type
, avail
, 2, I
, N
);
4525 /* I - 2 * dot(N, I) * N */
4526 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
4531 ir_function_signature
*
4532 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
4534 ir_variable
*I
= in_var(type
, "I");
4535 ir_variable
*N
= in_var(type
, "N");
4536 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
4537 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4539 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4540 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4542 /* From the GLSL 1.10 specification:
4543 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4545 * return genType(0.0)
4547 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4549 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4550 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4551 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4552 mul(n_dot_i
, n_dot_i
)))))));
4553 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4554 ret(ir_constant::zero(mem_ctx
, type
)),
4555 ret(sub(mul(eta
, I
),
4556 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4561 ir_function_signature
*
4562 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4564 ir_variable
*x
= in_var(type
, "x");
4565 ir_variable
*y
= in_var(type
, "y");
4566 MAKE_SIG(type
, avail
, 2, x
, y
);
4568 ir_variable
*z
= body
.make_temp(type
, "z");
4569 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4570 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4577 ir_function_signature
*
4578 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4583 if (type
->is_double()) {
4584 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4585 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4587 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4588 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4590 MAKE_SIG(type
, avail
, 2, c
, r
);
4592 ir_variable
*m
= body
.make_temp(type
, "m");
4593 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4594 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4601 ir_function_signature
*
4602 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4604 const glsl_type
*transpose_type
=
4605 glsl_type::get_instance(orig_type
->base_type
,
4606 orig_type
->matrix_columns
,
4607 orig_type
->vector_elements
);
4609 ir_variable
*m
= in_var(orig_type
, "m");
4610 MAKE_SIG(transpose_type
, avail
, 1, m
);
4612 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4613 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4614 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4615 body
.emit(assign(array_ref(t
, j
),
4616 matrix_elt(m
, i
, j
),
4625 ir_function_signature
*
4626 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4628 ir_variable
*m
= in_var(type
, "m");
4629 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4631 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4632 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4637 ir_function_signature
*
4638 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4640 ir_variable
*m
= in_var(type
, "m");
4641 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4644 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4645 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4648 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4649 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4652 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4653 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4655 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4656 mul(matrix_elt(m
, 0, 1), f2
)),
4657 mul(matrix_elt(m
, 0, 2), f3
))));
4662 ir_function_signature
*
4663 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4665 ir_variable
*m
= in_var(type
, "m");
4666 const glsl_type
*btype
= type
->get_base_type();
4667 MAKE_SIG(btype
, avail
, 1, m
);
4669 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4670 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4671 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4672 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4673 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4674 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4675 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4676 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4677 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4678 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4679 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4680 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4681 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4682 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4683 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4684 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4685 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4686 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4687 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4689 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)))));
4690 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)))));
4691 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)))));
4692 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)))));
4693 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)))));
4694 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)))));
4695 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)))));
4696 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)))));
4697 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)))));
4698 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)))));
4699 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)))));
4700 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)))));
4701 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)))));
4702 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)))));
4703 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)))));
4704 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)))));
4705 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)))));
4706 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)))));
4707 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)))));
4709 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4711 body
.emit(assign(adj_0
,
4712 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4713 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4714 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4716 body
.emit(assign(adj_0
, neg(
4717 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4718 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4719 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4721 body
.emit(assign(adj_0
,
4722 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4723 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4724 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4726 body
.emit(assign(adj_0
, neg(
4727 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4728 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4729 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4732 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4737 ir_function_signature
*
4738 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4740 ir_variable
*m
= in_var(type
, "m");
4741 MAKE_SIG(type
, avail
, 1, m
);
4743 ir_variable
*adj
= body
.make_temp(type
, "adj");
4744 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4745 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4746 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4747 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4749 ir_expression
*det
=
4750 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4751 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4753 body
.emit(ret(div(adj
, det
)));
4757 ir_function_signature
*
4758 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4760 ir_variable
*m
= in_var(type
, "m");
4761 const glsl_type
*btype
= type
->get_base_type();
4762 MAKE_SIG(type
, avail
, 1, m
);
4764 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4765 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4766 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4768 body
.emit(assign(f11_22_21_12
,
4769 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4770 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4771 body
.emit(assign(f10_22_20_12
,
4772 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4773 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4774 body
.emit(assign(f10_21_20_11
,
4775 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4776 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4778 ir_variable
*adj
= body
.make_temp(type
, "adj");
4779 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4780 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4781 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4783 body
.emit(assign(array_ref(adj
, 0), neg(
4784 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4785 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4787 body
.emit(assign(array_ref(adj
, 1),
4788 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4789 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4791 body
.emit(assign(array_ref(adj
, 2), neg(
4792 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4793 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4796 body
.emit(assign(array_ref(adj
, 0),
4797 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4798 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4800 body
.emit(assign(array_ref(adj
, 1), neg(
4801 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4802 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4804 body
.emit(assign(array_ref(adj
, 2),
4805 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4806 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4809 ir_expression
*det
=
4810 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4811 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4812 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4814 body
.emit(ret(div(adj
, det
)));
4819 ir_function_signature
*
4820 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4822 ir_variable
*m
= in_var(type
, "m");
4823 const glsl_type
*btype
= type
->get_base_type();
4824 MAKE_SIG(type
, avail
, 1, m
);
4826 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4827 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4828 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4829 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4830 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4831 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4832 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4833 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4834 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4835 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4836 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4837 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4838 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4839 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4840 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4841 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4842 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4843 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4844 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4846 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)))));
4847 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)))));
4848 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)))));
4849 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)))));
4850 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)))));
4851 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)))));
4852 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)))));
4853 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)))));
4854 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)))));
4855 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)))));
4856 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)))));
4857 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)))));
4858 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)))));
4859 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)))));
4860 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)))));
4861 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)))));
4862 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)))));
4863 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)))));
4864 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)))));
4866 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4867 body
.emit(assign(array_ref(adj
, 0),
4868 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4869 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4870 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4872 body
.emit(assign(array_ref(adj
, 1), neg(
4873 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4874 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4875 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4877 body
.emit(assign(array_ref(adj
, 2),
4878 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4879 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4880 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4882 body
.emit(assign(array_ref(adj
, 3), neg(
4883 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4884 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4885 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4888 body
.emit(assign(array_ref(adj
, 0), neg(
4889 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4890 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4891 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4893 body
.emit(assign(array_ref(adj
, 1),
4894 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4895 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4896 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4898 body
.emit(assign(array_ref(adj
, 2), neg(
4899 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4900 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4901 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4903 body
.emit(assign(array_ref(adj
, 3),
4904 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4905 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4906 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4909 body
.emit(assign(array_ref(adj
, 0),
4910 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4911 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4912 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4914 body
.emit(assign(array_ref(adj
, 1), neg(
4915 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4916 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4917 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4919 body
.emit(assign(array_ref(adj
, 2),
4920 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4921 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4922 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4924 body
.emit(assign(array_ref(adj
, 3), neg(
4925 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4926 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4927 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4930 body
.emit(assign(array_ref(adj
, 0), neg(
4931 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4932 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4933 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4935 body
.emit(assign(array_ref(adj
, 1),
4936 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4937 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4938 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4940 body
.emit(assign(array_ref(adj
, 2), neg(
4941 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4942 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4943 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4945 body
.emit(assign(array_ref(adj
, 3),
4946 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4947 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4948 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4951 ir_expression
*det
=
4952 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4953 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4954 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4955 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4957 body
.emit(ret(div(adj
, det
)));
4963 ir_function_signature
*
4964 builtin_builder::_lessThan(builtin_available_predicate avail
,
4965 const glsl_type
*type
)
4967 return binop(avail
, ir_binop_less
,
4968 glsl_type::bvec(type
->vector_elements
), type
, type
);
4971 ir_function_signature
*
4972 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4973 const glsl_type
*type
)
4975 return binop(avail
, ir_binop_lequal
,
4976 glsl_type::bvec(type
->vector_elements
), type
, type
);
4979 ir_function_signature
*
4980 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4981 const glsl_type
*type
)
4983 return binop(avail
, ir_binop_greater
,
4984 glsl_type::bvec(type
->vector_elements
), type
, type
);
4987 ir_function_signature
*
4988 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4989 const glsl_type
*type
)
4991 return binop(avail
, ir_binop_gequal
,
4992 glsl_type::bvec(type
->vector_elements
), type
, type
);
4995 ir_function_signature
*
4996 builtin_builder::_equal(builtin_available_predicate avail
,
4997 const glsl_type
*type
)
4999 return binop(avail
, ir_binop_equal
,
5000 glsl_type::bvec(type
->vector_elements
), type
, type
);
5003 ir_function_signature
*
5004 builtin_builder::_notEqual(builtin_available_predicate avail
,
5005 const glsl_type
*type
)
5007 return binop(avail
, ir_binop_nequal
,
5008 glsl_type::bvec(type
->vector_elements
), type
, type
);
5011 ir_function_signature
*
5012 builtin_builder::_any(const glsl_type
*type
)
5014 ir_variable
*v
= in_var(type
, "v");
5015 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5017 const unsigned vec_elem
= v
->type
->vector_elements
;
5018 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
5023 ir_function_signature
*
5024 builtin_builder::_all(const glsl_type
*type
)
5026 ir_variable
*v
= in_var(type
, "v");
5027 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
5029 const unsigned vec_elem
= v
->type
->vector_elements
;
5030 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
5035 UNOP(not, ir_unop_logic_not
, always_available
)
5038 has_lod(const glsl_type
*sampler_type
)
5040 assert(sampler_type
->is_sampler());
5042 switch (sampler_type
->sampler_dimensionality
) {
5043 case GLSL_SAMPLER_DIM_RECT
:
5044 case GLSL_SAMPLER_DIM_BUF
:
5045 case GLSL_SAMPLER_DIM_MS
:
5052 ir_function_signature
*
5053 builtin_builder::_textureSize(builtin_available_predicate avail
,
5054 const glsl_type
*return_type
,
5055 const glsl_type
*sampler_type
)
5057 ir_variable
*s
= in_var(sampler_type
, "sampler");
5058 /* The sampler always exists; add optional lod later. */
5059 MAKE_SIG(return_type
, avail
, 1, s
);
5061 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
5062 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
5064 if (has_lod(sampler_type
)) {
5065 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5066 sig
->parameters
.push_tail(lod
);
5067 tex
->lod_info
.lod
= var_ref(lod
);
5069 tex
->lod_info
.lod
= imm(0u);
5072 body
.emit(ret(tex
));
5077 ir_function_signature
*
5078 builtin_builder::_textureSamples(builtin_available_predicate avail
,
5079 const glsl_type
*sampler_type
)
5081 ir_variable
*s
= in_var(sampler_type
, "sampler");
5082 MAKE_SIG(glsl_type::int_type
, avail
, 1, s
);
5084 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
5085 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
5086 body
.emit(ret(tex
));
5091 ir_function_signature
*
5092 builtin_builder::_texture(ir_texture_opcode opcode
,
5093 builtin_available_predicate avail
,
5094 const glsl_type
*return_type
,
5095 const glsl_type
*sampler_type
,
5096 const glsl_type
*coord_type
,
5099 ir_variable
*s
= in_var(sampler_type
, "sampler");
5100 ir_variable
*P
= in_var(coord_type
, "P");
5101 /* The sampler and coordinate always exist; add optional parameters later. */
5102 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5104 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
5105 tex
->set_sampler(var_ref(s
), return_type
);
5107 const int coord_size
= sampler_type
->coordinate_components();
5109 if (coord_size
== coord_type
->vector_elements
) {
5110 tex
->coordinate
= var_ref(P
);
5112 /* The incoming coordinate also has the projector or shadow comparator,
5113 * so we need to swizzle those away.
5115 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
5118 /* The projector is always in the last component. */
5119 if (flags
& TEX_PROJECT
)
5120 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
5122 if (sampler_type
->sampler_shadow
) {
5123 if (opcode
== ir_tg4
) {
5124 /* gather has refz as a separate parameter, immediately after the
5127 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
5128 sig
->parameters
.push_tail(refz
);
5129 tex
->shadow_comparator
= var_ref(refz
);
5131 /* The shadow comparator is normally in the Z component, but a few types
5132 * have sufficiently large coordinates that it's in W.
5134 tex
->shadow_comparator
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
5138 if (opcode
== ir_txl
) {
5139 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
5140 sig
->parameters
.push_tail(lod
);
5141 tex
->lod_info
.lod
= var_ref(lod
);
5142 } else if (opcode
== ir_txd
) {
5143 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5144 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
5145 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
5146 sig
->parameters
.push_tail(dPdx
);
5147 sig
->parameters
.push_tail(dPdy
);
5148 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
5149 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
5152 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
5153 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
5154 ir_variable
*offset
=
5155 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
5156 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
5157 sig
->parameters
.push_tail(offset
);
5158 tex
->offset
= var_ref(offset
);
5161 if (flags
& TEX_OFFSET_ARRAY
) {
5162 ir_variable
*offsets
=
5163 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
5164 "offsets", ir_var_const_in
);
5165 sig
->parameters
.push_tail(offsets
);
5166 tex
->offset
= var_ref(offsets
);
5169 if (opcode
== ir_tg4
) {
5170 if (flags
& TEX_COMPONENT
) {
5171 ir_variable
*component
=
5172 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
5173 sig
->parameters
.push_tail(component
);
5174 tex
->lod_info
.component
= var_ref(component
);
5177 tex
->lod_info
.component
= imm(0);
5181 /* The "bias" parameter comes /after/ the "offset" parameter, which is
5182 * inconsistent with both textureLodOffset and textureGradOffset.
5184 if (opcode
== ir_txb
) {
5185 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
5186 sig
->parameters
.push_tail(bias
);
5187 tex
->lod_info
.bias
= var_ref(bias
);
5190 body
.emit(ret(tex
));
5195 ir_function_signature
*
5196 builtin_builder::_textureCubeArrayShadow(builtin_available_predicate avail
,
5197 const glsl_type
*sampler_type
)
5199 ir_variable
*s
= in_var(sampler_type
, "sampler");
5200 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
5201 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
5202 MAKE_SIG(glsl_type::float_type
, avail
, 3, s
, P
, compare
);
5204 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
5205 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
5207 tex
->coordinate
= var_ref(P
);
5208 tex
->shadow_comparator
= var_ref(compare
);
5210 body
.emit(ret(tex
));
5215 ir_function_signature
*
5216 builtin_builder::_texelFetch(builtin_available_predicate avail
,
5217 const glsl_type
*return_type
,
5218 const glsl_type
*sampler_type
,
5219 const glsl_type
*coord_type
,
5220 const glsl_type
*offset_type
)
5222 ir_variable
*s
= in_var(sampler_type
, "sampler");
5223 ir_variable
*P
= in_var(coord_type
, "P");
5224 /* The sampler and coordinate always exist; add optional parameters later. */
5225 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5227 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
5228 tex
->coordinate
= var_ref(P
);
5229 tex
->set_sampler(var_ref(s
), return_type
);
5231 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
5232 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
5233 sig
->parameters
.push_tail(sample
);
5234 tex
->lod_info
.sample_index
= var_ref(sample
);
5235 tex
->op
= ir_txf_ms
;
5236 } else if (has_lod(sampler_type
)) {
5237 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
5238 sig
->parameters
.push_tail(lod
);
5239 tex
->lod_info
.lod
= var_ref(lod
);
5241 tex
->lod_info
.lod
= imm(0u);
5244 if (offset_type
!= NULL
) {
5245 ir_variable
*offset
=
5246 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
5247 sig
->parameters
.push_tail(offset
);
5248 tex
->offset
= var_ref(offset
);
5251 body
.emit(ret(tex
));
5256 ir_function_signature
*
5257 builtin_builder::_EmitVertex()
5259 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5261 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5262 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
5267 ir_function_signature
*
5268 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
5269 const glsl_type
*stream_type
)
5271 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5273 * "Emit the current values of output variables to the current output
5274 * primitive on stream stream. The argument to stream must be a constant
5275 * integral expression."
5277 ir_variable
*stream
=
5278 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5280 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5282 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
5287 ir_function_signature
*
5288 builtin_builder::_EndPrimitive()
5290 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
5292 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
5293 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
5298 ir_function_signature
*
5299 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
5300 const glsl_type
*stream_type
)
5302 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
5304 * "Completes the current output primitive on stream stream and starts
5305 * a new one. The argument to stream must be a constant integral
5308 ir_variable
*stream
=
5309 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
5311 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
5313 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
5318 ir_function_signature
*
5319 builtin_builder::_barrier()
5321 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
5323 body
.emit(new(mem_ctx
) ir_barrier());
5327 ir_function_signature
*
5328 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
5329 const glsl_type
*sampler_type
,
5330 const glsl_type
*coord_type
)
5332 ir_variable
*s
= in_var(sampler_type
, "sampler");
5333 ir_variable
*coord
= in_var(coord_type
, "coord");
5334 /* The sampler and coordinate always exist; add optional parameters later. */
5335 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
5337 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
5338 tex
->coordinate
= var_ref(coord
);
5339 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
5341 body
.emit(ret(tex
));
5346 ir_function_signature
*
5347 builtin_builder::_textureQueryLevels(builtin_available_predicate avail
,
5348 const glsl_type
*sampler_type
)
5350 ir_variable
*s
= in_var(sampler_type
, "sampler");
5351 const glsl_type
*return_type
= glsl_type::int_type
;
5352 MAKE_SIG(return_type
, avail
, 1, s
);
5354 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
5355 tex
->set_sampler(var_ref(s
), return_type
);
5357 body
.emit(ret(tex
));
5362 ir_function_signature
*
5363 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
5364 const glsl_type
*sampler_type
,
5365 const glsl_type
*coord_type
)
5367 ir_variable
*s
= in_var(sampler_type
, "sampler");
5368 ir_variable
*P
= in_var(coord_type
, "P");
5369 const glsl_type
*return_type
= glsl_type::bool_type
;
5370 MAKE_SIG(return_type
, avail
, 2, s
, P
);
5372 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
5373 tex
->coordinate
= var_ref(P
);
5374 tex
->set_sampler(var_ref(s
), return_type
);
5376 body
.emit(ret(tex
));
5381 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
5382 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
5383 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
5384 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
5385 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
5386 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
5388 ir_function_signature
*
5389 builtin_builder::_fwidth(const glsl_type
*type
)
5391 ir_variable
*p
= in_var(type
, "p");
5392 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
5394 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
5399 ir_function_signature
*
5400 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
5402 ir_variable
*p
= in_var(type
, "p");
5403 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5405 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
5406 abs(expr(ir_unop_dFdy_coarse
, p
)))));
5411 ir_function_signature
*
5412 builtin_builder::_fwidthFine(const glsl_type
*type
)
5414 ir_variable
*p
= in_var(type
, "p");
5415 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
5417 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
5418 abs(expr(ir_unop_dFdy_fine
, p
)))));
5423 ir_function_signature
*
5424 builtin_builder::_noise1(const glsl_type
*type
)
5426 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
5429 ir_function_signature
*
5430 builtin_builder::_noise2(const glsl_type
*type
)
5432 ir_variable
*p
= in_var(type
, "p");
5433 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
5435 ir_constant_data b_offset
;
5436 b_offset
.f
[0] = 601.0f
;
5437 b_offset
.f
[1] = 313.0f
;
5438 b_offset
.f
[2] = 29.0f
;
5439 b_offset
.f
[3] = 277.0f
;
5441 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5442 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5443 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
5444 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5445 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5446 body
.emit(assign(t
, a
, WRITEMASK_X
));
5447 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5453 ir_function_signature
*
5454 builtin_builder::_noise3(const glsl_type
*type
)
5456 ir_variable
*p
= in_var(type
, "p");
5457 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
5459 ir_constant_data b_offset
;
5460 b_offset
.f
[0] = 601.0f
;
5461 b_offset
.f
[1] = 313.0f
;
5462 b_offset
.f
[2] = 29.0f
;
5463 b_offset
.f
[3] = 277.0f
;
5465 ir_constant_data c_offset
;
5466 c_offset
.f
[0] = 1559.0f
;
5467 c_offset
.f
[1] = 113.0f
;
5468 c_offset
.f
[2] = 1861.0f
;
5469 c_offset
.f
[3] = 797.0f
;
5471 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5472 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5473 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5474 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
5475 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5476 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5477 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
5478 body
.emit(assign(t
, a
, WRITEMASK_X
));
5479 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5480 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5486 ir_function_signature
*
5487 builtin_builder::_noise4(const glsl_type
*type
)
5489 ir_variable
*p
= in_var(type
, "p");
5490 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
5492 ir_variable
*_p
= body
.make_temp(type
, "_p");
5494 ir_constant_data p_offset
;
5495 p_offset
.f
[0] = 1559.0f
;
5496 p_offset
.f
[1] = 113.0f
;
5497 p_offset
.f
[2] = 1861.0f
;
5498 p_offset
.f
[3] = 797.0f
;
5500 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
5502 ir_constant_data offset
;
5503 offset
.f
[0] = 601.0f
;
5504 offset
.f
[1] = 313.0f
;
5505 offset
.f
[2] = 29.0f
;
5506 offset
.f
[3] = 277.0f
;
5508 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5509 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5510 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5511 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
5512 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
5513 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5514 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
5515 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
5516 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
5517 body
.emit(assign(t
, a
, WRITEMASK_X
));
5518 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5519 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5520 body
.emit(assign(t
, d
, WRITEMASK_W
));
5526 ir_function_signature
*
5527 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
5529 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5530 ir_variable
*value
= in_var(type
, "value");
5531 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5532 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5533 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, value
, offset
,
5536 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5537 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5539 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
5540 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5541 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5546 ir_function_signature
*
5547 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5549 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5550 ir_variable
*base
= in_var(type
, "base");
5551 ir_variable
*insert
= in_var(type
, "insert");
5552 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5553 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5554 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 4, base
, insert
,
5557 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5558 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5560 body
.emit(ret(bitfield_insert(base
, insert
,
5561 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5562 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5567 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31_or_integer_functions
)
5569 ir_function_signature
*
5570 builtin_builder::_bitCount(const glsl_type
*type
)
5572 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_bit_count
,
5573 glsl_type::ivec(type
->vector_elements
), type
);
5576 ir_function_signature
*
5577 builtin_builder::_findLSB(const glsl_type
*type
)
5579 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_lsb
,
5580 glsl_type::ivec(type
->vector_elements
), type
);
5583 ir_function_signature
*
5584 builtin_builder::_findMSB(const glsl_type
*type
)
5586 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_msb
,
5587 glsl_type::ivec(type
->vector_elements
), type
);
5590 ir_function_signature
*
5591 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5593 ir_variable
*a
= in_var(type
, "a");
5594 ir_variable
*b
= in_var(type
, "b");
5595 ir_variable
*c
= in_var(type
, "c");
5596 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5598 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5603 ir_function_signature
*
5604 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5606 return binop(x_type
->is_double() ? fp64
: gpu_shader5_or_es31_or_integer_functions
,
5607 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5610 ir_function_signature
*
5611 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5613 ir_variable
*x
= in_var(x_type
, "x");
5614 ir_variable
*exponent
= out_var(exp_type
, "exp");
5615 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5617 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5619 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5623 ir_function_signature
*
5624 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5626 ir_variable
*x
= in_var(x_type
, "x");
5627 ir_variable
*exponent
= out_var(exp_type
, "exp");
5628 MAKE_SIG(x_type
, gpu_shader5_or_es31_or_integer_functions
, 2, x
, exponent
);
5630 const unsigned vec_elem
= x_type
->vector_elements
;
5631 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5632 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5634 /* Single-precision floating-point values are stored as
5639 * An exponent shift of 23 will shift the mantissa out, leaving only the
5640 * exponent and sign bit (which itself may be zero, if the absolute value
5641 * was taken before the bitcast and shift.
5643 ir_constant
*exponent_shift
= imm(23);
5644 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5646 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5648 /* Exponent of floating-point values in the range [0.5, 1.0). */
5649 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5651 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5652 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5654 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5655 * to unsigned integers to ensure that 1 bits aren't shifted in.
5657 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5658 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5659 imm(0, vec_elem
)))));
5661 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5662 body
.emit(assign(bits
, bitcast_f2u(x
)));
5663 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5664 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5665 imm(0u, vec_elem
)))));
5666 body
.emit(ret(bitcast_u2f(bits
)));
5671 ir_function_signature
*
5672 builtin_builder::_uaddCarry(const glsl_type
*type
)
5674 ir_variable
*x
= in_var(type
, "x");
5675 ir_variable
*y
= in_var(type
, "y");
5676 ir_variable
*carry
= out_var(type
, "carry");
5677 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, carry
);
5679 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5680 body
.emit(ret(add(x
, y
)));
5685 ir_function_signature
*
5686 builtin_builder::_usubBorrow(const glsl_type
*type
)
5688 ir_variable
*x
= in_var(type
, "x");
5689 ir_variable
*y
= in_var(type
, "y");
5690 ir_variable
*borrow
= out_var(type
, "borrow");
5691 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, borrow
);
5693 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5694 body
.emit(ret(sub(x
, y
)));
5700 * For both imulExtended() and umulExtended() built-ins.
5702 ir_function_signature
*
5703 builtin_builder::_mulExtended(const glsl_type
*type
)
5705 ir_variable
*x
= in_var(type
, "x");
5706 ir_variable
*y
= in_var(type
, "y");
5707 ir_variable
*msb
= out_var(type
, "msb");
5708 ir_variable
*lsb
= out_var(type
, "lsb");
5709 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31_or_integer_functions
, 4, x
, y
, msb
, lsb
);
5711 body
.emit(assign(msb
, imul_high(x
, y
)));
5712 body
.emit(assign(lsb
, mul(x
, y
)));
5717 ir_function_signature
*
5718 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5720 ir_variable
*interpolant
= in_var(type
, "interpolant");
5721 interpolant
->data
.must_be_shader_input
= 1;
5722 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5724 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5729 ir_function_signature
*
5730 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5732 ir_variable
*interpolant
= in_var(type
, "interpolant");
5733 interpolant
->data
.must_be_shader_input
= 1;
5734 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5735 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5737 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5742 ir_function_signature
*
5743 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5745 ir_variable
*interpolant
= in_var(type
, "interpolant");
5746 interpolant
->data
.must_be_shader_input
= 1;
5747 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5748 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5750 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5755 ir_function_signature
*
5756 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
,
5757 enum ir_intrinsic_id id
)
5759 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5760 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 1, counter
);
5764 ir_function_signature
*
5765 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
,
5766 enum ir_intrinsic_id id
)
5768 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5769 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5770 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 2, counter
, data
);
5774 ir_function_signature
*
5775 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
,
5776 enum ir_intrinsic_id id
)
5778 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5779 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5780 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5781 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 3, counter
, compare
, data
);
5785 ir_function_signature
*
5786 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5787 const glsl_type
*type
,
5788 enum ir_intrinsic_id id
)
5790 ir_variable
*atomic
= in_var(type
, "atomic");
5791 ir_variable
*data
= in_var(type
, "data");
5792 MAKE_INTRINSIC(type
, id
, avail
, 2, atomic
, data
);
5796 ir_function_signature
*
5797 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5798 const glsl_type
*type
,
5799 enum ir_intrinsic_id id
)
5801 ir_variable
*atomic
= in_var(type
, "atomic");
5802 ir_variable
*data1
= in_var(type
, "data1");
5803 ir_variable
*data2
= in_var(type
, "data2");
5804 MAKE_INTRINSIC(type
, id
, avail
, 3, atomic
, data1
, data2
);
5808 ir_function_signature
*
5809 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5810 builtin_available_predicate avail
)
5812 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5813 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5815 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5816 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5818 body
.emit(ret(retval
));
5822 ir_function_signature
*
5823 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5824 builtin_available_predicate avail
)
5826 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5827 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5828 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5830 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5832 /* Instead of generating an __intrinsic_atomic_sub, generate an
5833 * __intrinsic_atomic_add with the data parameter negated.
5835 if (strcmp("__intrinsic_atomic_sub", intrinsic
) == 0) {
5836 ir_variable
*const neg_data
=
5837 body
.make_temp(glsl_type::uint_type
, "neg_data");
5839 body
.emit(assign(neg_data
, neg(data
)));
5841 exec_list parameters
;
5843 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(counter
));
5844 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(neg_data
));
5846 ir_function
*const func
=
5847 shader
->symbols
->get_function("__intrinsic_atomic_add");
5848 ir_instruction
*const c
= call(func
, retval
, parameters
);
5851 assert(parameters
.is_empty());
5855 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5859 body
.emit(ret(retval
));
5863 ir_function_signature
*
5864 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
5865 builtin_available_predicate avail
)
5867 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5868 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5869 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5870 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5872 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5873 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5875 body
.emit(ret(retval
));
5879 ir_function_signature
*
5880 builtin_builder::_atomic_op2(const char *intrinsic
,
5881 builtin_available_predicate avail
,
5882 const glsl_type
*type
)
5884 ir_variable
*atomic
= in_var(type
, "atomic_var");
5885 ir_variable
*data
= in_var(type
, "atomic_data");
5886 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5888 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5889 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5891 body
.emit(ret(retval
));
5895 ir_function_signature
*
5896 builtin_builder::_atomic_op3(const char *intrinsic
,
5897 builtin_available_predicate avail
,
5898 const glsl_type
*type
)
5900 ir_variable
*atomic
= in_var(type
, "atomic_var");
5901 ir_variable
*data1
= in_var(type
, "atomic_data1");
5902 ir_variable
*data2
= in_var(type
, "atomic_data2");
5903 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5905 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5906 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5908 body
.emit(ret(retval
));
5912 ir_function_signature
*
5913 builtin_builder::_min3(const glsl_type
*type
)
5915 ir_variable
*x
= in_var(type
, "x");
5916 ir_variable
*y
= in_var(type
, "y");
5917 ir_variable
*z
= in_var(type
, "z");
5918 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5920 ir_expression
*min3
= min2(x
, min2(y
,z
));
5921 body
.emit(ret(min3
));
5926 ir_function_signature
*
5927 builtin_builder::_max3(const glsl_type
*type
)
5929 ir_variable
*x
= in_var(type
, "x");
5930 ir_variable
*y
= in_var(type
, "y");
5931 ir_variable
*z
= in_var(type
, "z");
5932 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5934 ir_expression
*max3
= max2(x
, max2(y
,z
));
5935 body
.emit(ret(max3
));
5940 ir_function_signature
*
5941 builtin_builder::_mid3(const glsl_type
*type
)
5943 ir_variable
*x
= in_var(type
, "x");
5944 ir_variable
*y
= in_var(type
, "y");
5945 ir_variable
*z
= in_var(type
, "z");
5946 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5948 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5949 body
.emit(ret(mid3
));
5954 static builtin_available_predicate
5955 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
5957 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
5958 type
->sampled_type
== GLSL_TYPE_FLOAT
)
5959 return shader_image_atomic_exchange_float
;
5961 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
5962 IMAGE_FUNCTION_AVAIL_ATOMIC
))
5963 return shader_image_atomic
;
5966 return shader_image_load_store
;
5969 ir_function_signature
*
5970 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5971 unsigned num_arguments
,
5974 const glsl_type
*data_type
= glsl_type::get_instance(
5975 image_type
->sampled_type
,
5976 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5978 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5979 glsl_type::void_type
: data_type
);
5981 /* Addressing arguments that are always present. */
5982 ir_variable
*image
= in_var(image_type
, "image");
5983 ir_variable
*coord
= in_var(
5984 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5986 ir_function_signature
*sig
= new_sig(
5987 ret_type
, get_image_available_predicate(image_type
, flags
),
5990 /* Sample index for multisample images. */
5991 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5992 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5994 /* Data arguments. */
5995 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5996 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5997 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5998 ralloc_free(arg_name
);
6001 /* Set the maximal set of qualifiers allowed for this image
6002 * built-in. Function calls with arguments having fewer
6003 * qualifiers than present in the prototype are allowed by the
6004 * spec, but not with more, i.e. this will make the compiler
6005 * accept everything that needs to be accepted, and reject cases
6006 * like loads from write-only or stores to read-only images.
6008 image
->data
.memory_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
6009 image
->data
.memory_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
6010 image
->data
.memory_coherent
= true;
6011 image
->data
.memory_volatile
= true;
6012 image
->data
.memory_restrict
= true;
6017 ir_function_signature
*
6018 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
6019 unsigned /* num_arguments */,
6020 unsigned /* flags */)
6022 const glsl_type
*ret_type
;
6023 unsigned num_components
= image_type
->coordinate_components();
6025 /* From the ARB_shader_image_size extension:
6026 * "Cube images return the dimensions of one face."
6028 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
6029 !image_type
->sampler_array
) {
6033 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
6034 * supported by mesa.
6036 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
6038 ir_variable
*image
= in_var(image_type
, "image");
6039 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
6041 /* Set the maximal set of qualifiers allowed for this image
6042 * built-in. Function calls with arguments having fewer
6043 * qualifiers than present in the prototype are allowed by the
6044 * spec, but not with more, i.e. this will make the compiler
6045 * accept everything that needs to be accepted, and reject cases
6046 * like loads from write-only or stores to read-only images.
6048 image
->data
.memory_read_only
= true;
6049 image
->data
.memory_write_only
= true;
6050 image
->data
.memory_coherent
= true;
6051 image
->data
.memory_volatile
= true;
6052 image
->data
.memory_restrict
= true;
6057 ir_function_signature
*
6058 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
6059 unsigned /* num_arguments */,
6060 unsigned /* flags */)
6062 ir_variable
*image
= in_var(image_type
, "image");
6063 ir_function_signature
*sig
=
6064 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
6066 /* Set the maximal set of qualifiers allowed for this image
6067 * built-in. Function calls with arguments having fewer
6068 * qualifiers than present in the prototype are allowed by the
6069 * spec, but not with more, i.e. this will make the compiler
6070 * accept everything that needs to be accepted, and reject cases
6071 * like loads from write-only or stores to read-only images.
6073 image
->data
.memory_read_only
= true;
6074 image
->data
.memory_write_only
= true;
6075 image
->data
.memory_coherent
= true;
6076 image
->data
.memory_volatile
= true;
6077 image
->data
.memory_restrict
= true;
6082 ir_function_signature
*
6083 builtin_builder::_image(image_prototype_ctr prototype
,
6084 const glsl_type
*image_type
,
6085 const char *intrinsic_name
,
6086 unsigned num_arguments
,
6088 enum ir_intrinsic_id id
)
6090 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
6091 num_arguments
, flags
);
6093 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
6094 ir_factory
body(&sig
->body
, mem_ctx
);
6095 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
6097 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
6098 body
.emit(call(f
, NULL
, sig
->parameters
));
6100 ir_variable
*ret_val
=
6101 body
.make_temp(sig
->return_type
, "_ret_val");
6102 body
.emit(call(f
, ret_val
, sig
->parameters
));
6103 body
.emit(ret(ret_val
));
6106 sig
->is_defined
= true;
6109 sig
->intrinsic_id
= id
;
6115 ir_function_signature
*
6116 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
,
6117 enum ir_intrinsic_id id
)
6119 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
6123 ir_function_signature
*
6124 builtin_builder::_memory_barrier(const char *intrinsic_name
,
6125 builtin_available_predicate avail
)
6127 MAKE_SIG(glsl_type::void_type
, avail
, 0);
6128 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6129 NULL
, sig
->parameters
));
6133 ir_function_signature
*
6134 builtin_builder::_ballot_intrinsic()
6136 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6137 MAKE_INTRINSIC(glsl_type::uint64_t_type
, ir_intrinsic_ballot
, shader_ballot
,
6142 ir_function_signature
*
6143 builtin_builder::_ballot()
6145 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6147 MAKE_SIG(glsl_type::uint64_t_type
, shader_ballot
, 1, value
);
6148 ir_variable
*retval
= body
.make_temp(glsl_type::uint64_t_type
, "retval");
6150 body
.emit(call(shader
->symbols
->get_function("__intrinsic_ballot"),
6151 retval
, sig
->parameters
));
6152 body
.emit(ret(retval
));
6156 ir_function_signature
*
6157 builtin_builder::_read_first_invocation_intrinsic(const glsl_type
*type
)
6159 ir_variable
*value
= in_var(type
, "value");
6160 MAKE_INTRINSIC(type
, ir_intrinsic_read_first_invocation
, shader_ballot
,
6165 ir_function_signature
*
6166 builtin_builder::_read_first_invocation(const glsl_type
*type
)
6168 ir_variable
*value
= in_var(type
, "value");
6170 MAKE_SIG(type
, shader_ballot
, 1, value
);
6171 ir_variable
*retval
= body
.make_temp(type
, "retval");
6173 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_first_invocation"),
6174 retval
, sig
->parameters
));
6175 body
.emit(ret(retval
));
6179 ir_function_signature
*
6180 builtin_builder::_read_invocation_intrinsic(const glsl_type
*type
)
6182 ir_variable
*value
= in_var(type
, "value");
6183 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6184 MAKE_INTRINSIC(type
, ir_intrinsic_read_invocation
, shader_ballot
,
6185 2, value
, invocation
);
6189 ir_function_signature
*
6190 builtin_builder::_read_invocation(const glsl_type
*type
)
6192 ir_variable
*value
= in_var(type
, "value");
6193 ir_variable
*invocation
= in_var(glsl_type::uint_type
, "invocation");
6195 MAKE_SIG(type
, shader_ballot
, 2, value
, invocation
);
6196 ir_variable
*retval
= body
.make_temp(type
, "retval");
6198 body
.emit(call(shader
->symbols
->get_function("__intrinsic_read_invocation"),
6199 retval
, sig
->parameters
));
6200 body
.emit(ret(retval
));
6204 ir_function_signature
*
6205 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
6206 const glsl_type
*type
)
6208 MAKE_INTRINSIC(type
, ir_intrinsic_shader_clock
, avail
, 0);
6212 ir_function_signature
*
6213 builtin_builder::_shader_clock(builtin_available_predicate avail
,
6214 const glsl_type
*type
)
6216 MAKE_SIG(type
, avail
, 0);
6218 ir_variable
*retval
= body
.make_temp(glsl_type::uvec2_type
, "clock_retval");
6220 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
6221 retval
, sig
->parameters
));
6223 if (type
== glsl_type::uint64_t_type
) {
6224 body
.emit(ret(expr(ir_unop_pack_uint_2x32
, retval
)));
6226 body
.emit(ret(retval
));
6232 ir_function_signature
*
6233 builtin_builder::_vote_intrinsic(builtin_available_predicate avail
,
6234 enum ir_intrinsic_id id
)
6236 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6237 MAKE_INTRINSIC(glsl_type::bool_type
, id
, avail
, 1, value
);
6241 ir_function_signature
*
6242 builtin_builder::_vote(const char *intrinsic_name
,
6243 builtin_available_predicate avail
)
6245 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
6247 MAKE_SIG(glsl_type::bool_type
, avail
, 1, value
);
6249 ir_variable
*retval
= body
.make_temp(glsl_type::bool_type
, "retval");
6251 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
6252 retval
, sig
->parameters
));
6253 body
.emit(ret(retval
));
6259 /******************************************************************************/
6261 /* The singleton instance of builtin_builder. */
6262 static builtin_builder builtins
;
6263 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
6266 * External API (exposing the built-in module to the rest of the compiler):
6270 _mesa_glsl_initialize_builtin_functions()
6272 mtx_lock(&builtins_lock
);
6273 builtins
.initialize();
6274 mtx_unlock(&builtins_lock
);
6278 _mesa_glsl_release_builtin_functions()
6280 mtx_lock(&builtins_lock
);
6282 mtx_unlock(&builtins_lock
);
6285 ir_function_signature
*
6286 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
6287 const char *name
, exec_list
*actual_parameters
)
6289 ir_function_signature
*s
;
6290 mtx_lock(&builtins_lock
);
6291 s
= builtins
.find(state
, name
, actual_parameters
);
6292 mtx_unlock(&builtins_lock
);
6298 _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state
*state
, const char *name
)
6302 mtx_lock(&builtins_lock
);
6303 f
= builtins
.shader
->symbols
->get_function(name
);
6305 foreach_in_list(ir_function_signature
, sig
, &f
->signatures
) {
6306 if (sig
->is_builtin_available(state
)) {
6312 mtx_unlock(&builtins_lock
);
6318 _mesa_glsl_get_builtin_function_shader()
6320 return builtins
.shader
;
6325 * Get the function signature for main from a shader
6327 ir_function_signature
*
6328 _mesa_get_main_function_signature(glsl_symbol_table
*symbols
)
6330 ir_function
*const f
= symbols
->get_function("main");
6332 exec_list void_parameters
;
6334 /* Look for the 'void main()' signature and ensure that it's defined.
6335 * This keeps the linker from accidentally pick a shader that just
6336 * contains a prototype for main.
6338 * We don't have to check for multiple definitions of main (in multiple
6339 * shaders) because that would have already been caught above.
6341 ir_function_signature
*sig
=
6342 f
->matching_signature(NULL
, &void_parameters
, false);
6343 if ((sig
!= NULL
) && sig
->is_defined
) {