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 #include "main/core.h" /* for struct gl_shader */
59 #include "main/shaderobj.h"
60 #include "ir_builder.h"
61 #include "glsl_parser_extras.h"
62 #include "program/prog_instruction.h"
65 #define M_PIf ((float) M_PI)
66 #define M_PI_2f ((float) M_PI_2)
67 #define M_PI_4f ((float) M_PI_4)
69 using namespace ir_builder
;
72 * Availability predicates:
76 always_available(const _mesa_glsl_parse_state
*)
82 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
84 return state
->stage
== MESA_SHADER_VERTEX
&&
85 state
->language_version
<= 130 &&
90 fs_only(const _mesa_glsl_parse_state
*state
)
92 return state
->stage
== MESA_SHADER_FRAGMENT
;
96 gs_only(const _mesa_glsl_parse_state
*state
)
98 return state
->stage
== MESA_SHADER_GEOMETRY
;
102 v110(const _mesa_glsl_parse_state
*state
)
104 return !state
->es_shader
;
108 v110_fs_only(const _mesa_glsl_parse_state
*state
)
110 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
114 v120(const _mesa_glsl_parse_state
*state
)
116 return state
->is_version(120, 300);
120 v130(const _mesa_glsl_parse_state
*state
)
122 return state
->is_version(130, 300);
126 v130_fs_only(const _mesa_glsl_parse_state
*state
)
128 return state
->is_version(130, 300) &&
129 state
->stage
== MESA_SHADER_FRAGMENT
;
133 v140(const _mesa_glsl_parse_state
*state
)
135 return state
->is_version(140, 0);
139 v400_fs_only(const _mesa_glsl_parse_state
*state
)
141 return state
->is_version(400, 0) &&
142 state
->stage
== MESA_SHADER_FRAGMENT
;
146 es31(const _mesa_glsl_parse_state
*state
)
148 return state
->is_version(0, 310);
152 texture_rectangle(const _mesa_glsl_parse_state
*state
)
154 return state
->ARB_texture_rectangle_enable
;
158 texture_external(const _mesa_glsl_parse_state
*state
)
160 return state
->OES_EGL_image_external_enable
;
163 /** True if texturing functions with explicit LOD are allowed. */
165 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
167 /* Texturing functions with "Lod" in their name exist:
168 * - In the vertex shader stage (for all languages)
169 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
170 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
172 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
173 * don't need to explicitly check state->es_shader.
175 return state
->stage
== MESA_SHADER_VERTEX
||
176 state
->is_version(130, 300) ||
177 state
->ARB_shader_texture_lod_enable
;
181 v110_lod(const _mesa_glsl_parse_state
*state
)
183 return !state
->es_shader
&& lod_exists_in_stage(state
);
187 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
189 return state
->ARB_shader_texture_lod_enable
;
193 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
195 return state
->ARB_shader_texture_lod_enable
&&
196 state
->ARB_texture_rectangle_enable
;
200 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
202 return state
->is_version(330, 300) ||
203 state
->ARB_shader_bit_encoding_enable
||
204 state
->ARB_gpu_shader5_enable
;
208 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
210 return state
->is_version(450, 310) ||
211 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
215 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
217 return state
->ARB_shading_language_packing_enable
||
218 state
->is_version(420, 300);
222 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
224 return state
->ARB_shading_language_packing_enable
||
225 state
->ARB_gpu_shader5_enable
||
226 state
->is_version(400, 300);
230 gpu_shader5(const _mesa_glsl_parse_state
*state
)
232 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
236 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
238 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
242 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
244 return state
->ARB_shading_language_packing_enable
||
245 state
->ARB_gpu_shader5_enable
||
246 state
->is_version(400, 310);
250 fs_gpu_shader5(const _mesa_glsl_parse_state
*state
)
252 return state
->stage
== MESA_SHADER_FRAGMENT
&&
253 (state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
);
258 texture_array_lod(const _mesa_glsl_parse_state
*state
)
260 return lod_exists_in_stage(state
) &&
261 state
->EXT_texture_array_enable
;
265 fs_texture_array(const _mesa_glsl_parse_state
*state
)
267 return state
->stage
== MESA_SHADER_FRAGMENT
&&
268 state
->EXT_texture_array_enable
;
272 texture_array(const _mesa_glsl_parse_state
*state
)
274 return state
->EXT_texture_array_enable
;
278 texture_multisample(const _mesa_glsl_parse_state
*state
)
280 return state
->is_version(150, 310) ||
281 state
->ARB_texture_multisample_enable
;
285 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
287 return state
->is_version(150, 320) ||
288 state
->ARB_texture_multisample_enable
||
289 state
->OES_texture_storage_multisample_2d_array_enable
;
293 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
295 return texture_multisample(state
) &&
296 state
->EXT_shader_samples_identical_enable
;
300 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
302 return texture_multisample_array(state
) &&
303 state
->EXT_shader_samples_identical_enable
;
307 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
309 return state
->stage
== MESA_SHADER_FRAGMENT
&&
310 (state
->is_version(400, 0) ||
311 state
->ARB_texture_cube_map_array_enable
);
315 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
317 return state
->is_version(400, 0) ||
318 state
->ARB_texture_cube_map_array_enable
;
322 texture_query_levels(const _mesa_glsl_parse_state
*state
)
324 return state
->is_version(430, 0) ||
325 state
->ARB_texture_query_levels_enable
;
329 texture_query_lod(const _mesa_glsl_parse_state
*state
)
331 return state
->stage
== MESA_SHADER_FRAGMENT
&&
332 state
->ARB_texture_query_lod_enable
;
336 texture_gather(const _mesa_glsl_parse_state
*state
)
338 return state
->is_version(400, 0) ||
339 state
->ARB_texture_gather_enable
||
340 state
->ARB_gpu_shader5_enable
;
344 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
346 return state
->is_version(400, 310) ||
347 state
->ARB_texture_gather_enable
||
348 state
->ARB_gpu_shader5_enable
;
351 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
352 * used for relaxation of const offset requirements.
355 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
357 return !state
->is_version(400, 0) &&
358 !state
->ARB_gpu_shader5_enable
&&
359 (state
->ARB_texture_gather_enable
||
360 state
->is_version(0, 310));
363 /* Desktop GL or OES_standard_derivatives + fragment shader only */
365 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
367 return state
->stage
== MESA_SHADER_FRAGMENT
&&
368 (state
->is_version(110, 300) ||
369 state
->OES_standard_derivatives_enable
);
373 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
375 return state
->stage
== MESA_SHADER_FRAGMENT
&&
376 (state
->is_version(450, 0) ||
377 state
->ARB_derivative_control_enable
);
381 tex1d_lod(const _mesa_glsl_parse_state
*state
)
383 return !state
->es_shader
&& lod_exists_in_stage(state
);
386 /** True if sampler3D exists */
388 tex3d(const _mesa_glsl_parse_state
*state
)
390 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
391 * OES_texture_3D extension, and in GLSL ES 3.00.
393 return !state
->es_shader
||
394 state
->OES_texture_3D_enable
||
395 state
->language_version
>= 300;
399 fs_tex3d(const _mesa_glsl_parse_state
*state
)
401 return state
->stage
== MESA_SHADER_FRAGMENT
&&
402 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
406 tex3d_lod(const _mesa_glsl_parse_state
*state
)
408 return tex3d(state
) && lod_exists_in_stage(state
);
412 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
414 return state
->has_atomic_counters();
418 shader_clock(const _mesa_glsl_parse_state
*state
)
420 return state
->ARB_shader_clock_enable
;
424 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
426 return state
->has_shader_storage_buffer_objects();
430 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
432 return state
->AMD_shader_trinary_minmax_enable
;
436 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
438 return (state
->is_version(420, 310) ||
439 state
->ARB_shader_image_load_store_enable
);
443 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
445 return (state
->is_version(420, 0) ||
446 state
->ARB_shader_image_load_store_enable
);
450 shader_image_size(const _mesa_glsl_parse_state
*state
)
452 return state
->is_version(430, 310) ||
453 state
->ARB_shader_image_size_enable
;
457 shader_samples(const _mesa_glsl_parse_state
*state
)
459 return state
->is_version(450, 0) ||
460 state
->ARB_shader_texture_image_samples_enable
;
464 gs_streams(const _mesa_glsl_parse_state
*state
)
466 return gpu_shader5(state
) && gs_only(state
);
470 fp64(const _mesa_glsl_parse_state
*state
)
472 return state
->has_double();
476 compute_shader(const _mesa_glsl_parse_state
*state
)
478 return state
->stage
== MESA_SHADER_COMPUTE
;
482 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
484 return compute_shader(state
) || shader_storage_buffer_object(state
);
488 barrier_supported(const _mesa_glsl_parse_state
*state
)
490 return compute_shader(state
) ||
491 state
->stage
== MESA_SHADER_TESS_CTRL
;
496 /******************************************************************************/
501 * builtin_builder: A singleton object representing the core of the built-in
504 * It generates IR for every built-in function signature, and organizes them
507 class builtin_builder
{
514 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
515 const char *name
, exec_list
*actual_parameters
);
518 * A shader to hold all the built-in signatures; created by this module.
520 * This includes signatures for every built-in, regardless of version or
521 * enabled extensions. The availability predicate associated with each
522 * signature allows matching_signature() to filter out the irrelevant ones.
529 /** Global variables used by built-in functions. */
530 ir_variable
*gl_ModelViewProjectionMatrix
;
531 ir_variable
*gl_Vertex
;
533 void create_shader();
534 void create_intrinsics();
535 void create_builtins();
538 * IR builder helpers:
540 * These convenience functions assist in emitting IR, but don't necessarily
541 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
544 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
545 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
546 ir_constant
*imm(float f
, unsigned vector_elements
=1);
547 ir_constant
*imm(int i
, unsigned vector_elements
=1);
548 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
549 ir_constant
*imm(double d
, unsigned vector_elements
=1);
550 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
551 ir_dereference_variable
*var_ref(ir_variable
*var
);
552 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
553 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
555 ir_expression
*asin_expr(ir_variable
*x
);
556 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
559 * Call function \param f with parameters specified as the linked
560 * list \param params of \c ir_variable objects. \param ret should
561 * point to the ir_variable that will hold the function return
562 * value, or be \c NULL if the function has void return type.
564 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
566 /** Create a new function and add the given signatures. */
567 void add_function(const char *name
, ...);
569 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
570 unsigned num_arguments
,
573 enum image_function_flags
{
574 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
575 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
576 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
577 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
578 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
579 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
580 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
581 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
585 * Create a new image built-in function for all known image types.
586 * \p flags is a bitfield of \c image_function_flags flags.
588 void add_image_function(const char *name
,
589 const char *intrinsic_name
,
590 image_prototype_ctr prototype
,
591 unsigned num_arguments
,
595 * Create new functions for all known image built-ins and types.
596 * If \p glsl is \c true, use the GLSL built-in names and emit code
597 * to call into the actual compiler intrinsic. If \p glsl is
598 * false, emit a function prototype with no body for each image
601 void add_image_functions(bool glsl
);
603 ir_function_signature
*new_sig(const glsl_type
*return_type
,
604 builtin_available_predicate avail
,
605 int num_params
, ...);
608 * Function signature generators:
611 ir_function_signature
*unop(builtin_available_predicate avail
,
612 ir_expression_operation opcode
,
613 const glsl_type
*return_type
,
614 const glsl_type
*param_type
);
615 ir_function_signature
*binop(builtin_available_predicate avail
,
616 ir_expression_operation opcode
,
617 const glsl_type
*return_type
,
618 const glsl_type
*param0_type
,
619 const glsl_type
*param1_type
);
621 #define B0(X) ir_function_signature *_##X();
622 #define B1(X) ir_function_signature *_##X(const glsl_type *);
623 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
624 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
625 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
626 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
663 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
664 const glsl_type
*val_type
,
665 const glsl_type
*blend_type
);
674 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
675 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
676 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
677 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
678 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
679 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
680 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
681 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
682 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
683 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
684 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
685 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
698 BA1(determinant_mat2
);
699 BA1(determinant_mat3
);
700 BA1(determinant_mat4
);
708 BA1(greaterThanEqual
);
717 /** Flags to _texture() */
718 #define TEX_PROJECT 1
720 #define TEX_COMPONENT 4
721 #define TEX_OFFSET_NONCONST 8
722 #define TEX_OFFSET_ARRAY 16
724 ir_function_signature
*_texture(ir_texture_opcode opcode
,
725 builtin_available_predicate avail
,
726 const glsl_type
*return_type
,
727 const glsl_type
*sampler_type
,
728 const glsl_type
*coord_type
,
730 B0(textureCubeArrayShadow
);
731 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
732 const glsl_type
*return_type
,
733 const glsl_type
*sampler_type
,
734 const glsl_type
*coord_type
,
735 const glsl_type
*offset_type
= NULL
);
739 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
740 const glsl_type
*stream_type
);
741 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
742 const glsl_type
*stream_type
);
745 BA2(textureQueryLod
);
746 B1(textureQueryLevels
);
747 BA2(textureSamplesIdentical
);
775 B1(interpolateAtCentroid
)
776 B1(interpolateAtOffset
)
777 B1(interpolateAtSample
)
779 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
);
780 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
781 builtin_available_predicate avail
);
783 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
784 const glsl_type
*type
);
785 ir_function_signature
*_atomic_op2(const char *intrinsic
,
786 builtin_available_predicate avail
,
787 const glsl_type
*type
);
788 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
789 const glsl_type
*type
);
790 ir_function_signature
*_atomic_op3(const char *intrinsic
,
791 builtin_available_predicate avail
,
792 const glsl_type
*type
);
798 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
799 unsigned num_arguments
,
801 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
802 unsigned num_arguments
,
804 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
805 unsigned num_arguments
,
807 ir_function_signature
*_image(image_prototype_ctr prototype
,
808 const glsl_type
*image_type
,
809 const char *intrinsic_name
,
810 unsigned num_arguments
,
813 ir_function_signature
*_memory_barrier_intrinsic(
814 builtin_available_predicate avail
);
815 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
816 builtin_available_predicate avail
);
818 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
819 const glsl_type
*type
);
820 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
821 const glsl_type
*type
);
832 } /* anonymous namespace */
835 * Core builtin_builder functionality:
838 builtin_builder::builtin_builder()
840 gl_ModelViewProjectionMatrix(NULL
),
846 builtin_builder::~builtin_builder()
848 ralloc_free(mem_ctx
);
851 ir_function_signature
*
852 builtin_builder::find(_mesa_glsl_parse_state
*state
,
853 const char *name
, exec_list
*actual_parameters
)
855 /* The shader currently being compiled requested a built-in function;
856 * it needs to link against builtin_builder::shader in order to get them.
858 * Even if we don't find a matching signature, we still need to do this so
859 * that the "no matching signature" error will list potential candidates
860 * from the available built-ins.
862 state
->uses_builtin_functions
= true;
864 ir_function
*f
= shader
->symbols
->get_function(name
);
868 ir_function_signature
*sig
=
869 f
->matching_signature(state
, actual_parameters
, true);
877 builtin_builder::initialize()
879 /* If already initialized, don't do it again. */
883 mem_ctx
= ralloc_context(NULL
);
890 builtin_builder::release()
892 ralloc_free(mem_ctx
);
900 builtin_builder::create_shader()
902 /* The target doesn't actually matter. There's no target for generic
903 * GLSL utility code that could be linked against any stage, so just
904 * arbitrarily pick GL_VERTEX_SHADER.
906 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
907 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
909 gl_ModelViewProjectionMatrix
=
910 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
911 "gl_ModelViewProjectionMatrix",
914 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
916 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
917 shader
->symbols
->add_variable(gl_Vertex
);
923 * Create ir_function and ir_function_signature objects for each
927 builtin_builder::create_intrinsics()
929 add_function("__intrinsic_atomic_read",
930 _atomic_counter_intrinsic(shader_atomic_counters
),
932 add_function("__intrinsic_atomic_increment",
933 _atomic_counter_intrinsic(shader_atomic_counters
),
935 add_function("__intrinsic_atomic_predecrement",
936 _atomic_counter_intrinsic(shader_atomic_counters
),
939 add_function("__intrinsic_atomic_add",
940 _atomic_intrinsic2(buffer_atomics_supported
,
941 glsl_type::uint_type
),
942 _atomic_intrinsic2(buffer_atomics_supported
,
943 glsl_type::int_type
),
945 add_function("__intrinsic_atomic_min",
946 _atomic_intrinsic2(buffer_atomics_supported
,
947 glsl_type::uint_type
),
948 _atomic_intrinsic2(buffer_atomics_supported
,
949 glsl_type::int_type
),
951 add_function("__intrinsic_atomic_max",
952 _atomic_intrinsic2(buffer_atomics_supported
,
953 glsl_type::uint_type
),
954 _atomic_intrinsic2(buffer_atomics_supported
,
955 glsl_type::int_type
),
957 add_function("__intrinsic_atomic_and",
958 _atomic_intrinsic2(buffer_atomics_supported
,
959 glsl_type::uint_type
),
960 _atomic_intrinsic2(buffer_atomics_supported
,
961 glsl_type::int_type
),
963 add_function("__intrinsic_atomic_or",
964 _atomic_intrinsic2(buffer_atomics_supported
,
965 glsl_type::uint_type
),
966 _atomic_intrinsic2(buffer_atomics_supported
,
967 glsl_type::int_type
),
969 add_function("__intrinsic_atomic_xor",
970 _atomic_intrinsic2(buffer_atomics_supported
,
971 glsl_type::uint_type
),
972 _atomic_intrinsic2(buffer_atomics_supported
,
973 glsl_type::int_type
),
975 add_function("__intrinsic_atomic_exchange",
976 _atomic_intrinsic2(buffer_atomics_supported
,
977 glsl_type::uint_type
),
978 _atomic_intrinsic2(buffer_atomics_supported
,
979 glsl_type::int_type
),
981 add_function("__intrinsic_atomic_comp_swap",
982 _atomic_intrinsic3(buffer_atomics_supported
,
983 glsl_type::uint_type
),
984 _atomic_intrinsic3(buffer_atomics_supported
,
985 glsl_type::int_type
),
988 add_image_functions(false);
990 add_function("__intrinsic_memory_barrier",
991 _memory_barrier_intrinsic(shader_image_load_store
),
993 add_function("__intrinsic_group_memory_barrier",
994 _memory_barrier_intrinsic(compute_shader
),
996 add_function("__intrinsic_memory_barrier_atomic_counter",
997 _memory_barrier_intrinsic(compute_shader
),
999 add_function("__intrinsic_memory_barrier_buffer",
1000 _memory_barrier_intrinsic(compute_shader
),
1002 add_function("__intrinsic_memory_barrier_image",
1003 _memory_barrier_intrinsic(compute_shader
),
1005 add_function("__intrinsic_memory_barrier_shared",
1006 _memory_barrier_intrinsic(compute_shader
),
1009 add_function("__intrinsic_shader_clock",
1010 _shader_clock_intrinsic(shader_clock
,
1011 glsl_type::uvec2_type
),
1016 * Create ir_function and ir_function_signature objects for each built-in.
1018 * Contains a list of every available built-in.
1021 builtin_builder::create_builtins()
1024 add_function(#NAME, \
1025 _##NAME(glsl_type::float_type), \
1026 _##NAME(glsl_type::vec2_type), \
1027 _##NAME(glsl_type::vec3_type), \
1028 _##NAME(glsl_type::vec4_type), \
1032 add_function(#NAME, \
1033 _##NAME(always_available, glsl_type::float_type), \
1034 _##NAME(always_available, glsl_type::vec2_type), \
1035 _##NAME(always_available, glsl_type::vec3_type), \
1036 _##NAME(always_available, glsl_type::vec4_type), \
1037 _##NAME(fp64, glsl_type::double_type), \
1038 _##NAME(fp64, glsl_type::dvec2_type), \
1039 _##NAME(fp64, glsl_type::dvec3_type), \
1040 _##NAME(fp64, glsl_type::dvec4_type), \
1043 #define FD130(NAME) \
1044 add_function(#NAME, \
1045 _##NAME(v130, glsl_type::float_type), \
1046 _##NAME(v130, glsl_type::vec2_type), \
1047 _##NAME(v130, glsl_type::vec3_type), \
1048 _##NAME(v130, glsl_type::vec4_type), \
1049 _##NAME(fp64, glsl_type::double_type), \
1050 _##NAME(fp64, glsl_type::dvec2_type), \
1051 _##NAME(fp64, glsl_type::dvec3_type), \
1052 _##NAME(fp64, glsl_type::dvec4_type), \
1055 #define FDGS5(NAME) \
1056 add_function(#NAME, \
1057 _##NAME(gpu_shader5, glsl_type::float_type), \
1058 _##NAME(gpu_shader5, glsl_type::vec2_type), \
1059 _##NAME(gpu_shader5, glsl_type::vec3_type), \
1060 _##NAME(gpu_shader5, glsl_type::vec4_type), \
1061 _##NAME(fp64, glsl_type::double_type), \
1062 _##NAME(fp64, glsl_type::dvec2_type), \
1063 _##NAME(fp64, glsl_type::dvec3_type), \
1064 _##NAME(fp64, glsl_type::dvec4_type), \
1068 add_function(#NAME, \
1069 _##NAME(glsl_type::float_type), \
1070 _##NAME(glsl_type::vec2_type), \
1071 _##NAME(glsl_type::vec3_type), \
1072 _##NAME(glsl_type::vec4_type), \
1073 _##NAME(glsl_type::int_type), \
1074 _##NAME(glsl_type::ivec2_type), \
1075 _##NAME(glsl_type::ivec3_type), \
1076 _##NAME(glsl_type::ivec4_type), \
1080 add_function(#NAME, \
1081 _##NAME(always_available, glsl_type::float_type), \
1082 _##NAME(always_available, glsl_type::vec2_type), \
1083 _##NAME(always_available, glsl_type::vec3_type), \
1084 _##NAME(always_available, glsl_type::vec4_type), \
1085 _##NAME(always_available, glsl_type::int_type), \
1086 _##NAME(always_available, glsl_type::ivec2_type), \
1087 _##NAME(always_available, glsl_type::ivec3_type), \
1088 _##NAME(always_available, glsl_type::ivec4_type), \
1089 _##NAME(fp64, glsl_type::double_type), \
1090 _##NAME(fp64, glsl_type::dvec2_type), \
1091 _##NAME(fp64, glsl_type::dvec3_type), \
1092 _##NAME(fp64, glsl_type::dvec4_type), \
1095 #define FIUD(NAME) \
1096 add_function(#NAME, \
1097 _##NAME(always_available, glsl_type::float_type), \
1098 _##NAME(always_available, glsl_type::vec2_type), \
1099 _##NAME(always_available, glsl_type::vec3_type), \
1100 _##NAME(always_available, glsl_type::vec4_type), \
1102 _##NAME(always_available, glsl_type::int_type), \
1103 _##NAME(always_available, glsl_type::ivec2_type), \
1104 _##NAME(always_available, glsl_type::ivec3_type), \
1105 _##NAME(always_available, glsl_type::ivec4_type), \
1107 _##NAME(v130, glsl_type::uint_type), \
1108 _##NAME(v130, glsl_type::uvec2_type), \
1109 _##NAME(v130, glsl_type::uvec3_type), \
1110 _##NAME(v130, glsl_type::uvec4_type), \
1111 _##NAME(fp64, glsl_type::double_type), \
1112 _##NAME(fp64, glsl_type::dvec2_type), \
1113 _##NAME(fp64, glsl_type::dvec3_type), \
1114 _##NAME(fp64, glsl_type::dvec4_type), \
1118 add_function(#NAME, \
1119 _##NAME(glsl_type::int_type), \
1120 _##NAME(glsl_type::ivec2_type), \
1121 _##NAME(glsl_type::ivec3_type), \
1122 _##NAME(glsl_type::ivec4_type), \
1124 _##NAME(glsl_type::uint_type), \
1125 _##NAME(glsl_type::uvec2_type), \
1126 _##NAME(glsl_type::uvec3_type), \
1127 _##NAME(glsl_type::uvec4_type), \
1130 #define FIUBD(NAME) \
1131 add_function(#NAME, \
1132 _##NAME(always_available, glsl_type::float_type), \
1133 _##NAME(always_available, glsl_type::vec2_type), \
1134 _##NAME(always_available, glsl_type::vec3_type), \
1135 _##NAME(always_available, glsl_type::vec4_type), \
1137 _##NAME(always_available, glsl_type::int_type), \
1138 _##NAME(always_available, glsl_type::ivec2_type), \
1139 _##NAME(always_available, glsl_type::ivec3_type), \
1140 _##NAME(always_available, glsl_type::ivec4_type), \
1142 _##NAME(v130, glsl_type::uint_type), \
1143 _##NAME(v130, glsl_type::uvec2_type), \
1144 _##NAME(v130, glsl_type::uvec3_type), \
1145 _##NAME(v130, glsl_type::uvec4_type), \
1147 _##NAME(always_available, glsl_type::bool_type), \
1148 _##NAME(always_available, glsl_type::bvec2_type), \
1149 _##NAME(always_available, glsl_type::bvec3_type), \
1150 _##NAME(always_available, glsl_type::bvec4_type), \
1152 _##NAME(fp64, glsl_type::double_type), \
1153 _##NAME(fp64, glsl_type::dvec2_type), \
1154 _##NAME(fp64, glsl_type::dvec3_type), \
1155 _##NAME(fp64, glsl_type::dvec4_type), \
1158 #define FIUD2_MIXED(NAME) \
1159 add_function(#NAME, \
1160 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1161 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1162 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1163 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1165 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1166 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1167 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1169 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1170 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1171 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1172 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1174 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1175 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1176 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1178 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1179 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1180 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1181 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1183 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1184 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1185 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1187 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1188 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1189 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1190 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1191 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1192 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1193 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1204 add_function("atan",
1205 _atan(glsl_type::float_type
),
1206 _atan(glsl_type::vec2_type
),
1207 _atan(glsl_type::vec3_type
),
1208 _atan(glsl_type::vec4_type
),
1209 _atan2(glsl_type::float_type
),
1210 _atan2(glsl_type::vec2_type
),
1211 _atan2(glsl_type::vec3_type
),
1212 _atan2(glsl_type::vec4_type
),
1238 _mod(glsl_type::float_type
, glsl_type::float_type
),
1239 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
1240 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
1241 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
1243 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
1244 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
1245 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
1247 _mod(glsl_type::double_type
, glsl_type::double_type
),
1248 _mod(glsl_type::dvec2_type
, glsl_type::double_type
),
1249 _mod(glsl_type::dvec3_type
, glsl_type::double_type
),
1250 _mod(glsl_type::dvec4_type
, glsl_type::double_type
),
1252 _mod(glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1253 _mod(glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1254 _mod(glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1264 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1265 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1266 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1267 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1269 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1270 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1271 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1273 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1274 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1275 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1276 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1278 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1279 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1280 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1282 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1283 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1284 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1285 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1287 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1288 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1289 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1290 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1292 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1293 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1294 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1295 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1297 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1298 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1299 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1300 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1302 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1303 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1304 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1305 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1308 add_function("step",
1309 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1310 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1311 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1312 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1314 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1315 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1316 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1317 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1318 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1319 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1320 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1322 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1323 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1324 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1327 add_function("smoothstep",
1328 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1329 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1330 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1331 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1333 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1334 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1335 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1336 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1337 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1338 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1339 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1341 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1342 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1343 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1351 add_function("intBitsToFloat",
1352 _intBitsToFloat(glsl_type::int_type
),
1353 _intBitsToFloat(glsl_type::ivec2_type
),
1354 _intBitsToFloat(glsl_type::ivec3_type
),
1355 _intBitsToFloat(glsl_type::ivec4_type
),
1357 add_function("uintBitsToFloat",
1358 _uintBitsToFloat(glsl_type::uint_type
),
1359 _uintBitsToFloat(glsl_type::uvec2_type
),
1360 _uintBitsToFloat(glsl_type::uvec3_type
),
1361 _uintBitsToFloat(glsl_type::uvec4_type
),
1364 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1365 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1366 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1367 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1368 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1369 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1370 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1371 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1372 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1373 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1374 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1375 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1382 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1383 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1386 add_function("ftransform", _ftransform(), NULL
);
1391 add_function("matrixCompMult",
1392 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1393 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1394 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1395 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1396 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1397 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1398 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1399 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1400 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1401 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1402 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1403 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1404 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1405 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1406 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1407 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1408 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1409 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1411 add_function("outerProduct",
1412 _outerProduct(v120
, glsl_type::mat2_type
),
1413 _outerProduct(v120
, glsl_type::mat3_type
),
1414 _outerProduct(v120
, glsl_type::mat4_type
),
1415 _outerProduct(v120
, glsl_type::mat2x3_type
),
1416 _outerProduct(v120
, glsl_type::mat2x4_type
),
1417 _outerProduct(v120
, glsl_type::mat3x2_type
),
1418 _outerProduct(v120
, glsl_type::mat3x4_type
),
1419 _outerProduct(v120
, glsl_type::mat4x2_type
),
1420 _outerProduct(v120
, glsl_type::mat4x3_type
),
1421 _outerProduct(fp64
, glsl_type::dmat2_type
),
1422 _outerProduct(fp64
, glsl_type::dmat3_type
),
1423 _outerProduct(fp64
, glsl_type::dmat4_type
),
1424 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1425 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1426 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1427 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1428 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1429 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1431 add_function("determinant",
1432 _determinant_mat2(v120
, glsl_type::mat2_type
),
1433 _determinant_mat3(v120
, glsl_type::mat3_type
),
1434 _determinant_mat4(v120
, glsl_type::mat4_type
),
1435 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1436 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1437 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1440 add_function("inverse",
1441 _inverse_mat2(v120
, glsl_type::mat2_type
),
1442 _inverse_mat3(v120
, glsl_type::mat3_type
),
1443 _inverse_mat4(v120
, glsl_type::mat4_type
),
1444 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1445 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1446 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1448 add_function("transpose",
1449 _transpose(v120
, glsl_type::mat2_type
),
1450 _transpose(v120
, glsl_type::mat3_type
),
1451 _transpose(v120
, glsl_type::mat4_type
),
1452 _transpose(v120
, glsl_type::mat2x3_type
),
1453 _transpose(v120
, glsl_type::mat2x4_type
),
1454 _transpose(v120
, glsl_type::mat3x2_type
),
1455 _transpose(v120
, glsl_type::mat3x4_type
),
1456 _transpose(v120
, glsl_type::mat4x2_type
),
1457 _transpose(v120
, glsl_type::mat4x3_type
),
1458 _transpose(fp64
, glsl_type::dmat2_type
),
1459 _transpose(fp64
, glsl_type::dmat3_type
),
1460 _transpose(fp64
, glsl_type::dmat4_type
),
1461 _transpose(fp64
, glsl_type::dmat2x3_type
),
1462 _transpose(fp64
, glsl_type::dmat2x4_type
),
1463 _transpose(fp64
, glsl_type::dmat3x2_type
),
1464 _transpose(fp64
, glsl_type::dmat3x4_type
),
1465 _transpose(fp64
, glsl_type::dmat4x2_type
),
1466 _transpose(fp64
, glsl_type::dmat4x3_type
),
1471 FIUD(greaterThanEqual
)
1476 _any(glsl_type::bvec2_type
),
1477 _any(glsl_type::bvec3_type
),
1478 _any(glsl_type::bvec4_type
),
1482 _all(glsl_type::bvec2_type
),
1483 _all(glsl_type::bvec3_type
),
1484 _all(glsl_type::bvec4_type
),
1488 _not(glsl_type::bvec2_type
),
1489 _not(glsl_type::bvec3_type
),
1490 _not(glsl_type::bvec4_type
),
1493 add_function("textureSize",
1494 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1495 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1496 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1498 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1499 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1500 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1502 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1503 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1504 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1506 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1507 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1508 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1510 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1511 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1512 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1514 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1515 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1516 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1517 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1518 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1519 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1521 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1522 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1524 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1525 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1526 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1527 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1529 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1530 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1531 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1532 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1534 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1535 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1536 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1537 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1538 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1539 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1541 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1542 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1543 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1546 add_function("textureSamples",
1547 _textureSamples(glsl_type::sampler2DMS_type
),
1548 _textureSamples(glsl_type::isampler2DMS_type
),
1549 _textureSamples(glsl_type::usampler2DMS_type
),
1551 _textureSamples(glsl_type::sampler2DMSArray_type
),
1552 _textureSamples(glsl_type::isampler2DMSArray_type
),
1553 _textureSamples(glsl_type::usampler2DMSArray_type
),
1556 add_function("texture",
1557 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1558 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1559 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1561 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1562 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1563 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1565 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1566 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1567 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1569 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1570 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1571 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1573 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1574 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1575 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1577 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1578 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1579 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1581 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1582 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1583 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1585 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1586 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1587 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1589 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1590 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1591 /* samplerCubeArrayShadow is special; it has an extra parameter
1592 * for the shadow comparitor since there is no vec5 type.
1594 _textureCubeArrayShadow(),
1596 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1597 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1598 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1600 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1602 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1603 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1604 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1606 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1607 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1608 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1610 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1611 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1612 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1614 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1615 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1616 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1618 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1619 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1620 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1622 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1623 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1624 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1626 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1627 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1628 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1630 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1631 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1632 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1634 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1637 add_function("textureLod",
1638 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1639 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1640 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1642 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1643 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1644 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1646 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1647 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1648 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1650 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1651 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1652 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1654 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1655 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1657 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1658 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1659 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1661 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1662 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1663 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1665 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1666 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1667 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1669 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1672 add_function("textureOffset",
1673 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1674 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1675 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1677 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1678 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1679 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1681 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1682 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1683 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1685 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1686 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1687 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1689 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1691 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1692 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1694 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1695 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1696 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1698 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1699 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1700 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1702 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1704 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1705 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1706 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1708 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1709 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1710 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1712 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1713 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1714 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1716 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1717 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1719 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1720 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1721 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1723 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1724 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1725 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1727 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1730 add_function("textureProj",
1731 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1732 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1733 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1734 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1735 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1736 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1738 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1739 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1740 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1741 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1742 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1743 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1745 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1746 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1747 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1749 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1750 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1752 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1753 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1754 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1755 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1756 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1757 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1759 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1761 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1762 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1763 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1764 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1765 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1766 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1768 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1769 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1770 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1771 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1772 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1773 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1775 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1776 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1777 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1779 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1780 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1783 add_function("texelFetch",
1784 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1785 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1786 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1788 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1789 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1790 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1792 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1793 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1794 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1796 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1797 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1798 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1800 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1801 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1802 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1804 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1805 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1806 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1808 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1809 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1810 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1812 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1813 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1814 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1816 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1817 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1818 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1821 add_function("texelFetchOffset",
1822 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1823 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1824 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1826 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1827 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1828 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1830 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1831 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1832 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1834 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1835 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1836 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1838 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1839 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1840 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1842 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1843 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1844 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1848 add_function("textureProjOffset",
1849 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1850 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1851 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1852 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1853 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1854 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1856 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1857 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1858 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1859 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1860 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1861 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1863 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1864 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1865 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1867 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1868 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1870 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1871 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1872 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1873 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1874 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1875 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1877 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1879 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1880 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1881 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1882 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1883 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1884 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1886 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1887 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1888 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1889 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1890 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1891 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1893 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1894 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1895 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1897 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1898 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1901 add_function("textureLodOffset",
1902 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1903 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1904 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1906 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1907 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1908 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1910 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1911 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1912 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1914 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1915 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1917 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1918 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1919 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1921 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1922 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1923 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1925 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1928 add_function("textureProjLod",
1929 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1930 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1931 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1932 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1933 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1934 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1936 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1937 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1938 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1939 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1940 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1941 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1943 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1944 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1945 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1947 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1948 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1951 add_function("textureProjLodOffset",
1952 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1953 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1954 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1955 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1956 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1957 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1959 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1960 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1961 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1962 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1963 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1964 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1966 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1967 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1968 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1970 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1971 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1974 add_function("textureGrad",
1975 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1976 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1977 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1979 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1980 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1981 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1983 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1984 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1985 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1987 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1988 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1989 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1991 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1992 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1993 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1995 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1997 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1998 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1999 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2001 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2002 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2003 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2005 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2006 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2007 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2009 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2010 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2011 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2013 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2014 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2017 add_function("textureGradOffset",
2018 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2019 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2020 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2022 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2023 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2024 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2026 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2027 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2028 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2030 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2031 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2032 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2034 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2036 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2037 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2039 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2040 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2041 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2043 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2044 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2045 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2047 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2048 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2051 add_function("textureProjGrad",
2052 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2053 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2054 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2055 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2056 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2057 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2059 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2060 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2061 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2062 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2063 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2064 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2066 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2067 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2068 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2070 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2071 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2072 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2073 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2074 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2075 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2077 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2079 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2080 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2083 add_function("textureProjGradOffset",
2084 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2085 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2086 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2087 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2088 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2089 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2091 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2092 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2093 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2094 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2095 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2096 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2098 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2099 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2100 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2102 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2103 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2104 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2105 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2106 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2107 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2109 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2111 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2112 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2115 add_function("EmitVertex", _EmitVertex(), NULL
);
2116 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2117 add_function("EmitStreamVertex",
2118 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2119 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2121 add_function("EndStreamPrimitive",
2122 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2123 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2125 add_function("barrier", _barrier(), NULL
);
2127 add_function("textureQueryLOD",
2128 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2129 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2130 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2132 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2133 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2134 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2136 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2137 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2138 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2140 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2141 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2142 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2144 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2145 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2146 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2148 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2149 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2150 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2152 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2153 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2154 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2156 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2157 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2158 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2159 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2160 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2161 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2164 add_function("textureQueryLod",
2165 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2166 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2167 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2169 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2170 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2171 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2173 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2174 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2175 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2177 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2178 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2179 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2181 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2182 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2183 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2185 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2186 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2187 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2189 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2190 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2191 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2193 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2194 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2195 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2196 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2197 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2198 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2201 add_function("textureQueryLevels",
2202 _textureQueryLevels(glsl_type::sampler1D_type
),
2203 _textureQueryLevels(glsl_type::sampler2D_type
),
2204 _textureQueryLevels(glsl_type::sampler3D_type
),
2205 _textureQueryLevels(glsl_type::samplerCube_type
),
2206 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2207 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2208 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2209 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2210 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2211 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2212 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2213 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2214 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2216 _textureQueryLevels(glsl_type::isampler1D_type
),
2217 _textureQueryLevels(glsl_type::isampler2D_type
),
2218 _textureQueryLevels(glsl_type::isampler3D_type
),
2219 _textureQueryLevels(glsl_type::isamplerCube_type
),
2220 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2221 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2222 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2224 _textureQueryLevels(glsl_type::usampler1D_type
),
2225 _textureQueryLevels(glsl_type::usampler2D_type
),
2226 _textureQueryLevels(glsl_type::usampler3D_type
),
2227 _textureQueryLevels(glsl_type::usamplerCube_type
),
2228 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2229 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2230 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2234 add_function("textureSamplesIdenticalEXT",
2235 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2236 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2237 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2239 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2240 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2241 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2244 add_function("texture1D",
2245 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2246 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2249 add_function("texture1DArray",
2250 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2251 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2254 add_function("texture1DProj",
2255 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2256 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2257 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2258 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2261 add_function("texture1DLod",
2262 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2265 add_function("texture1DArrayLod",
2266 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2269 add_function("texture1DProjLod",
2270 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2271 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2274 add_function("texture2D",
2275 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2276 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2277 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2280 add_function("texture2DArray",
2281 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2282 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2285 add_function("texture2DProj",
2286 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2287 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2288 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2289 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2290 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2291 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2294 add_function("texture2DLod",
2295 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2298 add_function("texture2DArrayLod",
2299 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2302 add_function("texture2DProjLod",
2303 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2304 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2307 add_function("texture3D",
2308 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2309 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2312 add_function("texture3DProj",
2313 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2314 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2317 add_function("texture3DLod",
2318 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2321 add_function("texture3DProjLod",
2322 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2325 add_function("textureCube",
2326 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2327 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2330 add_function("textureCubeLod",
2331 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2334 add_function("texture2DRect",
2335 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2338 add_function("texture2DRectProj",
2339 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2340 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2343 add_function("shadow1D",
2344 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2345 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2348 add_function("shadow1DArray",
2349 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2350 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2353 add_function("shadow2D",
2354 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2355 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2358 add_function("shadow2DArray",
2359 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2360 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2363 add_function("shadow1DProj",
2364 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2365 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2368 add_function("shadow2DProj",
2369 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2370 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2373 add_function("shadow1DLod",
2374 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2377 add_function("shadow2DLod",
2378 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2381 add_function("shadow1DArrayLod",
2382 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2385 add_function("shadow1DProjLod",
2386 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2389 add_function("shadow2DProjLod",
2390 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2393 add_function("shadow2DRect",
2394 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2397 add_function("shadow2DRectProj",
2398 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2401 add_function("texture1DGradARB",
2402 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2405 add_function("texture1DProjGradARB",
2406 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2407 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2410 add_function("texture2DGradARB",
2411 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2414 add_function("texture2DProjGradARB",
2415 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2416 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2419 add_function("texture3DGradARB",
2420 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2423 add_function("texture3DProjGradARB",
2424 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2427 add_function("textureCubeGradARB",
2428 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2431 add_function("shadow1DGradARB",
2432 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2435 add_function("shadow1DProjGradARB",
2436 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2439 add_function("shadow2DGradARB",
2440 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2443 add_function("shadow2DProjGradARB",
2444 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2447 add_function("texture2DRectGradARB",
2448 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2451 add_function("texture2DRectProjGradARB",
2452 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2453 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2456 add_function("shadow2DRectGradARB",
2457 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2460 add_function("shadow2DRectProjGradARB",
2461 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2464 add_function("textureGather",
2465 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2466 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2467 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2469 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2470 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2471 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2473 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2474 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2475 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2477 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2478 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2479 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2481 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2482 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2483 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2485 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2486 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2487 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2489 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2490 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2491 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2493 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2494 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2495 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2497 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2498 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2499 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2501 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2502 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2503 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2505 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2506 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2507 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2508 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2509 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2512 add_function("textureGatherOffset",
2513 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2514 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2515 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2517 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2518 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2519 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2521 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2522 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2523 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2525 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2526 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2527 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2529 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2530 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2531 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2533 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2534 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2535 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2537 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2538 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2539 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2541 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2542 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2543 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2545 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2546 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2547 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2549 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2550 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2551 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2553 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2554 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2555 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2557 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2558 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2561 add_function("textureGatherOffsets",
2562 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2563 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2564 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2566 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2567 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2568 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2570 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2571 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2572 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2574 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2575 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2576 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2578 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2579 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2580 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2582 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2583 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2584 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2586 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2587 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2588 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2613 add_function("ldexp",
2614 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2615 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2616 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2617 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2618 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2619 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2620 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2621 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2624 add_function("frexp",
2625 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2626 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2627 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2628 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2629 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2630 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2631 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2632 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2634 add_function("uaddCarry",
2635 _uaddCarry(glsl_type::uint_type
),
2636 _uaddCarry(glsl_type::uvec2_type
),
2637 _uaddCarry(glsl_type::uvec3_type
),
2638 _uaddCarry(glsl_type::uvec4_type
),
2640 add_function("usubBorrow",
2641 _usubBorrow(glsl_type::uint_type
),
2642 _usubBorrow(glsl_type::uvec2_type
),
2643 _usubBorrow(glsl_type::uvec3_type
),
2644 _usubBorrow(glsl_type::uvec4_type
),
2646 add_function("imulExtended",
2647 _mulExtended(glsl_type::int_type
),
2648 _mulExtended(glsl_type::ivec2_type
),
2649 _mulExtended(glsl_type::ivec3_type
),
2650 _mulExtended(glsl_type::ivec4_type
),
2652 add_function("umulExtended",
2653 _mulExtended(glsl_type::uint_type
),
2654 _mulExtended(glsl_type::uvec2_type
),
2655 _mulExtended(glsl_type::uvec3_type
),
2656 _mulExtended(glsl_type::uvec4_type
),
2658 add_function("interpolateAtCentroid",
2659 _interpolateAtCentroid(glsl_type::float_type
),
2660 _interpolateAtCentroid(glsl_type::vec2_type
),
2661 _interpolateAtCentroid(glsl_type::vec3_type
),
2662 _interpolateAtCentroid(glsl_type::vec4_type
),
2664 add_function("interpolateAtOffset",
2665 _interpolateAtOffset(glsl_type::float_type
),
2666 _interpolateAtOffset(glsl_type::vec2_type
),
2667 _interpolateAtOffset(glsl_type::vec3_type
),
2668 _interpolateAtOffset(glsl_type::vec4_type
),
2670 add_function("interpolateAtSample",
2671 _interpolateAtSample(glsl_type::float_type
),
2672 _interpolateAtSample(glsl_type::vec2_type
),
2673 _interpolateAtSample(glsl_type::vec3_type
),
2674 _interpolateAtSample(glsl_type::vec4_type
),
2677 add_function("atomicCounter",
2678 _atomic_counter_op("__intrinsic_atomic_read",
2679 shader_atomic_counters
),
2681 add_function("atomicCounterIncrement",
2682 _atomic_counter_op("__intrinsic_atomic_increment",
2683 shader_atomic_counters
),
2685 add_function("atomicCounterDecrement",
2686 _atomic_counter_op("__intrinsic_atomic_predecrement",
2687 shader_atomic_counters
),
2690 add_function("atomicAdd",
2691 _atomic_op2("__intrinsic_atomic_add",
2692 buffer_atomics_supported
,
2693 glsl_type::uint_type
),
2694 _atomic_op2("__intrinsic_atomic_add",
2695 buffer_atomics_supported
,
2696 glsl_type::int_type
),
2698 add_function("atomicMin",
2699 _atomic_op2("__intrinsic_atomic_min",
2700 buffer_atomics_supported
,
2701 glsl_type::uint_type
),
2702 _atomic_op2("__intrinsic_atomic_min",
2703 buffer_atomics_supported
,
2704 glsl_type::int_type
),
2706 add_function("atomicMax",
2707 _atomic_op2("__intrinsic_atomic_max",
2708 buffer_atomics_supported
,
2709 glsl_type::uint_type
),
2710 _atomic_op2("__intrinsic_atomic_max",
2711 buffer_atomics_supported
,
2712 glsl_type::int_type
),
2714 add_function("atomicAnd",
2715 _atomic_op2("__intrinsic_atomic_and",
2716 buffer_atomics_supported
,
2717 glsl_type::uint_type
),
2718 _atomic_op2("__intrinsic_atomic_and",
2719 buffer_atomics_supported
,
2720 glsl_type::int_type
),
2722 add_function("atomicOr",
2723 _atomic_op2("__intrinsic_atomic_or",
2724 buffer_atomics_supported
,
2725 glsl_type::uint_type
),
2726 _atomic_op2("__intrinsic_atomic_or",
2727 buffer_atomics_supported
,
2728 glsl_type::int_type
),
2730 add_function("atomicXor",
2731 _atomic_op2("__intrinsic_atomic_xor",
2732 buffer_atomics_supported
,
2733 glsl_type::uint_type
),
2734 _atomic_op2("__intrinsic_atomic_xor",
2735 buffer_atomics_supported
,
2736 glsl_type::int_type
),
2738 add_function("atomicExchange",
2739 _atomic_op2("__intrinsic_atomic_exchange",
2740 buffer_atomics_supported
,
2741 glsl_type::uint_type
),
2742 _atomic_op2("__intrinsic_atomic_exchange",
2743 buffer_atomics_supported
,
2744 glsl_type::int_type
),
2746 add_function("atomicCompSwap",
2747 _atomic_op3("__intrinsic_atomic_comp_swap",
2748 buffer_atomics_supported
,
2749 glsl_type::uint_type
),
2750 _atomic_op3("__intrinsic_atomic_comp_swap",
2751 buffer_atomics_supported
,
2752 glsl_type::int_type
),
2755 add_function("min3",
2756 _min3(glsl_type::float_type
),
2757 _min3(glsl_type::vec2_type
),
2758 _min3(glsl_type::vec3_type
),
2759 _min3(glsl_type::vec4_type
),
2761 _min3(glsl_type::int_type
),
2762 _min3(glsl_type::ivec2_type
),
2763 _min3(glsl_type::ivec3_type
),
2764 _min3(glsl_type::ivec4_type
),
2766 _min3(glsl_type::uint_type
),
2767 _min3(glsl_type::uvec2_type
),
2768 _min3(glsl_type::uvec3_type
),
2769 _min3(glsl_type::uvec4_type
),
2772 add_function("max3",
2773 _max3(glsl_type::float_type
),
2774 _max3(glsl_type::vec2_type
),
2775 _max3(glsl_type::vec3_type
),
2776 _max3(glsl_type::vec4_type
),
2778 _max3(glsl_type::int_type
),
2779 _max3(glsl_type::ivec2_type
),
2780 _max3(glsl_type::ivec3_type
),
2781 _max3(glsl_type::ivec4_type
),
2783 _max3(glsl_type::uint_type
),
2784 _max3(glsl_type::uvec2_type
),
2785 _max3(glsl_type::uvec3_type
),
2786 _max3(glsl_type::uvec4_type
),
2789 add_function("mid3",
2790 _mid3(glsl_type::float_type
),
2791 _mid3(glsl_type::vec2_type
),
2792 _mid3(glsl_type::vec3_type
),
2793 _mid3(glsl_type::vec4_type
),
2795 _mid3(glsl_type::int_type
),
2796 _mid3(glsl_type::ivec2_type
),
2797 _mid3(glsl_type::ivec3_type
),
2798 _mid3(glsl_type::ivec4_type
),
2800 _mid3(glsl_type::uint_type
),
2801 _mid3(glsl_type::uvec2_type
),
2802 _mid3(glsl_type::uvec3_type
),
2803 _mid3(glsl_type::uvec4_type
),
2806 add_image_functions(true);
2808 add_function("memoryBarrier",
2809 _memory_barrier("__intrinsic_memory_barrier",
2810 shader_image_load_store
),
2812 add_function("groupMemoryBarrier",
2813 _memory_barrier("__intrinsic_group_memory_barrier",
2816 add_function("memoryBarrierAtomicCounter",
2817 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
2820 add_function("memoryBarrierBuffer",
2821 _memory_barrier("__intrinsic_memory_barrier_buffer",
2824 add_function("memoryBarrierImage",
2825 _memory_barrier("__intrinsic_memory_barrier_image",
2828 add_function("memoryBarrierShared",
2829 _memory_barrier("__intrinsic_memory_barrier_shared",
2833 add_function("clock2x32ARB",
2834 _shader_clock(shader_clock
,
2835 glsl_type::uvec2_type
),
2846 builtin_builder::add_function(const char *name
, ...)
2850 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2854 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2860 stuff
.push_tail(sig
);
2861 validate_ir_tree(&stuff
);
2864 f
->add_signature(sig
);
2868 shader
->symbols
->add_function(f
);
2872 builtin_builder::add_image_function(const char *name
,
2873 const char *intrinsic_name
,
2874 image_prototype_ctr prototype
,
2875 unsigned num_arguments
,
2878 static const glsl_type
*const types
[] = {
2879 glsl_type::image1D_type
,
2880 glsl_type::image2D_type
,
2881 glsl_type::image3D_type
,
2882 glsl_type::image2DRect_type
,
2883 glsl_type::imageCube_type
,
2884 glsl_type::imageBuffer_type
,
2885 glsl_type::image1DArray_type
,
2886 glsl_type::image2DArray_type
,
2887 glsl_type::imageCubeArray_type
,
2888 glsl_type::image2DMS_type
,
2889 glsl_type::image2DMSArray_type
,
2890 glsl_type::iimage1D_type
,
2891 glsl_type::iimage2D_type
,
2892 glsl_type::iimage3D_type
,
2893 glsl_type::iimage2DRect_type
,
2894 glsl_type::iimageCube_type
,
2895 glsl_type::iimageBuffer_type
,
2896 glsl_type::iimage1DArray_type
,
2897 glsl_type::iimage2DArray_type
,
2898 glsl_type::iimageCubeArray_type
,
2899 glsl_type::iimage2DMS_type
,
2900 glsl_type::iimage2DMSArray_type
,
2901 glsl_type::uimage1D_type
,
2902 glsl_type::uimage2D_type
,
2903 glsl_type::uimage3D_type
,
2904 glsl_type::uimage2DRect_type
,
2905 glsl_type::uimageCube_type
,
2906 glsl_type::uimageBuffer_type
,
2907 glsl_type::uimage1DArray_type
,
2908 glsl_type::uimage2DArray_type
,
2909 glsl_type::uimageCubeArray_type
,
2910 glsl_type::uimage2DMS_type
,
2911 glsl_type::uimage2DMSArray_type
2914 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2916 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2917 if ((types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2918 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
2919 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
2920 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
2921 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
2922 num_arguments
, flags
));
2925 shader
->symbols
->add_function(f
);
2929 builtin_builder::add_image_functions(bool glsl
)
2931 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2933 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2934 "__intrinsic_image_load",
2935 &builtin_builder::_image_prototype
, 0,
2936 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2937 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2938 IMAGE_FUNCTION_READ_ONLY
));
2940 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2941 "__intrinsic_image_store",
2942 &builtin_builder::_image_prototype
, 1,
2943 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2944 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2945 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2946 IMAGE_FUNCTION_WRITE_ONLY
));
2948 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
2950 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2951 "__intrinsic_image_atomic_add",
2952 &builtin_builder::_image_prototype
, 1, atom_flags
);
2954 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2955 "__intrinsic_image_atomic_min",
2956 &builtin_builder::_image_prototype
, 1, atom_flags
);
2958 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2959 "__intrinsic_image_atomic_max",
2960 &builtin_builder::_image_prototype
, 1, atom_flags
);
2962 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2963 "__intrinsic_image_atomic_and",
2964 &builtin_builder::_image_prototype
, 1, atom_flags
);
2966 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2967 "__intrinsic_image_atomic_or",
2968 &builtin_builder::_image_prototype
, 1, atom_flags
);
2970 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2971 "__intrinsic_image_atomic_xor",
2972 &builtin_builder::_image_prototype
, 1, atom_flags
);
2974 add_image_function((glsl
? "imageAtomicExchange" :
2975 "__intrinsic_image_atomic_exchange"),
2976 "__intrinsic_image_atomic_exchange",
2977 &builtin_builder::_image_prototype
, 1, atom_flags
);
2979 add_image_function((glsl
? "imageAtomicCompSwap" :
2980 "__intrinsic_image_atomic_comp_swap"),
2981 "__intrinsic_image_atomic_comp_swap",
2982 &builtin_builder::_image_prototype
, 2, atom_flags
);
2984 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
2985 "__intrinsic_image_size",
2986 &builtin_builder::_image_size_prototype
, 1,
2987 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
2989 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
2990 "__intrinsic_image_samples",
2991 &builtin_builder::_image_samples_prototype
, 1,
2992 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2993 IMAGE_FUNCTION_MS_ONLY
);
2997 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2999 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3003 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3005 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3009 builtin_builder::imm(float f
, unsigned vector_elements
)
3011 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3015 builtin_builder::imm(int i
, unsigned vector_elements
)
3017 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3021 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3023 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3027 builtin_builder::imm(double d
, unsigned vector_elements
)
3029 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3033 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3035 return new(mem_ctx
) ir_constant(type
, &data
);
3038 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
3040 ir_dereference_variable
*
3041 builtin_builder::var_ref(ir_variable
*var
)
3043 return new(mem_ctx
) ir_dereference_variable(var
);
3046 ir_dereference_array
*
3047 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3049 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3052 /** Return an element of a matrix */
3054 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3056 return swizzle(array_ref(var
, column
), row
, 1);
3060 * Implementations of built-in functions:
3063 ir_function_signature
*
3064 builtin_builder::new_sig(const glsl_type
*return_type
,
3065 builtin_available_predicate avail
,
3071 ir_function_signature
*sig
=
3072 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3075 va_start(ap
, num_params
);
3076 for (int i
= 0; i
< num_params
; i
++) {
3077 plist
.push_tail(va_arg(ap
, ir_variable
*));
3081 sig
->replace_parameters(&plist
);
3085 #define MAKE_SIG(return_type, avail, ...) \
3086 ir_function_signature *sig = \
3087 new_sig(return_type, avail, __VA_ARGS__); \
3088 ir_factory body(&sig->body, mem_ctx); \
3089 sig->is_defined = true;
3091 #define MAKE_INTRINSIC(return_type, avail, ...) \
3092 ir_function_signature *sig = \
3093 new_sig(return_type, avail, __VA_ARGS__); \
3094 sig->is_intrinsic = true;
3096 ir_function_signature
*
3097 builtin_builder::unop(builtin_available_predicate avail
,
3098 ir_expression_operation opcode
,
3099 const glsl_type
*return_type
,
3100 const glsl_type
*param_type
)
3102 ir_variable
*x
= in_var(param_type
, "x");
3103 MAKE_SIG(return_type
, avail
, 1, x
);
3104 body
.emit(ret(expr(opcode
, x
)));
3108 #define UNOP(NAME, OPCODE, AVAIL) \
3109 ir_function_signature * \
3110 builtin_builder::_##NAME(const glsl_type *type) \
3112 return unop(&AVAIL, OPCODE, type, type); \
3115 #define UNOPA(NAME, OPCODE) \
3116 ir_function_signature * \
3117 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3119 return unop(avail, OPCODE, type, type); \
3122 ir_function_signature
*
3123 builtin_builder::binop(builtin_available_predicate avail
,
3124 ir_expression_operation opcode
,
3125 const glsl_type
*return_type
,
3126 const glsl_type
*param0_type
,
3127 const glsl_type
*param1_type
)
3129 ir_variable
*x
= in_var(param0_type
, "x");
3130 ir_variable
*y
= in_var(param1_type
, "y");
3131 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3132 body
.emit(ret(expr(opcode
, x
, y
)));
3136 #define BINOP(NAME, OPCODE, AVAIL) \
3137 ir_function_signature * \
3138 builtin_builder::_##NAME(const glsl_type *return_type, \
3139 const glsl_type *param0_type, \
3140 const glsl_type *param1_type) \
3142 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3146 * Angle and Trigonometry Functions @{
3149 ir_function_signature
*
3150 builtin_builder::_radians(const glsl_type
*type
)
3152 ir_variable
*degrees
= in_var(type
, "degrees");
3153 MAKE_SIG(type
, always_available
, 1, degrees
);
3154 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3158 ir_function_signature
*
3159 builtin_builder::_degrees(const glsl_type
*type
)
3161 ir_variable
*radians
= in_var(type
, "radians");
3162 MAKE_SIG(type
, always_available
, 1, radians
);
3163 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3167 UNOP(sin
, ir_unop_sin
, always_available
)
3168 UNOP(cos
, ir_unop_cos
, always_available
)
3170 ir_function_signature
*
3171 builtin_builder::_tan(const glsl_type
*type
)
3173 ir_variable
*theta
= in_var(type
, "theta");
3174 MAKE_SIG(type
, always_available
, 1, theta
);
3175 body
.emit(ret(div(sin(theta
), cos(theta
))));
3180 builtin_builder::asin_expr(ir_variable
*x
)
3184 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3187 add(imm(M_PI_4f
- 1.0f
),
3189 add(imm(0.086566724f
),
3190 mul(abs(x
), imm(-0.03102955f
))))))))));
3194 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3196 exec_list actual_params
;
3198 foreach_in_list(ir_variable
, var
, ¶ms
) {
3199 actual_params
.push_tail(var_ref(var
));
3202 ir_function_signature
*sig
=
3203 f
->exact_matching_signature(NULL
, &actual_params
);
3207 ir_dereference_variable
*deref
=
3208 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3210 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3213 ir_function_signature
*
3214 builtin_builder::_asin(const glsl_type
*type
)
3216 ir_variable
*x
= in_var(type
, "x");
3217 MAKE_SIG(type
, always_available
, 1, x
);
3219 body
.emit(ret(asin_expr(x
)));
3224 ir_function_signature
*
3225 builtin_builder::_acos(const glsl_type
*type
)
3227 ir_variable
*x
= in_var(type
, "x");
3228 MAKE_SIG(type
, always_available
, 1, x
);
3230 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
3235 ir_function_signature
*
3236 builtin_builder::_atan2(const glsl_type
*type
)
3238 ir_variable
*vec_y
= in_var(type
, "vec_y");
3239 ir_variable
*vec_x
= in_var(type
, "vec_x");
3240 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3242 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3243 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3244 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3245 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3246 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3247 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3248 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3250 /* If |x| >= 1.0e-8 * |y|: */
3252 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3254 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3256 /* Then...call atan(y/x) */
3257 do_atan(body
, glsl_type::float_type
, r
, div(y
, x
));
3259 /* ...and fix it up: */
3260 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3261 inner_if
->then_instructions
.push_tail(
3262 if_tree(gequal(y
, imm(0.0f
)),
3263 assign(r
, add(r
, imm(M_PIf
))),
3264 assign(r
, sub(r
, imm(M_PIf
)))));
3265 outer_then
.emit(inner_if
);
3268 outer_if
->else_instructions
.push_tail(
3269 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3271 body
.emit(outer_if
);
3273 body
.emit(assign(vec_result
, r
, 1 << i
));
3275 body
.emit(ret(vec_result
));
3281 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3284 * range-reduction, first step:
3286 * / y_over_x if |y_over_x| <= 1.0;
3288 * \ 1.0 / y_over_x otherwise
3290 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3291 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3297 * approximate atan by evaluating polynomial:
3299 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3300 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3301 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3303 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3304 body
.emit(assign(tmp
, mul(x
, x
)));
3305 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3307 imm(0.0536813784310406f
)),
3309 imm(0.1173503194786851f
)),
3311 imm(0.1938924977115610f
)),
3313 imm(0.3326756418091246f
)),
3315 imm(0.9999793128310355f
)),
3318 /* range-reduction fixup */
3319 body
.emit(assign(tmp
, add(tmp
,
3320 mul(b2f(greater(abs(y_over_x
),
3321 imm(1.0f
, type
->components()))),
3327 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3330 ir_function_signature
*
3331 builtin_builder::_atan(const glsl_type
*type
)
3333 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3334 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3336 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3337 do_atan(body
, type
, tmp
, y_over_x
);
3338 body
.emit(ret(tmp
));
3343 ir_function_signature
*
3344 builtin_builder::_sinh(const glsl_type
*type
)
3346 ir_variable
*x
= in_var(type
, "x");
3347 MAKE_SIG(type
, v130
, 1, x
);
3349 /* 0.5 * (e^x - e^(-x)) */
3350 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3355 ir_function_signature
*
3356 builtin_builder::_cosh(const glsl_type
*type
)
3358 ir_variable
*x
= in_var(type
, "x");
3359 MAKE_SIG(type
, v130
, 1, x
);
3361 /* 0.5 * (e^x + e^(-x)) */
3362 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3367 ir_function_signature
*
3368 builtin_builder::_tanh(const glsl_type
*type
)
3370 ir_variable
*x
= in_var(type
, "x");
3371 MAKE_SIG(type
, v130
, 1, x
);
3373 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3374 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3375 add(exp(x
), exp(neg(x
))))));
3380 ir_function_signature
*
3381 builtin_builder::_asinh(const glsl_type
*type
)
3383 ir_variable
*x
= in_var(type
, "x");
3384 MAKE_SIG(type
, v130
, 1, x
);
3386 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3391 ir_function_signature
*
3392 builtin_builder::_acosh(const glsl_type
*type
)
3394 ir_variable
*x
= in_var(type
, "x");
3395 MAKE_SIG(type
, v130
, 1, x
);
3397 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3401 ir_function_signature
*
3402 builtin_builder::_atanh(const glsl_type
*type
)
3404 ir_variable
*x
= in_var(type
, "x");
3405 MAKE_SIG(type
, v130
, 1, x
);
3407 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3408 sub(imm(1.0f
), x
))))));
3414 * Exponential Functions @{
3417 ir_function_signature
*
3418 builtin_builder::_pow(const glsl_type
*type
)
3420 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
3423 UNOP(exp
, ir_unop_exp
, always_available
)
3424 UNOP(log
, ir_unop_log
, always_available
)
3425 UNOP(exp2
, ir_unop_exp2
, always_available
)
3426 UNOP(log2
, ir_unop_log2
, always_available
)
3427 UNOPA(sqrt
, ir_unop_sqrt
)
3428 UNOPA(inversesqrt
, ir_unop_rsq
)
3432 UNOPA(abs
, ir_unop_abs
)
3433 UNOPA(sign
, ir_unop_sign
)
3434 UNOPA(floor
, ir_unop_floor
)
3435 UNOPA(trunc
, ir_unop_trunc
)
3436 UNOPA(round
, ir_unop_round_even
)
3437 UNOPA(roundEven
, ir_unop_round_even
)
3438 UNOPA(ceil
, ir_unop_ceil
)
3439 UNOPA(fract
, ir_unop_fract
)
3441 ir_function_signature
*
3442 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
3444 return binop(always_available
, ir_binop_mod
, x_type
, x_type
, y_type
);
3447 ir_function_signature
*
3448 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3450 ir_variable
*x
= in_var(type
, "x");
3451 ir_variable
*i
= out_var(type
, "i");
3452 MAKE_SIG(type
, avail
, 2, x
, i
);
3454 ir_variable
*t
= body
.make_temp(type
, "t");
3455 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3456 body
.emit(assign(i
, t
));
3457 body
.emit(ret(sub(x
, t
)));
3462 ir_function_signature
*
3463 builtin_builder::_min(builtin_available_predicate avail
,
3464 const glsl_type
*x_type
, const glsl_type
*y_type
)
3466 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
3469 ir_function_signature
*
3470 builtin_builder::_max(builtin_available_predicate avail
,
3471 const glsl_type
*x_type
, const glsl_type
*y_type
)
3473 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
3476 ir_function_signature
*
3477 builtin_builder::_clamp(builtin_available_predicate avail
,
3478 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3480 ir_variable
*x
= in_var(val_type
, "x");
3481 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3482 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3483 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3485 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3490 ir_function_signature
*
3491 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3493 ir_variable
*x
= in_var(val_type
, "x");
3494 ir_variable
*y
= in_var(val_type
, "y");
3495 ir_variable
*a
= in_var(blend_type
, "a");
3496 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3498 body
.emit(ret(lrp(x
, y
, a
)));
3503 ir_function_signature
*
3504 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3505 const glsl_type
*val_type
,
3506 const glsl_type
*blend_type
)
3508 ir_variable
*x
= in_var(val_type
, "x");
3509 ir_variable
*y
= in_var(val_type
, "y");
3510 ir_variable
*a
= in_var(blend_type
, "a");
3511 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3513 /* csel matches the ternary operator in that a selector of true choses the
3514 * first argument. This differs from mix(x, y, false) which choses the
3515 * second argument (to remain consistent with the interpolating version of
3516 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3518 * To handle the behavior mismatch, reverse the x and y arguments.
3520 body
.emit(ret(csel(a
, y
, x
)));
3525 ir_function_signature
*
3526 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3528 ir_variable
*edge
= in_var(edge_type
, "edge");
3529 ir_variable
*x
= in_var(x_type
, "x");
3530 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3532 ir_variable
*t
= body
.make_temp(x_type
, "t");
3533 if (x_type
->vector_elements
== 1) {
3534 /* Both are floats */
3535 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3536 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3538 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3539 } else if (edge_type
->vector_elements
== 1) {
3540 /* x is a vector but edge is a float */
3541 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3542 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3543 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3545 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3548 /* Both are vectors */
3549 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3550 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3551 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3554 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3564 ir_function_signature
*
3565 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3567 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3568 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3569 ir_variable
*x
= in_var(x_type
, "x");
3570 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3572 /* From the GLSL 1.10 specification:
3575 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3576 * return t * t * (3 - 2 * t);
3579 ir_variable
*t
= body
.make_temp(x_type
, "t");
3580 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3581 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3583 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3588 ir_function_signature
*
3589 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3591 ir_variable
*x
= in_var(type
, "x");
3592 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3594 body
.emit(ret(nequal(x
, x
)));
3599 ir_function_signature
*
3600 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3602 ir_variable
*x
= in_var(type
, "x");
3603 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3605 ir_constant_data infinities
;
3606 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3607 switch (type
->base_type
) {
3608 case GLSL_TYPE_FLOAT
:
3609 infinities
.f
[i
] = INFINITY
;
3611 case GLSL_TYPE_DOUBLE
:
3612 infinities
.d
[i
] = INFINITY
;
3615 unreachable("unknown type");
3619 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3624 ir_function_signature
*
3625 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3627 ir_variable
*x
= in_var(type
, "x");
3628 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3629 body
.emit(ret(bitcast_f2i(x
)));
3633 ir_function_signature
*
3634 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3636 ir_variable
*x
= in_var(type
, "x");
3637 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3638 body
.emit(ret(bitcast_f2u(x
)));
3642 ir_function_signature
*
3643 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3645 ir_variable
*x
= in_var(type
, "x");
3646 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3647 body
.emit(ret(bitcast_i2f(x
)));
3651 ir_function_signature
*
3652 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3654 ir_variable
*x
= in_var(type
, "x");
3655 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3656 body
.emit(ret(bitcast_u2f(x
)));
3660 ir_function_signature
*
3661 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3663 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3664 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3665 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3669 ir_function_signature
*
3670 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3672 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3673 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3674 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3678 ir_function_signature
*
3679 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3681 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3682 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3683 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3687 ir_function_signature
*
3688 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3690 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3691 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3692 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3696 ir_function_signature
*
3697 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3699 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3700 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3701 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3705 ir_function_signature
*
3706 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3708 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3709 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3710 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3715 ir_function_signature
*
3716 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3718 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3719 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3720 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3724 ir_function_signature
*
3725 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3727 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3728 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3729 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3733 ir_function_signature
*
3734 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3736 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3737 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3738 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3742 ir_function_signature
*
3743 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3745 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3746 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3747 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3751 ir_function_signature
*
3752 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3754 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3755 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3756 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3760 ir_function_signature
*
3761 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3763 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3764 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3765 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3769 ir_function_signature
*
3770 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3772 ir_variable
*x
= in_var(type
, "x");
3773 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3775 body
.emit(ret(sqrt(dot(x
, x
))));
3780 ir_function_signature
*
3781 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3783 ir_variable
*p0
= in_var(type
, "p0");
3784 ir_variable
*p1
= in_var(type
, "p1");
3785 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3787 if (type
->vector_elements
== 1) {
3788 body
.emit(ret(abs(sub(p0
, p1
))));
3790 ir_variable
*p
= body
.make_temp(type
, "p");
3791 body
.emit(assign(p
, sub(p0
, p1
)));
3792 body
.emit(ret(sqrt(dot(p
, p
))));
3798 ir_function_signature
*
3799 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3801 if (type
->vector_elements
== 1)
3802 return binop(avail
, ir_binop_mul
, type
, type
, type
);
3804 return binop(avail
, ir_binop_dot
,
3805 type
->get_base_type(), type
, type
);
3808 ir_function_signature
*
3809 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3811 ir_variable
*a
= in_var(type
, "a");
3812 ir_variable
*b
= in_var(type
, "b");
3813 MAKE_SIG(type
, avail
, 2, a
, b
);
3815 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3816 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3818 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3819 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3824 ir_function_signature
*
3825 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3827 ir_variable
*x
= in_var(type
, "x");
3828 MAKE_SIG(type
, avail
, 1, x
);
3830 if (type
->vector_elements
== 1) {
3831 body
.emit(ret(sign(x
)));
3833 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3839 ir_function_signature
*
3840 builtin_builder::_ftransform()
3842 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3844 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3845 glsl_type::vec4_type
,
3846 var_ref(gl_ModelViewProjectionMatrix
),
3847 var_ref(gl_Vertex
))));
3849 /* FINISHME: Once the ir_expression() constructor handles type inference
3850 * for matrix operations, we can simplify this to:
3852 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3857 ir_function_signature
*
3858 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3860 ir_variable
*N
= in_var(type
, "N");
3861 ir_variable
*I
= in_var(type
, "I");
3862 ir_variable
*Nref
= in_var(type
, "Nref");
3863 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3865 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3866 ret(N
), ret(neg(N
))));
3871 ir_function_signature
*
3872 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3874 ir_variable
*I
= in_var(type
, "I");
3875 ir_variable
*N
= in_var(type
, "N");
3876 MAKE_SIG(type
, avail
, 2, I
, N
);
3878 /* I - 2 * dot(N, I) * N */
3879 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3884 ir_function_signature
*
3885 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3887 ir_variable
*I
= in_var(type
, "I");
3888 ir_variable
*N
= in_var(type
, "N");
3889 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3890 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3892 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3893 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3895 /* From the GLSL 1.10 specification:
3896 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3898 * return genType(0.0)
3900 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3902 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3903 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3904 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3905 mul(n_dot_i
, n_dot_i
)))))));
3906 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3907 ret(ir_constant::zero(mem_ctx
, type
)),
3908 ret(sub(mul(eta
, I
),
3909 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3914 ir_function_signature
*
3915 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3917 ir_variable
*x
= in_var(type
, "x");
3918 ir_variable
*y
= in_var(type
, "y");
3919 MAKE_SIG(type
, avail
, 2, x
, y
);
3921 ir_variable
*z
= body
.make_temp(type
, "z");
3922 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3923 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3930 ir_function_signature
*
3931 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3936 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3937 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3938 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3940 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3941 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3943 MAKE_SIG(type
, avail
, 2, c
, r
);
3945 ir_variable
*m
= body
.make_temp(type
, "m");
3946 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3947 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3954 ir_function_signature
*
3955 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3957 const glsl_type
*transpose_type
=
3958 glsl_type::get_instance(orig_type
->base_type
,
3959 orig_type
->matrix_columns
,
3960 orig_type
->vector_elements
);
3962 ir_variable
*m
= in_var(orig_type
, "m");
3963 MAKE_SIG(transpose_type
, avail
, 1, m
);
3965 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3966 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3967 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3968 body
.emit(assign(array_ref(t
, j
),
3969 matrix_elt(m
, i
, j
),
3978 ir_function_signature
*
3979 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3981 ir_variable
*m
= in_var(type
, "m");
3982 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3984 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3985 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3990 ir_function_signature
*
3991 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3993 ir_variable
*m
= in_var(type
, "m");
3994 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3997 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3998 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4001 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4002 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4005 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4006 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4008 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4009 mul(matrix_elt(m
, 0, 1), f2
)),
4010 mul(matrix_elt(m
, 0, 2), f3
))));
4015 ir_function_signature
*
4016 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4018 ir_variable
*m
= in_var(type
, "m");
4019 const glsl_type
*btype
= type
->get_base_type();
4020 MAKE_SIG(btype
, avail
, 1, m
);
4022 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4023 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4024 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4025 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4026 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4027 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4028 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4029 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4030 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4031 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4032 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4033 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4034 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4035 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4036 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4037 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4038 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4039 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4040 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4042 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)))));
4043 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)))));
4044 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)))));
4045 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)))));
4046 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)))));
4047 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)))));
4048 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)))));
4049 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)))));
4050 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)))));
4051 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)))));
4052 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)))));
4053 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)))));
4054 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)))));
4055 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)))));
4056 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)))));
4057 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)))));
4058 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)))));
4059 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)))));
4060 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)))));
4062 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4064 body
.emit(assign(adj_0
,
4065 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4066 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4067 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4069 body
.emit(assign(adj_0
, neg(
4070 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4071 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4072 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4074 body
.emit(assign(adj_0
,
4075 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4076 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4077 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4079 body
.emit(assign(adj_0
, neg(
4080 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4081 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4082 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4085 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4090 ir_function_signature
*
4091 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4093 ir_variable
*m
= in_var(type
, "m");
4094 MAKE_SIG(type
, avail
, 1, m
);
4096 ir_variable
*adj
= body
.make_temp(type
, "adj");
4097 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4098 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4099 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4100 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4102 ir_expression
*det
=
4103 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4104 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4106 body
.emit(ret(div(adj
, det
)));
4110 ir_function_signature
*
4111 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4113 ir_variable
*m
= in_var(type
, "m");
4114 const glsl_type
*btype
= type
->get_base_type();
4115 MAKE_SIG(type
, avail
, 1, m
);
4117 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4118 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4119 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4121 body
.emit(assign(f11_22_21_12
,
4122 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4123 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4124 body
.emit(assign(f10_22_20_12
,
4125 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4126 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4127 body
.emit(assign(f10_21_20_11
,
4128 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4129 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4131 ir_variable
*adj
= body
.make_temp(type
, "adj");
4132 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4133 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4134 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4136 body
.emit(assign(array_ref(adj
, 0), neg(
4137 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4138 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4140 body
.emit(assign(array_ref(adj
, 1),
4141 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4142 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4144 body
.emit(assign(array_ref(adj
, 2), neg(
4145 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4146 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4149 body
.emit(assign(array_ref(adj
, 0),
4150 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4151 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4153 body
.emit(assign(array_ref(adj
, 1), neg(
4154 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4155 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4157 body
.emit(assign(array_ref(adj
, 2),
4158 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4159 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4162 ir_expression
*det
=
4163 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4164 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4165 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4167 body
.emit(ret(div(adj
, det
)));
4172 ir_function_signature
*
4173 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4175 ir_variable
*m
= in_var(type
, "m");
4176 const glsl_type
*btype
= type
->get_base_type();
4177 MAKE_SIG(type
, avail
, 1, m
);
4179 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4180 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4181 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4182 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4183 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4184 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4185 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4186 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4187 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4188 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4189 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4190 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4191 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4192 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4193 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4194 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4195 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4196 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4197 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4199 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)))));
4200 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)))));
4201 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)))));
4202 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)))));
4203 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)))));
4204 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)))));
4205 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)))));
4206 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)))));
4207 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)))));
4208 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)))));
4209 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)))));
4210 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)))));
4211 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)))));
4212 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)))));
4213 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)))));
4214 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)))));
4215 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)))));
4216 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)))));
4217 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)))));
4219 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4220 body
.emit(assign(array_ref(adj
, 0),
4221 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4222 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4223 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4225 body
.emit(assign(array_ref(adj
, 1), neg(
4226 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4227 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4228 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4230 body
.emit(assign(array_ref(adj
, 2),
4231 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4232 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4233 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4235 body
.emit(assign(array_ref(adj
, 3), neg(
4236 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4237 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4238 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4241 body
.emit(assign(array_ref(adj
, 0), neg(
4242 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4243 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4244 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4246 body
.emit(assign(array_ref(adj
, 1),
4247 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4248 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4249 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4251 body
.emit(assign(array_ref(adj
, 2), neg(
4252 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4253 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4254 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4256 body
.emit(assign(array_ref(adj
, 3),
4257 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4258 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4259 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4262 body
.emit(assign(array_ref(adj
, 0),
4263 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4264 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4265 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4267 body
.emit(assign(array_ref(adj
, 1), neg(
4268 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4269 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4270 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4272 body
.emit(assign(array_ref(adj
, 2),
4273 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4274 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4275 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4277 body
.emit(assign(array_ref(adj
, 3), neg(
4278 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4279 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4280 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4283 body
.emit(assign(array_ref(adj
, 0), neg(
4284 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4285 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4286 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4288 body
.emit(assign(array_ref(adj
, 1),
4289 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4290 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4291 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4293 body
.emit(assign(array_ref(adj
, 2), neg(
4294 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4295 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4296 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4298 body
.emit(assign(array_ref(adj
, 3),
4299 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4300 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4301 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4304 ir_expression
*det
=
4305 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4306 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4307 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4308 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4310 body
.emit(ret(div(adj
, det
)));
4316 ir_function_signature
*
4317 builtin_builder::_lessThan(builtin_available_predicate avail
,
4318 const glsl_type
*type
)
4320 return binop(avail
, ir_binop_less
,
4321 glsl_type::bvec(type
->vector_elements
), type
, type
);
4324 ir_function_signature
*
4325 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4326 const glsl_type
*type
)
4328 return binop(avail
, ir_binop_lequal
,
4329 glsl_type::bvec(type
->vector_elements
), type
, type
);
4332 ir_function_signature
*
4333 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4334 const glsl_type
*type
)
4336 return binop(avail
, ir_binop_greater
,
4337 glsl_type::bvec(type
->vector_elements
), type
, type
);
4340 ir_function_signature
*
4341 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4342 const glsl_type
*type
)
4344 return binop(avail
, ir_binop_gequal
,
4345 glsl_type::bvec(type
->vector_elements
), type
, type
);
4348 ir_function_signature
*
4349 builtin_builder::_equal(builtin_available_predicate avail
,
4350 const glsl_type
*type
)
4352 return binop(avail
, ir_binop_equal
,
4353 glsl_type::bvec(type
->vector_elements
), type
, type
);
4356 ir_function_signature
*
4357 builtin_builder::_notEqual(builtin_available_predicate avail
,
4358 const glsl_type
*type
)
4360 return binop(avail
, ir_binop_nequal
,
4361 glsl_type::bvec(type
->vector_elements
), type
, type
);
4364 ir_function_signature
*
4365 builtin_builder::_any(const glsl_type
*type
)
4367 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
4370 ir_function_signature
*
4371 builtin_builder::_all(const glsl_type
*type
)
4373 ir_variable
*v
= in_var(type
, "v");
4374 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4376 switch (type
->vector_elements
) {
4378 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
4381 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4385 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4394 UNOP(not, ir_unop_logic_not
, always_available
)
4397 has_lod(const glsl_type
*sampler_type
)
4399 assert(sampler_type
->is_sampler());
4401 switch (sampler_type
->sampler_dimensionality
) {
4402 case GLSL_SAMPLER_DIM_RECT
:
4403 case GLSL_SAMPLER_DIM_BUF
:
4404 case GLSL_SAMPLER_DIM_MS
:
4411 ir_function_signature
*
4412 builtin_builder::_textureSize(builtin_available_predicate avail
,
4413 const glsl_type
*return_type
,
4414 const glsl_type
*sampler_type
)
4416 ir_variable
*s
= in_var(sampler_type
, "sampler");
4417 /* The sampler always exists; add optional lod later. */
4418 MAKE_SIG(return_type
, avail
, 1, s
);
4420 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4421 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4423 if (has_lod(sampler_type
)) {
4424 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4425 sig
->parameters
.push_tail(lod
);
4426 tex
->lod_info
.lod
= var_ref(lod
);
4428 tex
->lod_info
.lod
= imm(0u);
4431 body
.emit(ret(tex
));
4436 ir_function_signature
*
4437 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4439 ir_variable
*s
= in_var(sampler_type
, "sampler");
4440 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4442 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4443 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4444 body
.emit(ret(tex
));
4449 ir_function_signature
*
4450 builtin_builder::_texture(ir_texture_opcode opcode
,
4451 builtin_available_predicate avail
,
4452 const glsl_type
*return_type
,
4453 const glsl_type
*sampler_type
,
4454 const glsl_type
*coord_type
,
4457 ir_variable
*s
= in_var(sampler_type
, "sampler");
4458 ir_variable
*P
= in_var(coord_type
, "P");
4459 /* The sampler and coordinate always exist; add optional parameters later. */
4460 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4462 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4463 tex
->set_sampler(var_ref(s
), return_type
);
4465 const int coord_size
= sampler_type
->coordinate_components();
4467 if (coord_size
== coord_type
->vector_elements
) {
4468 tex
->coordinate
= var_ref(P
);
4470 /* The incoming coordinate also has the projector or shadow comparitor,
4471 * so we need to swizzle those away.
4473 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4476 /* The projector is always in the last component. */
4477 if (flags
& TEX_PROJECT
)
4478 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4480 if (sampler_type
->sampler_shadow
) {
4481 if (opcode
== ir_tg4
) {
4482 /* gather has refz as a separate parameter, immediately after the
4485 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4486 sig
->parameters
.push_tail(refz
);
4487 tex
->shadow_comparitor
= var_ref(refz
);
4489 /* The shadow comparitor is normally in the Z component, but a few types
4490 * have sufficiently large coordinates that it's in W.
4492 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4496 if (opcode
== ir_txl
) {
4497 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4498 sig
->parameters
.push_tail(lod
);
4499 tex
->lod_info
.lod
= var_ref(lod
);
4500 } else if (opcode
== ir_txd
) {
4501 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4502 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4503 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4504 sig
->parameters
.push_tail(dPdx
);
4505 sig
->parameters
.push_tail(dPdy
);
4506 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4507 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4510 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4511 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4512 ir_variable
*offset
=
4513 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4514 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4515 sig
->parameters
.push_tail(offset
);
4516 tex
->offset
= var_ref(offset
);
4519 if (flags
& TEX_OFFSET_ARRAY
) {
4520 ir_variable
*offsets
=
4521 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4522 "offsets", ir_var_const_in
);
4523 sig
->parameters
.push_tail(offsets
);
4524 tex
->offset
= var_ref(offsets
);
4527 if (opcode
== ir_tg4
) {
4528 if (flags
& TEX_COMPONENT
) {
4529 ir_variable
*component
=
4530 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4531 sig
->parameters
.push_tail(component
);
4532 tex
->lod_info
.component
= var_ref(component
);
4535 tex
->lod_info
.component
= imm(0);
4539 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4540 * inconsistent with both textureLodOffset and textureGradOffset.
4542 if (opcode
== ir_txb
) {
4543 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4544 sig
->parameters
.push_tail(bias
);
4545 tex
->lod_info
.bias
= var_ref(bias
);
4548 body
.emit(ret(tex
));
4553 ir_function_signature
*
4554 builtin_builder::_textureCubeArrayShadow()
4556 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4557 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4558 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4559 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4561 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4562 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4564 tex
->coordinate
= var_ref(P
);
4565 tex
->shadow_comparitor
= var_ref(compare
);
4567 body
.emit(ret(tex
));
4572 ir_function_signature
*
4573 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4574 const glsl_type
*return_type
,
4575 const glsl_type
*sampler_type
,
4576 const glsl_type
*coord_type
,
4577 const glsl_type
*offset_type
)
4579 ir_variable
*s
= in_var(sampler_type
, "sampler");
4580 ir_variable
*P
= in_var(coord_type
, "P");
4581 /* The sampler and coordinate always exist; add optional parameters later. */
4582 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4584 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4585 tex
->coordinate
= var_ref(P
);
4586 tex
->set_sampler(var_ref(s
), return_type
);
4588 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4589 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4590 sig
->parameters
.push_tail(sample
);
4591 tex
->lod_info
.sample_index
= var_ref(sample
);
4592 tex
->op
= ir_txf_ms
;
4593 } else if (has_lod(sampler_type
)) {
4594 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4595 sig
->parameters
.push_tail(lod
);
4596 tex
->lod_info
.lod
= var_ref(lod
);
4598 tex
->lod_info
.lod
= imm(0u);
4601 if (offset_type
!= NULL
) {
4602 ir_variable
*offset
=
4603 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4604 sig
->parameters
.push_tail(offset
);
4605 tex
->offset
= var_ref(offset
);
4608 body
.emit(ret(tex
));
4613 ir_function_signature
*
4614 builtin_builder::_EmitVertex()
4616 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4618 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4619 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4624 ir_function_signature
*
4625 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4626 const glsl_type
*stream_type
)
4628 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4630 * "Emit the current values of output variables to the current output
4631 * primitive on stream stream. The argument to stream must be a constant
4632 * integral expression."
4634 ir_variable
*stream
=
4635 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4637 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4639 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4644 ir_function_signature
*
4645 builtin_builder::_EndPrimitive()
4647 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4649 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4650 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4655 ir_function_signature
*
4656 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4657 const glsl_type
*stream_type
)
4659 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4661 * "Completes the current output primitive on stream stream and starts
4662 * a new one. The argument to stream must be a constant integral
4665 ir_variable
*stream
=
4666 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4668 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4670 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4675 ir_function_signature
*
4676 builtin_builder::_barrier()
4678 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4680 body
.emit(new(mem_ctx
) ir_barrier());
4684 ir_function_signature
*
4685 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4686 const glsl_type
*sampler_type
,
4687 const glsl_type
*coord_type
)
4689 ir_variable
*s
= in_var(sampler_type
, "sampler");
4690 ir_variable
*coord
= in_var(coord_type
, "coord");
4691 /* The sampler and coordinate always exist; add optional parameters later. */
4692 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4694 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4695 tex
->coordinate
= var_ref(coord
);
4696 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4698 body
.emit(ret(tex
));
4703 ir_function_signature
*
4704 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4706 ir_variable
*s
= in_var(sampler_type
, "sampler");
4707 const glsl_type
*return_type
= glsl_type::int_type
;
4708 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4710 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4711 tex
->set_sampler(var_ref(s
), return_type
);
4713 body
.emit(ret(tex
));
4718 ir_function_signature
*
4719 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
4720 const glsl_type
*sampler_type
,
4721 const glsl_type
*coord_type
)
4723 ir_variable
*s
= in_var(sampler_type
, "sampler");
4724 ir_variable
*P
= in_var(coord_type
, "P");
4725 const glsl_type
*return_type
= glsl_type::bool_type
;
4726 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4728 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
4729 tex
->coordinate
= var_ref(P
);
4730 tex
->set_sampler(var_ref(s
), return_type
);
4732 body
.emit(ret(tex
));
4737 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4738 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4739 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4740 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4741 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4742 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4744 ir_function_signature
*
4745 builtin_builder::_fwidth(const glsl_type
*type
)
4747 ir_variable
*p
= in_var(type
, "p");
4748 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4750 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4755 ir_function_signature
*
4756 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4758 ir_variable
*p
= in_var(type
, "p");
4759 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4761 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4762 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4767 ir_function_signature
*
4768 builtin_builder::_fwidthFine(const glsl_type
*type
)
4770 ir_variable
*p
= in_var(type
, "p");
4771 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4773 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4774 abs(expr(ir_unop_dFdy_fine
, p
)))));
4779 ir_function_signature
*
4780 builtin_builder::_noise1(const glsl_type
*type
)
4782 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4785 ir_function_signature
*
4786 builtin_builder::_noise2(const glsl_type
*type
)
4788 ir_variable
*p
= in_var(type
, "p");
4789 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4791 ir_constant_data b_offset
;
4792 b_offset
.f
[0] = 601.0f
;
4793 b_offset
.f
[1] = 313.0f
;
4794 b_offset
.f
[2] = 29.0f
;
4795 b_offset
.f
[3] = 277.0f
;
4797 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4798 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4799 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4800 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4801 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4802 body
.emit(assign(t
, a
, WRITEMASK_X
));
4803 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4809 ir_function_signature
*
4810 builtin_builder::_noise3(const glsl_type
*type
)
4812 ir_variable
*p
= in_var(type
, "p");
4813 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4815 ir_constant_data b_offset
;
4816 b_offset
.f
[0] = 601.0f
;
4817 b_offset
.f
[1] = 313.0f
;
4818 b_offset
.f
[2] = 29.0f
;
4819 b_offset
.f
[3] = 277.0f
;
4821 ir_constant_data c_offset
;
4822 c_offset
.f
[0] = 1559.0f
;
4823 c_offset
.f
[1] = 113.0f
;
4824 c_offset
.f
[2] = 1861.0f
;
4825 c_offset
.f
[3] = 797.0f
;
4827 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4828 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4829 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4830 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4831 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4832 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4833 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4834 body
.emit(assign(t
, a
, WRITEMASK_X
));
4835 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4836 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4842 ir_function_signature
*
4843 builtin_builder::_noise4(const glsl_type
*type
)
4845 ir_variable
*p
= in_var(type
, "p");
4846 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4848 ir_variable
*_p
= body
.make_temp(type
, "_p");
4850 ir_constant_data p_offset
;
4851 p_offset
.f
[0] = 1559.0f
;
4852 p_offset
.f
[1] = 113.0f
;
4853 p_offset
.f
[2] = 1861.0f
;
4854 p_offset
.f
[3] = 797.0f
;
4856 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4858 ir_constant_data offset
;
4859 offset
.f
[0] = 601.0f
;
4860 offset
.f
[1] = 313.0f
;
4861 offset
.f
[2] = 29.0f
;
4862 offset
.f
[3] = 277.0f
;
4864 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4865 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4866 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4867 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4868 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4869 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4870 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4871 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4872 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4873 body
.emit(assign(t
, a
, WRITEMASK_X
));
4874 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4875 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4876 body
.emit(assign(t
, d
, WRITEMASK_W
));
4882 ir_function_signature
*
4883 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4885 ir_variable
*value
= in_var(type
, "value");
4886 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4887 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4888 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4890 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4895 ir_function_signature
*
4896 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4898 ir_variable
*base
= in_var(type
, "base");
4899 ir_variable
*insert
= in_var(type
, "insert");
4900 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4901 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4902 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
4904 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4909 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
4911 ir_function_signature
*
4912 builtin_builder::_bitCount(const glsl_type
*type
)
4914 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
4915 glsl_type::ivec(type
->vector_elements
), type
);
4918 ir_function_signature
*
4919 builtin_builder::_findLSB(const glsl_type
*type
)
4921 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
4922 glsl_type::ivec(type
->vector_elements
), type
);
4925 ir_function_signature
*
4926 builtin_builder::_findMSB(const glsl_type
*type
)
4928 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
4929 glsl_type::ivec(type
->vector_elements
), type
);
4932 ir_function_signature
*
4933 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4935 ir_variable
*a
= in_var(type
, "a");
4936 ir_variable
*b
= in_var(type
, "b");
4937 ir_variable
*c
= in_var(type
, "c");
4938 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4940 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4945 ir_function_signature
*
4946 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4948 return binop(x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
,
4949 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
4952 ir_function_signature
*
4953 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4955 ir_variable
*x
= in_var(x_type
, "x");
4956 ir_variable
*exponent
= out_var(exp_type
, "exp");
4957 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
4959 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
4961 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
4965 ir_function_signature
*
4966 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4968 ir_variable
*x
= in_var(x_type
, "x");
4969 ir_variable
*exponent
= out_var(exp_type
, "exp");
4970 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
4972 const unsigned vec_elem
= x_type
->vector_elements
;
4973 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4974 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4976 /* Single-precision floating-point values are stored as
4981 * An exponent shift of 23 will shift the mantissa out, leaving only the
4982 * exponent and sign bit (which itself may be zero, if the absolute value
4983 * was taken before the bitcast and shift.
4985 ir_constant
*exponent_shift
= imm(23);
4986 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4988 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4990 /* Exponent of floating-point values in the range [0.5, 1.0). */
4991 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4993 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4994 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4996 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4997 * to unsigned integers to ensure that 1 bits aren't shifted in.
4999 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5000 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5001 imm(0, vec_elem
)))));
5003 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5004 body
.emit(assign(bits
, bitcast_f2u(x
)));
5005 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5006 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5007 imm(0u, vec_elem
)))));
5008 body
.emit(ret(bitcast_u2f(bits
)));
5013 ir_function_signature
*
5014 builtin_builder::_uaddCarry(const glsl_type
*type
)
5016 ir_variable
*x
= in_var(type
, "x");
5017 ir_variable
*y
= in_var(type
, "y");
5018 ir_variable
*carry
= out_var(type
, "carry");
5019 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
5021 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5022 body
.emit(ret(add(x
, y
)));
5027 ir_function_signature
*
5028 builtin_builder::_usubBorrow(const glsl_type
*type
)
5030 ir_variable
*x
= in_var(type
, "x");
5031 ir_variable
*y
= in_var(type
, "y");
5032 ir_variable
*borrow
= out_var(type
, "borrow");
5033 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
5035 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5036 body
.emit(ret(sub(x
, y
)));
5042 * For both imulExtended() and umulExtended() built-ins.
5044 ir_function_signature
*
5045 builtin_builder::_mulExtended(const glsl_type
*type
)
5047 ir_variable
*x
= in_var(type
, "x");
5048 ir_variable
*y
= in_var(type
, "y");
5049 ir_variable
*msb
= out_var(type
, "msb");
5050 ir_variable
*lsb
= out_var(type
, "lsb");
5051 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
5053 body
.emit(assign(msb
, imul_high(x
, y
)));
5054 body
.emit(assign(lsb
, mul(x
, y
)));
5059 ir_function_signature
*
5060 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5062 ir_variable
*interpolant
= in_var(type
, "interpolant");
5063 interpolant
->data
.must_be_shader_input
= 1;
5064 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
5066 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5071 ir_function_signature
*
5072 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5074 ir_variable
*interpolant
= in_var(type
, "interpolant");
5075 interpolant
->data
.must_be_shader_input
= 1;
5076 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5077 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
5079 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5084 ir_function_signature
*
5085 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5087 ir_variable
*interpolant
= in_var(type
, "interpolant");
5088 interpolant
->data
.must_be_shader_input
= 1;
5089 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5090 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
5092 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5097 ir_function_signature
*
5098 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
)
5100 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5101 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
5105 ir_function_signature
*
5106 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5107 const glsl_type
*type
)
5109 ir_variable
*atomic
= in_var(type
, "atomic");
5110 ir_variable
*data
= in_var(type
, "data");
5111 MAKE_INTRINSIC(type
, avail
, 2, atomic
, data
);
5115 ir_function_signature
*
5116 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5117 const glsl_type
*type
)
5119 ir_variable
*atomic
= in_var(type
, "atomic");
5120 ir_variable
*data1
= in_var(type
, "data1");
5121 ir_variable
*data2
= in_var(type
, "data2");
5122 MAKE_INTRINSIC(type
, avail
, 3, atomic
, data1
, data2
);
5126 ir_function_signature
*
5127 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5128 builtin_available_predicate avail
)
5130 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5131 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5133 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5134 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5136 body
.emit(ret(retval
));
5140 ir_function_signature
*
5141 builtin_builder::_atomic_op2(const char *intrinsic
,
5142 builtin_available_predicate avail
,
5143 const glsl_type
*type
)
5145 ir_variable
*atomic
= in_var(type
, "atomic_var");
5146 ir_variable
*data
= in_var(type
, "atomic_data");
5147 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5149 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5150 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5152 body
.emit(ret(retval
));
5156 ir_function_signature
*
5157 builtin_builder::_atomic_op3(const char *intrinsic
,
5158 builtin_available_predicate avail
,
5159 const glsl_type
*type
)
5161 ir_variable
*atomic
= in_var(type
, "atomic_var");
5162 ir_variable
*data1
= in_var(type
, "atomic_data1");
5163 ir_variable
*data2
= in_var(type
, "atomic_data2");
5164 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5166 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5167 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5169 body
.emit(ret(retval
));
5173 ir_function_signature
*
5174 builtin_builder::_min3(const glsl_type
*type
)
5176 ir_variable
*x
= in_var(type
, "x");
5177 ir_variable
*y
= in_var(type
, "y");
5178 ir_variable
*z
= in_var(type
, "z");
5179 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5181 ir_expression
*min3
= min2(x
, min2(y
,z
));
5182 body
.emit(ret(min3
));
5187 ir_function_signature
*
5188 builtin_builder::_max3(const glsl_type
*type
)
5190 ir_variable
*x
= in_var(type
, "x");
5191 ir_variable
*y
= in_var(type
, "y");
5192 ir_variable
*z
= in_var(type
, "z");
5193 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5195 ir_expression
*max3
= max2(x
, max2(y
,z
));
5196 body
.emit(ret(max3
));
5201 ir_function_signature
*
5202 builtin_builder::_mid3(const glsl_type
*type
)
5204 ir_variable
*x
= in_var(type
, "x");
5205 ir_variable
*y
= in_var(type
, "y");
5206 ir_variable
*z
= in_var(type
, "z");
5207 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5209 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5210 body
.emit(ret(mid3
));
5215 ir_function_signature
*
5216 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5217 unsigned num_arguments
,
5220 const glsl_type
*data_type
= glsl_type::get_instance(
5221 image_type
->sampler_type
,
5222 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5224 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5225 glsl_type::void_type
: data_type
);
5227 /* Addressing arguments that are always present. */
5228 ir_variable
*image
= in_var(image_type
, "image");
5229 ir_variable
*coord
= in_var(
5230 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5232 const builtin_available_predicate avail
=
5233 (flags
& IMAGE_FUNCTION_AVAIL_ATOMIC
? shader_image_atomic
:
5234 shader_image_load_store
);
5235 ir_function_signature
*sig
= new_sig(ret_type
, avail
, 2, image
, coord
);
5237 /* Sample index for multisample images. */
5238 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5239 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5241 /* Data arguments. */
5242 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5243 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5244 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5245 ralloc_free(arg_name
);
5248 /* Set the maximal set of qualifiers allowed for this image
5249 * built-in. Function calls with arguments having fewer
5250 * qualifiers than present in the prototype are allowed by the
5251 * spec, but not with more, i.e. this will make the compiler
5252 * accept everything that needs to be accepted, and reject cases
5253 * like loads from write-only or stores to read-only images.
5255 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5256 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5257 image
->data
.image_coherent
= true;
5258 image
->data
.image_volatile
= true;
5259 image
->data
.image_restrict
= true;
5264 ir_function_signature
*
5265 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5266 unsigned /* num_arguments */,
5267 unsigned /* flags */)
5269 const glsl_type
*ret_type
;
5270 unsigned num_components
= image_type
->coordinate_components();
5272 /* From the ARB_shader_image_size extension:
5273 * "Cube images return the dimensions of one face."
5275 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5276 !image_type
->sampler_array
) {
5280 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5281 * supported by mesa.
5283 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5285 ir_variable
*image
= in_var(image_type
, "image");
5286 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5288 /* Set the maximal set of qualifiers allowed for this image
5289 * built-in. Function calls with arguments having fewer
5290 * qualifiers than present in the prototype are allowed by the
5291 * spec, but not with more, i.e. this will make the compiler
5292 * accept everything that needs to be accepted, and reject cases
5293 * like loads from write-only or stores to read-only images.
5295 image
->data
.image_read_only
= true;
5296 image
->data
.image_write_only
= true;
5297 image
->data
.image_coherent
= true;
5298 image
->data
.image_volatile
= true;
5299 image
->data
.image_restrict
= true;
5304 ir_function_signature
*
5305 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5306 unsigned /* num_arguments */,
5307 unsigned /* flags */)
5309 ir_variable
*image
= in_var(image_type
, "image");
5310 ir_function_signature
*sig
=
5311 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5313 /* Set the maximal set of qualifiers allowed for this image
5314 * built-in. Function calls with arguments having fewer
5315 * qualifiers than present in the prototype are allowed by the
5316 * spec, but not with more, i.e. this will make the compiler
5317 * accept everything that needs to be accepted, and reject cases
5318 * like loads from write-only or stores to read-only images.
5320 image
->data
.image_read_only
= true;
5321 image
->data
.image_write_only
= true;
5322 image
->data
.image_coherent
= true;
5323 image
->data
.image_volatile
= true;
5324 image
->data
.image_restrict
= true;
5329 ir_function_signature
*
5330 builtin_builder::_image(image_prototype_ctr prototype
,
5331 const glsl_type
*image_type
,
5332 const char *intrinsic_name
,
5333 unsigned num_arguments
,
5336 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5337 num_arguments
, flags
);
5339 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5340 ir_factory
body(&sig
->body
, mem_ctx
);
5341 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5343 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5344 body
.emit(call(f
, NULL
, sig
->parameters
));
5346 ir_variable
*ret_val
=
5347 body
.make_temp(sig
->return_type
, "_ret_val");
5348 body
.emit(call(f
, ret_val
, sig
->parameters
));
5349 body
.emit(ret(ret_val
));
5352 sig
->is_defined
= true;
5355 sig
->is_intrinsic
= true;
5361 ir_function_signature
*
5362 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5364 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5368 ir_function_signature
*
5369 builtin_builder::_memory_barrier(const char *intrinsic_name
,
5370 builtin_available_predicate avail
)
5372 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5373 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
5374 NULL
, sig
->parameters
));
5378 ir_function_signature
*
5379 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
5380 const glsl_type
*type
)
5382 MAKE_INTRINSIC(type
, avail
, 0);
5386 ir_function_signature
*
5387 builtin_builder::_shader_clock(builtin_available_predicate avail
,
5388 const glsl_type
*type
)
5390 MAKE_SIG(type
, avail
, 0);
5392 ir_variable
*retval
= body
.make_temp(type
, "clock_retval");
5394 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
5395 retval
, sig
->parameters
));
5396 body
.emit(ret(retval
));
5402 /******************************************************************************/
5404 /* The singleton instance of builtin_builder. */
5405 static builtin_builder builtins
;
5406 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5409 * External API (exposing the built-in module to the rest of the compiler):
5413 _mesa_glsl_initialize_builtin_functions()
5415 mtx_lock(&builtins_lock
);
5416 builtins
.initialize();
5417 mtx_unlock(&builtins_lock
);
5421 _mesa_glsl_release_builtin_functions()
5423 mtx_lock(&builtins_lock
);
5425 mtx_unlock(&builtins_lock
);
5428 ir_function_signature
*
5429 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5430 const char *name
, exec_list
*actual_parameters
)
5432 ir_function_signature
* s
;
5433 mtx_lock(&builtins_lock
);
5434 s
= builtins
.find(state
, name
, actual_parameters
);
5435 mtx_unlock(&builtins_lock
);
5440 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5443 mtx_lock(&builtins_lock
);
5444 f
= builtins
.shader
->symbols
->get_function(name
);
5445 mtx_unlock(&builtins_lock
);
5450 _mesa_glsl_get_builtin_function_shader()
5452 return builtins
.shader
;
5457 * Get the function signature for main from a shader
5459 ir_function_signature
*
5460 _mesa_get_main_function_signature(gl_shader
*sh
)
5462 ir_function
*const f
= sh
->symbols
->get_function("main");
5464 exec_list void_parameters
;
5466 /* Look for the 'void main()' signature and ensure that it's defined.
5467 * This keeps the linker from accidentally pick a shader that just
5468 * contains a prototype for main.
5470 * We don't have to check for multiple definitions of main (in multiple
5471 * shaders) because that would have already been caught above.
5473 ir_function_signature
*sig
=
5474 f
->matching_signature(NULL
, &void_parameters
, false);
5475 if ((sig
!= NULL
) && sig
->is_defined
) {