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 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
295 return state
->stage
== MESA_SHADER_FRAGMENT
&&
296 (state
->is_version(400, 0) ||
297 state
->ARB_texture_cube_map_array_enable
);
301 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
303 return state
->is_version(400, 0) ||
304 state
->ARB_texture_cube_map_array_enable
;
308 texture_query_levels(const _mesa_glsl_parse_state
*state
)
310 return state
->is_version(430, 0) ||
311 state
->ARB_texture_query_levels_enable
;
315 texture_query_lod(const _mesa_glsl_parse_state
*state
)
317 return state
->stage
== MESA_SHADER_FRAGMENT
&&
318 state
->ARB_texture_query_lod_enable
;
322 texture_gather(const _mesa_glsl_parse_state
*state
)
324 return state
->is_version(400, 0) ||
325 state
->ARB_texture_gather_enable
||
326 state
->ARB_gpu_shader5_enable
;
330 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
332 return state
->is_version(400, 310) ||
333 state
->ARB_texture_gather_enable
||
334 state
->ARB_gpu_shader5_enable
;
337 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
338 * used for relaxation of const offset requirements.
341 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
343 return !state
->is_version(400, 0) &&
344 !state
->ARB_gpu_shader5_enable
&&
345 (state
->ARB_texture_gather_enable
||
346 state
->is_version(0, 310));
349 /* Desktop GL or OES_standard_derivatives + fragment shader only */
351 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
353 return state
->stage
== MESA_SHADER_FRAGMENT
&&
354 (state
->is_version(110, 300) ||
355 state
->OES_standard_derivatives_enable
);
359 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
361 return state
->stage
== MESA_SHADER_FRAGMENT
&&
362 (state
->is_version(450, 0) ||
363 state
->ARB_derivative_control_enable
);
367 tex1d_lod(const _mesa_glsl_parse_state
*state
)
369 return !state
->es_shader
&& lod_exists_in_stage(state
);
372 /** True if sampler3D exists */
374 tex3d(const _mesa_glsl_parse_state
*state
)
376 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
377 * OES_texture_3D extension, and in GLSL ES 3.00.
379 return !state
->es_shader
||
380 state
->OES_texture_3D_enable
||
381 state
->language_version
>= 300;
385 fs_tex3d(const _mesa_glsl_parse_state
*state
)
387 return state
->stage
== MESA_SHADER_FRAGMENT
&&
388 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
392 tex3d_lod(const _mesa_glsl_parse_state
*state
)
394 return tex3d(state
) && lod_exists_in_stage(state
);
398 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
400 return state
->has_atomic_counters();
404 shader_clock(const _mesa_glsl_parse_state
*state
)
406 return state
->ARB_shader_clock_enable
;
410 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
412 return state
->has_shader_storage_buffer_objects();
416 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
418 return state
->AMD_shader_trinary_minmax_enable
;
422 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
424 return (state
->is_version(420, 310) ||
425 state
->ARB_shader_image_load_store_enable
);
429 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
431 return (state
->is_version(420, 0) ||
432 state
->ARB_shader_image_load_store_enable
);
436 shader_image_size(const _mesa_glsl_parse_state
*state
)
438 return state
->is_version(430, 310) ||
439 state
->ARB_shader_image_size_enable
;
443 shader_samples(const _mesa_glsl_parse_state
*state
)
445 return state
->is_version(450, 0) ||
446 state
->ARB_shader_texture_image_samples_enable
;
450 gs_streams(const _mesa_glsl_parse_state
*state
)
452 return gpu_shader5(state
) && gs_only(state
);
456 fp64(const _mesa_glsl_parse_state
*state
)
458 return state
->has_double();
462 compute_shader(const _mesa_glsl_parse_state
*state
)
464 return state
->stage
== MESA_SHADER_COMPUTE
;
468 barrier_supported(const _mesa_glsl_parse_state
*state
)
470 return compute_shader(state
) ||
471 state
->stage
== MESA_SHADER_TESS_CTRL
;
476 /******************************************************************************/
481 * builtin_builder: A singleton object representing the core of the built-in
484 * It generates IR for every built-in function signature, and organizes them
487 class builtin_builder
{
494 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
495 const char *name
, exec_list
*actual_parameters
);
498 * A shader to hold all the built-in signatures; created by this module.
500 * This includes signatures for every built-in, regardless of version or
501 * enabled extensions. The availability predicate associated with each
502 * signature allows matching_signature() to filter out the irrelevant ones.
509 /** Global variables used by built-in functions. */
510 ir_variable
*gl_ModelViewProjectionMatrix
;
511 ir_variable
*gl_Vertex
;
513 void create_shader();
514 void create_intrinsics();
515 void create_builtins();
518 * IR builder helpers:
520 * These convenience functions assist in emitting IR, but don't necessarily
521 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
524 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
525 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
526 ir_constant
*imm(float f
, unsigned vector_elements
=1);
527 ir_constant
*imm(int i
, unsigned vector_elements
=1);
528 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
529 ir_constant
*imm(double d
, unsigned vector_elements
=1);
530 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
531 ir_dereference_variable
*var_ref(ir_variable
*var
);
532 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
533 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
535 ir_expression
*asin_expr(ir_variable
*x
);
536 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
539 * Call function \param f with parameters specified as the linked
540 * list \param params of \c ir_variable objects. \param ret should
541 * point to the ir_variable that will hold the function return
542 * value, or be \c NULL if the function has void return type.
544 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
546 /** Create a new function and add the given signatures. */
547 void add_function(const char *name
, ...);
549 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
550 unsigned num_arguments
,
553 enum image_function_flags
{
554 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
555 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
556 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
557 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
558 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
559 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
560 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
561 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
565 * Create a new image built-in function for all known image types.
566 * \p flags is a bitfield of \c image_function_flags flags.
568 void add_image_function(const char *name
,
569 const char *intrinsic_name
,
570 image_prototype_ctr prototype
,
571 unsigned num_arguments
,
575 * Create new functions for all known image built-ins and types.
576 * If \p glsl is \c true, use the GLSL built-in names and emit code
577 * to call into the actual compiler intrinsic. If \p glsl is
578 * false, emit a function prototype with no body for each image
581 void add_image_functions(bool glsl
);
583 ir_function_signature
*new_sig(const glsl_type
*return_type
,
584 builtin_available_predicate avail
,
585 int num_params
, ...);
588 * Function signature generators:
591 ir_function_signature
*unop(builtin_available_predicate avail
,
592 ir_expression_operation opcode
,
593 const glsl_type
*return_type
,
594 const glsl_type
*param_type
);
595 ir_function_signature
*binop(ir_expression_operation opcode
,
596 builtin_available_predicate avail
,
597 const glsl_type
*return_type
,
598 const glsl_type
*param0_type
,
599 const glsl_type
*param1_type
);
601 #define B0(X) ir_function_signature *_##X();
602 #define B1(X) ir_function_signature *_##X(const glsl_type *);
603 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
604 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
605 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
606 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
643 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
644 const glsl_type
*val_type
,
645 const glsl_type
*blend_type
);
654 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
655 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
656 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
657 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
658 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
659 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
660 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
661 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
662 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
663 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
664 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
665 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
678 BA1(determinant_mat2
);
679 BA1(determinant_mat3
);
680 BA1(determinant_mat4
);
688 BA1(greaterThanEqual
);
697 /** Flags to _texture() */
698 #define TEX_PROJECT 1
700 #define TEX_COMPONENT 4
701 #define TEX_OFFSET_NONCONST 8
702 #define TEX_OFFSET_ARRAY 16
704 ir_function_signature
*_texture(ir_texture_opcode opcode
,
705 builtin_available_predicate avail
,
706 const glsl_type
*return_type
,
707 const glsl_type
*sampler_type
,
708 const glsl_type
*coord_type
,
710 B0(textureCubeArrayShadow
);
711 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
712 const glsl_type
*return_type
,
713 const glsl_type
*sampler_type
,
714 const glsl_type
*coord_type
,
715 const glsl_type
*offset_type
= NULL
);
719 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
720 const glsl_type
*stream_type
);
721 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
722 const glsl_type
*stream_type
);
725 BA2(textureQueryLod
);
726 B1(textureQueryLevels
);
754 B1(interpolateAtCentroid
)
755 B1(interpolateAtOffset
)
756 B1(interpolateAtSample
)
758 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
);
759 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
760 builtin_available_predicate avail
);
762 ir_function_signature
*_atomic_ssbo_intrinsic2(builtin_available_predicate avail
,
763 const glsl_type
*type
);
764 ir_function_signature
*_atomic_ssbo_op2(const char *intrinsic
,
765 builtin_available_predicate avail
,
766 const glsl_type
*type
);
767 ir_function_signature
*_atomic_ssbo_intrinsic3(builtin_available_predicate avail
,
768 const glsl_type
*type
);
769 ir_function_signature
*_atomic_ssbo_op3(const char *intrinsic
,
770 builtin_available_predicate avail
,
771 const glsl_type
*type
);
777 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
778 unsigned num_arguments
,
780 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
781 unsigned num_arguments
,
783 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
784 unsigned num_arguments
,
786 ir_function_signature
*_image(image_prototype_ctr prototype
,
787 const glsl_type
*image_type
,
788 const char *intrinsic_name
,
789 unsigned num_arguments
,
792 ir_function_signature
*_memory_barrier_intrinsic(
793 builtin_available_predicate avail
);
794 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
795 builtin_available_predicate avail
);
797 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
798 const glsl_type
*type
);
799 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
800 const glsl_type
*type
);
811 } /* anonymous namespace */
814 * Core builtin_builder functionality:
817 builtin_builder::builtin_builder()
819 gl_ModelViewProjectionMatrix(NULL
),
825 builtin_builder::~builtin_builder()
827 ralloc_free(mem_ctx
);
830 ir_function_signature
*
831 builtin_builder::find(_mesa_glsl_parse_state
*state
,
832 const char *name
, exec_list
*actual_parameters
)
834 /* The shader currently being compiled requested a built-in function;
835 * it needs to link against builtin_builder::shader in order to get them.
837 * Even if we don't find a matching signature, we still need to do this so
838 * that the "no matching signature" error will list potential candidates
839 * from the available built-ins.
841 state
->uses_builtin_functions
= true;
843 ir_function
*f
= shader
->symbols
->get_function(name
);
847 ir_function_signature
*sig
=
848 f
->matching_signature(state
, actual_parameters
, true);
856 builtin_builder::initialize()
858 /* If already initialized, don't do it again. */
862 mem_ctx
= ralloc_context(NULL
);
869 builtin_builder::release()
871 ralloc_free(mem_ctx
);
879 builtin_builder::create_shader()
881 /* The target doesn't actually matter. There's no target for generic
882 * GLSL utility code that could be linked against any stage, so just
883 * arbitrarily pick GL_VERTEX_SHADER.
885 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
886 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
888 gl_ModelViewProjectionMatrix
=
889 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
890 "gl_ModelViewProjectionMatrix",
893 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
895 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
896 shader
->symbols
->add_variable(gl_Vertex
);
902 * Create ir_function and ir_function_signature objects for each
906 builtin_builder::create_intrinsics()
908 add_function("__intrinsic_atomic_read",
909 _atomic_counter_intrinsic(shader_atomic_counters
),
911 add_function("__intrinsic_atomic_increment",
912 _atomic_counter_intrinsic(shader_atomic_counters
),
914 add_function("__intrinsic_atomic_predecrement",
915 _atomic_counter_intrinsic(shader_atomic_counters
),
918 add_function("__intrinsic_ssbo_atomic_add",
919 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
920 glsl_type::uint_type
),
921 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
922 glsl_type::int_type
),
924 add_function("__intrinsic_ssbo_atomic_min",
925 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
926 glsl_type::uint_type
),
927 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
928 glsl_type::int_type
),
930 add_function("__intrinsic_ssbo_atomic_max",
931 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
932 glsl_type::uint_type
),
933 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
934 glsl_type::int_type
),
936 add_function("__intrinsic_ssbo_atomic_and",
937 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
938 glsl_type::uint_type
),
939 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
940 glsl_type::int_type
),
942 add_function("__intrinsic_ssbo_atomic_or",
943 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
944 glsl_type::uint_type
),
945 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
946 glsl_type::int_type
),
948 add_function("__intrinsic_ssbo_atomic_xor",
949 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
950 glsl_type::uint_type
),
951 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
952 glsl_type::int_type
),
954 add_function("__intrinsic_ssbo_atomic_exchange",
955 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
956 glsl_type::uint_type
),
957 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
958 glsl_type::int_type
),
960 add_function("__intrinsic_ssbo_atomic_comp_swap",
961 _atomic_ssbo_intrinsic3(shader_storage_buffer_object
,
962 glsl_type::uint_type
),
963 _atomic_ssbo_intrinsic3(shader_storage_buffer_object
,
964 glsl_type::int_type
),
967 add_image_functions(false);
969 add_function("__intrinsic_memory_barrier",
970 _memory_barrier_intrinsic(shader_image_load_store
),
972 add_function("__intrinsic_group_memory_barrier",
973 _memory_barrier_intrinsic(compute_shader
),
975 add_function("__intrinsic_memory_barrier_atomic_counter",
976 _memory_barrier_intrinsic(compute_shader
),
978 add_function("__intrinsic_memory_barrier_buffer",
979 _memory_barrier_intrinsic(compute_shader
),
981 add_function("__intrinsic_memory_barrier_image",
982 _memory_barrier_intrinsic(compute_shader
),
984 add_function("__intrinsic_memory_barrier_shared",
985 _memory_barrier_intrinsic(compute_shader
),
988 add_function("__intrinsic_shader_clock",
989 _shader_clock_intrinsic(shader_clock
,
990 glsl_type::uvec2_type
),
995 * Create ir_function and ir_function_signature objects for each built-in.
997 * Contains a list of every available built-in.
1000 builtin_builder::create_builtins()
1003 add_function(#NAME, \
1004 _##NAME(glsl_type::float_type), \
1005 _##NAME(glsl_type::vec2_type), \
1006 _##NAME(glsl_type::vec3_type), \
1007 _##NAME(glsl_type::vec4_type), \
1011 add_function(#NAME, \
1012 _##NAME(always_available, glsl_type::float_type), \
1013 _##NAME(always_available, glsl_type::vec2_type), \
1014 _##NAME(always_available, glsl_type::vec3_type), \
1015 _##NAME(always_available, glsl_type::vec4_type), \
1016 _##NAME(fp64, glsl_type::double_type), \
1017 _##NAME(fp64, glsl_type::dvec2_type), \
1018 _##NAME(fp64, glsl_type::dvec3_type), \
1019 _##NAME(fp64, glsl_type::dvec4_type), \
1022 #define FD130(NAME) \
1023 add_function(#NAME, \
1024 _##NAME(v130, glsl_type::float_type), \
1025 _##NAME(v130, glsl_type::vec2_type), \
1026 _##NAME(v130, glsl_type::vec3_type), \
1027 _##NAME(v130, glsl_type::vec4_type), \
1028 _##NAME(fp64, glsl_type::double_type), \
1029 _##NAME(fp64, glsl_type::dvec2_type), \
1030 _##NAME(fp64, glsl_type::dvec3_type), \
1031 _##NAME(fp64, glsl_type::dvec4_type), \
1034 #define FDGS5(NAME) \
1035 add_function(#NAME, \
1036 _##NAME(gpu_shader5, glsl_type::float_type), \
1037 _##NAME(gpu_shader5, glsl_type::vec2_type), \
1038 _##NAME(gpu_shader5, glsl_type::vec3_type), \
1039 _##NAME(gpu_shader5, glsl_type::vec4_type), \
1040 _##NAME(fp64, glsl_type::double_type), \
1041 _##NAME(fp64, glsl_type::dvec2_type), \
1042 _##NAME(fp64, glsl_type::dvec3_type), \
1043 _##NAME(fp64, glsl_type::dvec4_type), \
1047 add_function(#NAME, \
1048 _##NAME(glsl_type::float_type), \
1049 _##NAME(glsl_type::vec2_type), \
1050 _##NAME(glsl_type::vec3_type), \
1051 _##NAME(glsl_type::vec4_type), \
1052 _##NAME(glsl_type::int_type), \
1053 _##NAME(glsl_type::ivec2_type), \
1054 _##NAME(glsl_type::ivec3_type), \
1055 _##NAME(glsl_type::ivec4_type), \
1059 add_function(#NAME, \
1060 _##NAME(always_available, glsl_type::float_type), \
1061 _##NAME(always_available, glsl_type::vec2_type), \
1062 _##NAME(always_available, glsl_type::vec3_type), \
1063 _##NAME(always_available, glsl_type::vec4_type), \
1064 _##NAME(always_available, glsl_type::int_type), \
1065 _##NAME(always_available, glsl_type::ivec2_type), \
1066 _##NAME(always_available, glsl_type::ivec3_type), \
1067 _##NAME(always_available, glsl_type::ivec4_type), \
1068 _##NAME(fp64, glsl_type::double_type), \
1069 _##NAME(fp64, glsl_type::dvec2_type), \
1070 _##NAME(fp64, glsl_type::dvec3_type), \
1071 _##NAME(fp64, glsl_type::dvec4_type), \
1074 #define FIUD(NAME) \
1075 add_function(#NAME, \
1076 _##NAME(always_available, glsl_type::float_type), \
1077 _##NAME(always_available, glsl_type::vec2_type), \
1078 _##NAME(always_available, glsl_type::vec3_type), \
1079 _##NAME(always_available, glsl_type::vec4_type), \
1081 _##NAME(always_available, glsl_type::int_type), \
1082 _##NAME(always_available, glsl_type::ivec2_type), \
1083 _##NAME(always_available, glsl_type::ivec3_type), \
1084 _##NAME(always_available, glsl_type::ivec4_type), \
1086 _##NAME(v130, glsl_type::uint_type), \
1087 _##NAME(v130, glsl_type::uvec2_type), \
1088 _##NAME(v130, glsl_type::uvec3_type), \
1089 _##NAME(v130, glsl_type::uvec4_type), \
1090 _##NAME(fp64, glsl_type::double_type), \
1091 _##NAME(fp64, glsl_type::dvec2_type), \
1092 _##NAME(fp64, glsl_type::dvec3_type), \
1093 _##NAME(fp64, glsl_type::dvec4_type), \
1097 add_function(#NAME, \
1098 _##NAME(glsl_type::int_type), \
1099 _##NAME(glsl_type::ivec2_type), \
1100 _##NAME(glsl_type::ivec3_type), \
1101 _##NAME(glsl_type::ivec4_type), \
1103 _##NAME(glsl_type::uint_type), \
1104 _##NAME(glsl_type::uvec2_type), \
1105 _##NAME(glsl_type::uvec3_type), \
1106 _##NAME(glsl_type::uvec4_type), \
1109 #define FIUBD(NAME) \
1110 add_function(#NAME, \
1111 _##NAME(always_available, glsl_type::float_type), \
1112 _##NAME(always_available, glsl_type::vec2_type), \
1113 _##NAME(always_available, glsl_type::vec3_type), \
1114 _##NAME(always_available, glsl_type::vec4_type), \
1116 _##NAME(always_available, glsl_type::int_type), \
1117 _##NAME(always_available, glsl_type::ivec2_type), \
1118 _##NAME(always_available, glsl_type::ivec3_type), \
1119 _##NAME(always_available, glsl_type::ivec4_type), \
1121 _##NAME(v130, glsl_type::uint_type), \
1122 _##NAME(v130, glsl_type::uvec2_type), \
1123 _##NAME(v130, glsl_type::uvec3_type), \
1124 _##NAME(v130, glsl_type::uvec4_type), \
1126 _##NAME(always_available, glsl_type::bool_type), \
1127 _##NAME(always_available, glsl_type::bvec2_type), \
1128 _##NAME(always_available, glsl_type::bvec3_type), \
1129 _##NAME(always_available, glsl_type::bvec4_type), \
1131 _##NAME(fp64, glsl_type::double_type), \
1132 _##NAME(fp64, glsl_type::dvec2_type), \
1133 _##NAME(fp64, glsl_type::dvec3_type), \
1134 _##NAME(fp64, glsl_type::dvec4_type), \
1137 #define FIUD2_MIXED(NAME) \
1138 add_function(#NAME, \
1139 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1140 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1141 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1142 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1144 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1145 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1146 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1148 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1149 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1150 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1151 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1153 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1154 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1155 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1157 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1158 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1159 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1160 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1162 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1163 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1164 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1166 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1167 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1168 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1169 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1170 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1171 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1172 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1183 add_function("atan",
1184 _atan(glsl_type::float_type
),
1185 _atan(glsl_type::vec2_type
),
1186 _atan(glsl_type::vec3_type
),
1187 _atan(glsl_type::vec4_type
),
1188 _atan2(glsl_type::float_type
),
1189 _atan2(glsl_type::vec2_type
),
1190 _atan2(glsl_type::vec3_type
),
1191 _atan2(glsl_type::vec4_type
),
1217 _mod(glsl_type::float_type
, glsl_type::float_type
),
1218 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
1219 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
1220 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
1222 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
1223 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
1224 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
1226 _mod(glsl_type::double_type
, glsl_type::double_type
),
1227 _mod(glsl_type::dvec2_type
, glsl_type::double_type
),
1228 _mod(glsl_type::dvec3_type
, glsl_type::double_type
),
1229 _mod(glsl_type::dvec4_type
, glsl_type::double_type
),
1231 _mod(glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1232 _mod(glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1233 _mod(glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1243 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1244 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1245 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1246 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1248 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1249 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1250 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1252 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1253 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1254 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1255 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1257 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1258 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1259 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1261 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1262 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1263 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1264 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1266 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1267 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1268 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1269 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1271 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1272 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1273 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1274 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1276 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1277 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1278 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1279 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1281 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1282 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1283 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1284 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1287 add_function("step",
1288 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1289 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1290 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1291 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1293 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1294 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1295 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1296 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1297 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1298 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1299 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1301 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1302 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1303 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1306 add_function("smoothstep",
1307 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1308 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1309 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1310 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1312 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1313 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1314 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1315 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1316 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1317 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1318 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1320 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1321 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1322 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1330 add_function("intBitsToFloat",
1331 _intBitsToFloat(glsl_type::int_type
),
1332 _intBitsToFloat(glsl_type::ivec2_type
),
1333 _intBitsToFloat(glsl_type::ivec3_type
),
1334 _intBitsToFloat(glsl_type::ivec4_type
),
1336 add_function("uintBitsToFloat",
1337 _uintBitsToFloat(glsl_type::uint_type
),
1338 _uintBitsToFloat(glsl_type::uvec2_type
),
1339 _uintBitsToFloat(glsl_type::uvec3_type
),
1340 _uintBitsToFloat(glsl_type::uvec4_type
),
1343 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1344 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1345 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1346 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1347 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1348 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1349 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1350 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1351 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1352 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1353 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1354 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1361 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1362 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1365 add_function("ftransform", _ftransform(), NULL
);
1370 add_function("matrixCompMult",
1371 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1372 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1373 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1374 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1375 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1376 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1377 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1378 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1379 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1380 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1381 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1382 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1383 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1384 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1385 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1386 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1387 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1388 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1390 add_function("outerProduct",
1391 _outerProduct(v120
, glsl_type::mat2_type
),
1392 _outerProduct(v120
, glsl_type::mat3_type
),
1393 _outerProduct(v120
, glsl_type::mat4_type
),
1394 _outerProduct(v120
, glsl_type::mat2x3_type
),
1395 _outerProduct(v120
, glsl_type::mat2x4_type
),
1396 _outerProduct(v120
, glsl_type::mat3x2_type
),
1397 _outerProduct(v120
, glsl_type::mat3x4_type
),
1398 _outerProduct(v120
, glsl_type::mat4x2_type
),
1399 _outerProduct(v120
, glsl_type::mat4x3_type
),
1400 _outerProduct(fp64
, glsl_type::dmat2_type
),
1401 _outerProduct(fp64
, glsl_type::dmat3_type
),
1402 _outerProduct(fp64
, glsl_type::dmat4_type
),
1403 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1404 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1405 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1406 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1407 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1408 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1410 add_function("determinant",
1411 _determinant_mat2(v120
, glsl_type::mat2_type
),
1412 _determinant_mat3(v120
, glsl_type::mat3_type
),
1413 _determinant_mat4(v120
, glsl_type::mat4_type
),
1414 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1415 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1416 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1419 add_function("inverse",
1420 _inverse_mat2(v120
, glsl_type::mat2_type
),
1421 _inverse_mat3(v120
, glsl_type::mat3_type
),
1422 _inverse_mat4(v120
, glsl_type::mat4_type
),
1423 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1424 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1425 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1427 add_function("transpose",
1428 _transpose(v120
, glsl_type::mat2_type
),
1429 _transpose(v120
, glsl_type::mat3_type
),
1430 _transpose(v120
, glsl_type::mat4_type
),
1431 _transpose(v120
, glsl_type::mat2x3_type
),
1432 _transpose(v120
, glsl_type::mat2x4_type
),
1433 _transpose(v120
, glsl_type::mat3x2_type
),
1434 _transpose(v120
, glsl_type::mat3x4_type
),
1435 _transpose(v120
, glsl_type::mat4x2_type
),
1436 _transpose(v120
, glsl_type::mat4x3_type
),
1437 _transpose(fp64
, glsl_type::dmat2_type
),
1438 _transpose(fp64
, glsl_type::dmat3_type
),
1439 _transpose(fp64
, glsl_type::dmat4_type
),
1440 _transpose(fp64
, glsl_type::dmat2x3_type
),
1441 _transpose(fp64
, glsl_type::dmat2x4_type
),
1442 _transpose(fp64
, glsl_type::dmat3x2_type
),
1443 _transpose(fp64
, glsl_type::dmat3x4_type
),
1444 _transpose(fp64
, glsl_type::dmat4x2_type
),
1445 _transpose(fp64
, glsl_type::dmat4x3_type
),
1450 FIUD(greaterThanEqual
)
1455 _any(glsl_type::bvec2_type
),
1456 _any(glsl_type::bvec3_type
),
1457 _any(glsl_type::bvec4_type
),
1461 _all(glsl_type::bvec2_type
),
1462 _all(glsl_type::bvec3_type
),
1463 _all(glsl_type::bvec4_type
),
1467 _not(glsl_type::bvec2_type
),
1468 _not(glsl_type::bvec3_type
),
1469 _not(glsl_type::bvec4_type
),
1472 add_function("textureSize",
1473 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1474 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1475 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1477 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1478 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1479 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1481 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1482 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1483 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1485 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1486 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1487 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1489 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1490 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1491 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1493 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1494 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1495 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1496 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1497 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1498 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1500 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1501 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1503 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1504 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1505 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1506 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1508 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1509 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1510 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1511 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1513 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1514 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1515 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1516 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1517 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1518 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1520 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1521 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1522 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1525 add_function("textureSamples",
1526 _textureSamples(glsl_type::sampler2DMS_type
),
1527 _textureSamples(glsl_type::isampler2DMS_type
),
1528 _textureSamples(glsl_type::usampler2DMS_type
),
1530 _textureSamples(glsl_type::sampler2DMSArray_type
),
1531 _textureSamples(glsl_type::isampler2DMSArray_type
),
1532 _textureSamples(glsl_type::usampler2DMSArray_type
),
1535 add_function("texture",
1536 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1537 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1538 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1540 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1541 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1542 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1544 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1545 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1546 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1548 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1549 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1550 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1552 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1553 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1554 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1556 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1557 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1558 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1560 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1561 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1562 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1564 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1565 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1566 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1568 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1569 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1570 /* samplerCubeArrayShadow is special; it has an extra parameter
1571 * for the shadow comparitor since there is no vec5 type.
1573 _textureCubeArrayShadow(),
1575 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1576 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1577 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1579 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1581 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1582 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1583 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1585 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1586 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1587 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1589 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1590 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1591 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1593 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1594 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1595 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1597 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1598 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1599 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1601 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1602 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1603 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1605 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1606 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1607 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1609 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1610 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1611 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1613 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1616 add_function("textureLod",
1617 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1618 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1619 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1621 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1622 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1623 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1625 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1626 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1627 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1629 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1630 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1631 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1633 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1634 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1636 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1637 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1638 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1640 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1641 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1642 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1644 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1645 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1646 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1648 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1651 add_function("textureOffset",
1652 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1653 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1654 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1656 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1657 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1658 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1660 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1661 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1662 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1664 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1665 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1666 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1668 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1670 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1671 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1673 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1674 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1675 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1677 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1678 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1679 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1681 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1683 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1684 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1685 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1687 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1688 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1689 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1691 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1692 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1693 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1695 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1696 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1698 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1699 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1700 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1702 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1703 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1704 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1706 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1709 add_function("textureProj",
1710 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1711 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1712 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1713 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1714 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1715 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1717 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1718 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1719 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1720 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1721 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1722 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1724 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1725 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1726 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1728 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1729 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1731 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1732 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1733 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1734 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1735 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1736 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1738 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1740 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1741 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1742 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1743 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1744 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1745 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1747 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1748 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1749 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1750 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1751 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1752 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1754 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1755 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1756 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1758 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1759 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1762 add_function("texelFetch",
1763 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1764 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1765 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1767 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1768 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1769 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1771 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1772 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1773 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1775 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1776 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1777 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1779 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1780 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1781 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1783 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1784 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1785 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1787 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1788 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1789 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1791 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1792 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1793 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1795 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1796 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1797 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1800 add_function("texelFetchOffset",
1801 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1802 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1803 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1805 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1806 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1807 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1809 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1810 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1811 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1813 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1814 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1815 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1817 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1818 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1819 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1821 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1822 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1823 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1827 add_function("textureProjOffset",
1828 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1829 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1830 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1831 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1832 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1833 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1835 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1836 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1837 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1838 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1839 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1840 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1842 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1843 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1844 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1846 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1847 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1849 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1850 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1851 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1852 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1853 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1854 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1856 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1858 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1859 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1860 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1861 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1862 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1863 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1865 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1866 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1867 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1868 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1869 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1870 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1872 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1873 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1874 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1876 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1877 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1880 add_function("textureLodOffset",
1881 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1882 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1883 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1885 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1886 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1887 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1889 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1890 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1891 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1893 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1894 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1896 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1897 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1898 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1900 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1901 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1902 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1904 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1907 add_function("textureProjLod",
1908 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1909 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1910 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1911 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1912 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1913 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1915 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1916 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1917 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1918 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1919 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1920 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1922 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1923 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1924 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1926 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1927 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1930 add_function("textureProjLodOffset",
1931 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1932 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1933 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1934 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1935 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1936 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1938 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1939 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1940 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1941 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1942 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1943 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1945 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1946 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1947 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1949 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1950 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1953 add_function("textureGrad",
1954 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1955 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1956 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1958 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1959 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1960 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1962 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1963 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1964 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1966 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1967 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1968 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1970 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1971 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1972 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1974 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1976 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1977 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1978 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1980 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1981 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1982 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1984 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1985 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1986 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1988 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1989 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1990 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1992 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1993 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1996 add_function("textureGradOffset",
1997 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1998 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1999 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2001 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2002 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2003 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2005 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2006 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2007 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2009 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2010 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2011 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2013 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2015 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2016 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2018 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2019 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2020 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2022 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2023 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2024 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2026 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2027 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2030 add_function("textureProjGrad",
2031 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2032 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2033 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2034 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2035 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2036 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2038 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2039 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2040 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2041 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2042 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2043 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2045 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2046 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2047 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2049 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2050 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2051 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2052 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2053 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2054 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2056 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2058 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2059 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2062 add_function("textureProjGradOffset",
2063 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2064 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2065 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2066 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2067 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2068 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2070 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2071 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2072 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2073 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2074 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2075 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2077 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2078 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2079 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2081 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2082 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2083 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2084 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2085 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2086 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2088 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2090 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2091 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2094 add_function("EmitVertex", _EmitVertex(), NULL
);
2095 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2096 add_function("EmitStreamVertex",
2097 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2098 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2100 add_function("EndStreamPrimitive",
2101 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2102 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2104 add_function("barrier", _barrier(), NULL
);
2106 add_function("textureQueryLOD",
2107 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2108 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2109 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2111 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2112 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2113 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2115 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2116 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2117 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2119 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2120 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2121 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2123 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2124 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2125 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2127 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2128 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2129 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2131 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2132 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2133 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2135 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2136 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2137 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2138 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2139 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2140 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2143 add_function("textureQueryLod",
2144 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2145 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2146 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2148 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2149 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2150 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2152 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2153 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2154 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2156 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2157 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2158 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2160 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2161 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2162 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2164 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2165 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2166 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2168 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2169 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2170 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2172 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2173 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2174 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2175 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2176 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2177 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2180 add_function("textureQueryLevels",
2181 _textureQueryLevels(glsl_type::sampler1D_type
),
2182 _textureQueryLevels(glsl_type::sampler2D_type
),
2183 _textureQueryLevels(glsl_type::sampler3D_type
),
2184 _textureQueryLevels(glsl_type::samplerCube_type
),
2185 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2186 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2187 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2188 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2189 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2190 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2191 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2192 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2193 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2195 _textureQueryLevels(glsl_type::isampler1D_type
),
2196 _textureQueryLevels(glsl_type::isampler2D_type
),
2197 _textureQueryLevels(glsl_type::isampler3D_type
),
2198 _textureQueryLevels(glsl_type::isamplerCube_type
),
2199 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2200 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2201 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2203 _textureQueryLevels(glsl_type::usampler1D_type
),
2204 _textureQueryLevels(glsl_type::usampler2D_type
),
2205 _textureQueryLevels(glsl_type::usampler3D_type
),
2206 _textureQueryLevels(glsl_type::usamplerCube_type
),
2207 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2208 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2209 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2213 add_function("texture1D",
2214 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2215 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2218 add_function("texture1DArray",
2219 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2220 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2223 add_function("texture1DProj",
2224 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2225 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2226 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2227 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2230 add_function("texture1DLod",
2231 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2234 add_function("texture1DArrayLod",
2235 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2238 add_function("texture1DProjLod",
2239 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2240 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2243 add_function("texture2D",
2244 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2245 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2246 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2249 add_function("texture2DArray",
2250 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2251 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2254 add_function("texture2DProj",
2255 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2256 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2257 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2258 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2259 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2260 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2263 add_function("texture2DLod",
2264 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2267 add_function("texture2DArrayLod",
2268 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2271 add_function("texture2DProjLod",
2272 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2273 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2276 add_function("texture3D",
2277 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2278 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2281 add_function("texture3DProj",
2282 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2283 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2286 add_function("texture3DLod",
2287 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2290 add_function("texture3DProjLod",
2291 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2294 add_function("textureCube",
2295 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2296 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2299 add_function("textureCubeLod",
2300 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2303 add_function("texture2DRect",
2304 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2307 add_function("texture2DRectProj",
2308 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2309 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2312 add_function("shadow1D",
2313 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2314 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2317 add_function("shadow1DArray",
2318 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2319 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2322 add_function("shadow2D",
2323 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2324 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2327 add_function("shadow2DArray",
2328 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2329 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2332 add_function("shadow1DProj",
2333 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2334 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2337 add_function("shadow2DProj",
2338 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2339 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2342 add_function("shadow1DLod",
2343 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2346 add_function("shadow2DLod",
2347 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2350 add_function("shadow1DArrayLod",
2351 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2354 add_function("shadow1DProjLod",
2355 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2358 add_function("shadow2DProjLod",
2359 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2362 add_function("shadow2DRect",
2363 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2366 add_function("shadow2DRectProj",
2367 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2370 add_function("texture1DGradARB",
2371 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2374 add_function("texture1DProjGradARB",
2375 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2376 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2379 add_function("texture2DGradARB",
2380 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2383 add_function("texture2DProjGradARB",
2384 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2385 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2388 add_function("texture3DGradARB",
2389 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2392 add_function("texture3DProjGradARB",
2393 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2396 add_function("textureCubeGradARB",
2397 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2400 add_function("shadow1DGradARB",
2401 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2404 add_function("shadow1DProjGradARB",
2405 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2408 add_function("shadow2DGradARB",
2409 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2412 add_function("shadow2DProjGradARB",
2413 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2416 add_function("texture2DRectGradARB",
2417 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2420 add_function("texture2DRectProjGradARB",
2421 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2422 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2425 add_function("shadow2DRectGradARB",
2426 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2429 add_function("shadow2DRectProjGradARB",
2430 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2433 add_function("textureGather",
2434 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2435 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2436 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2438 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2439 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2440 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2442 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2443 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2444 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2446 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2447 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2448 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2450 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2451 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2452 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2454 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2455 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2456 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2458 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2459 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2460 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2462 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2463 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2464 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2466 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2467 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2468 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2470 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2471 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2472 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2474 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2475 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2476 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2477 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2478 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2481 add_function("textureGatherOffset",
2482 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2483 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2484 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2486 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2487 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2488 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2490 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2491 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2492 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2494 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2495 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2496 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2498 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2499 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2500 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2502 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2503 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2504 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2506 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2507 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2508 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2510 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2511 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2512 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2514 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2515 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2516 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2518 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2519 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2520 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2522 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2523 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2524 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2526 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2527 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2530 add_function("textureGatherOffsets",
2531 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2532 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2533 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2535 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2536 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2537 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2539 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2540 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2541 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2543 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2544 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2545 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2547 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2548 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2549 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2551 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2552 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2553 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2555 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2556 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2557 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2582 add_function("ldexp",
2583 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2584 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2585 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2586 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2587 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2588 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2589 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2590 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2593 add_function("frexp",
2594 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2595 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2596 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2597 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2598 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2599 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2600 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2601 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2603 add_function("uaddCarry",
2604 _uaddCarry(glsl_type::uint_type
),
2605 _uaddCarry(glsl_type::uvec2_type
),
2606 _uaddCarry(glsl_type::uvec3_type
),
2607 _uaddCarry(glsl_type::uvec4_type
),
2609 add_function("usubBorrow",
2610 _usubBorrow(glsl_type::uint_type
),
2611 _usubBorrow(glsl_type::uvec2_type
),
2612 _usubBorrow(glsl_type::uvec3_type
),
2613 _usubBorrow(glsl_type::uvec4_type
),
2615 add_function("imulExtended",
2616 _mulExtended(glsl_type::int_type
),
2617 _mulExtended(glsl_type::ivec2_type
),
2618 _mulExtended(glsl_type::ivec3_type
),
2619 _mulExtended(glsl_type::ivec4_type
),
2621 add_function("umulExtended",
2622 _mulExtended(glsl_type::uint_type
),
2623 _mulExtended(glsl_type::uvec2_type
),
2624 _mulExtended(glsl_type::uvec3_type
),
2625 _mulExtended(glsl_type::uvec4_type
),
2627 add_function("interpolateAtCentroid",
2628 _interpolateAtCentroid(glsl_type::float_type
),
2629 _interpolateAtCentroid(glsl_type::vec2_type
),
2630 _interpolateAtCentroid(glsl_type::vec3_type
),
2631 _interpolateAtCentroid(glsl_type::vec4_type
),
2633 add_function("interpolateAtOffset",
2634 _interpolateAtOffset(glsl_type::float_type
),
2635 _interpolateAtOffset(glsl_type::vec2_type
),
2636 _interpolateAtOffset(glsl_type::vec3_type
),
2637 _interpolateAtOffset(glsl_type::vec4_type
),
2639 add_function("interpolateAtSample",
2640 _interpolateAtSample(glsl_type::float_type
),
2641 _interpolateAtSample(glsl_type::vec2_type
),
2642 _interpolateAtSample(glsl_type::vec3_type
),
2643 _interpolateAtSample(glsl_type::vec4_type
),
2646 add_function("atomicCounter",
2647 _atomic_counter_op("__intrinsic_atomic_read",
2648 shader_atomic_counters
),
2650 add_function("atomicCounterIncrement",
2651 _atomic_counter_op("__intrinsic_atomic_increment",
2652 shader_atomic_counters
),
2654 add_function("atomicCounterDecrement",
2655 _atomic_counter_op("__intrinsic_atomic_predecrement",
2656 shader_atomic_counters
),
2659 add_function("atomicAdd",
2660 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_add",
2661 shader_storage_buffer_object
,
2662 glsl_type::uint_type
),
2663 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_add",
2664 shader_storage_buffer_object
,
2665 glsl_type::int_type
),
2667 add_function("atomicMin",
2668 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_min",
2669 shader_storage_buffer_object
,
2670 glsl_type::uint_type
),
2671 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_min",
2672 shader_storage_buffer_object
,
2673 glsl_type::int_type
),
2675 add_function("atomicMax",
2676 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_max",
2677 shader_storage_buffer_object
,
2678 glsl_type::uint_type
),
2679 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_max",
2680 shader_storage_buffer_object
,
2681 glsl_type::int_type
),
2683 add_function("atomicAnd",
2684 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_and",
2685 shader_storage_buffer_object
,
2686 glsl_type::uint_type
),
2687 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_and",
2688 shader_storage_buffer_object
,
2689 glsl_type::int_type
),
2691 add_function("atomicOr",
2692 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_or",
2693 shader_storage_buffer_object
,
2694 glsl_type::uint_type
),
2695 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_or",
2696 shader_storage_buffer_object
,
2697 glsl_type::int_type
),
2699 add_function("atomicXor",
2700 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_xor",
2701 shader_storage_buffer_object
,
2702 glsl_type::uint_type
),
2703 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_xor",
2704 shader_storage_buffer_object
,
2705 glsl_type::int_type
),
2707 add_function("atomicExchange",
2708 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_exchange",
2709 shader_storage_buffer_object
,
2710 glsl_type::uint_type
),
2711 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_exchange",
2712 shader_storage_buffer_object
,
2713 glsl_type::int_type
),
2715 add_function("atomicCompSwap",
2716 _atomic_ssbo_op3("__intrinsic_ssbo_atomic_comp_swap",
2717 shader_storage_buffer_object
,
2718 glsl_type::uint_type
),
2719 _atomic_ssbo_op3("__intrinsic_ssbo_atomic_comp_swap",
2720 shader_storage_buffer_object
,
2721 glsl_type::int_type
),
2724 add_function("min3",
2725 _min3(glsl_type::float_type
),
2726 _min3(glsl_type::vec2_type
),
2727 _min3(glsl_type::vec3_type
),
2728 _min3(glsl_type::vec4_type
),
2730 _min3(glsl_type::int_type
),
2731 _min3(glsl_type::ivec2_type
),
2732 _min3(glsl_type::ivec3_type
),
2733 _min3(glsl_type::ivec4_type
),
2735 _min3(glsl_type::uint_type
),
2736 _min3(glsl_type::uvec2_type
),
2737 _min3(glsl_type::uvec3_type
),
2738 _min3(glsl_type::uvec4_type
),
2741 add_function("max3",
2742 _max3(glsl_type::float_type
),
2743 _max3(glsl_type::vec2_type
),
2744 _max3(glsl_type::vec3_type
),
2745 _max3(glsl_type::vec4_type
),
2747 _max3(glsl_type::int_type
),
2748 _max3(glsl_type::ivec2_type
),
2749 _max3(glsl_type::ivec3_type
),
2750 _max3(glsl_type::ivec4_type
),
2752 _max3(glsl_type::uint_type
),
2753 _max3(glsl_type::uvec2_type
),
2754 _max3(glsl_type::uvec3_type
),
2755 _max3(glsl_type::uvec4_type
),
2758 add_function("mid3",
2759 _mid3(glsl_type::float_type
),
2760 _mid3(glsl_type::vec2_type
),
2761 _mid3(glsl_type::vec3_type
),
2762 _mid3(glsl_type::vec4_type
),
2764 _mid3(glsl_type::int_type
),
2765 _mid3(glsl_type::ivec2_type
),
2766 _mid3(glsl_type::ivec3_type
),
2767 _mid3(glsl_type::ivec4_type
),
2769 _mid3(glsl_type::uint_type
),
2770 _mid3(glsl_type::uvec2_type
),
2771 _mid3(glsl_type::uvec3_type
),
2772 _mid3(glsl_type::uvec4_type
),
2775 add_image_functions(true);
2777 add_function("memoryBarrier",
2778 _memory_barrier("__intrinsic_memory_barrier",
2779 shader_image_load_store
),
2781 add_function("groupMemoryBarrier",
2782 _memory_barrier("__intrinsic_group_memory_barrier",
2785 add_function("memoryBarrierAtomicCounter",
2786 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
2789 add_function("memoryBarrierBuffer",
2790 _memory_barrier("__intrinsic_memory_barrier_buffer",
2793 add_function("memoryBarrierImage",
2794 _memory_barrier("__intrinsic_memory_barrier_image",
2797 add_function("memoryBarrierShared",
2798 _memory_barrier("__intrinsic_memory_barrier_shared",
2802 add_function("clock2x32ARB",
2803 _shader_clock(shader_clock
,
2804 glsl_type::uvec2_type
),
2815 builtin_builder::add_function(const char *name
, ...)
2819 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2823 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2829 stuff
.push_tail(sig
);
2830 validate_ir_tree(&stuff
);
2833 f
->add_signature(sig
);
2837 shader
->symbols
->add_function(f
);
2841 builtin_builder::add_image_function(const char *name
,
2842 const char *intrinsic_name
,
2843 image_prototype_ctr prototype
,
2844 unsigned num_arguments
,
2847 static const glsl_type
*const types
[] = {
2848 glsl_type::image1D_type
,
2849 glsl_type::image2D_type
,
2850 glsl_type::image3D_type
,
2851 glsl_type::image2DRect_type
,
2852 glsl_type::imageCube_type
,
2853 glsl_type::imageBuffer_type
,
2854 glsl_type::image1DArray_type
,
2855 glsl_type::image2DArray_type
,
2856 glsl_type::imageCubeArray_type
,
2857 glsl_type::image2DMS_type
,
2858 glsl_type::image2DMSArray_type
,
2859 glsl_type::iimage1D_type
,
2860 glsl_type::iimage2D_type
,
2861 glsl_type::iimage3D_type
,
2862 glsl_type::iimage2DRect_type
,
2863 glsl_type::iimageCube_type
,
2864 glsl_type::iimageBuffer_type
,
2865 glsl_type::iimage1DArray_type
,
2866 glsl_type::iimage2DArray_type
,
2867 glsl_type::iimageCubeArray_type
,
2868 glsl_type::iimage2DMS_type
,
2869 glsl_type::iimage2DMSArray_type
,
2870 glsl_type::uimage1D_type
,
2871 glsl_type::uimage2D_type
,
2872 glsl_type::uimage3D_type
,
2873 glsl_type::uimage2DRect_type
,
2874 glsl_type::uimageCube_type
,
2875 glsl_type::uimageBuffer_type
,
2876 glsl_type::uimage1DArray_type
,
2877 glsl_type::uimage2DArray_type
,
2878 glsl_type::uimageCubeArray_type
,
2879 glsl_type::uimage2DMS_type
,
2880 glsl_type::uimage2DMSArray_type
2883 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2885 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2886 if ((types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2887 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
2888 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
2889 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
2890 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
2891 num_arguments
, flags
));
2894 shader
->symbols
->add_function(f
);
2898 builtin_builder::add_image_functions(bool glsl
)
2900 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2902 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2903 "__intrinsic_image_load",
2904 &builtin_builder::_image_prototype
, 0,
2905 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2906 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2907 IMAGE_FUNCTION_READ_ONLY
));
2909 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2910 "__intrinsic_image_store",
2911 &builtin_builder::_image_prototype
, 1,
2912 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2913 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2914 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2915 IMAGE_FUNCTION_WRITE_ONLY
));
2917 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
2919 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2920 "__intrinsic_image_atomic_add",
2921 &builtin_builder::_image_prototype
, 1, atom_flags
);
2923 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2924 "__intrinsic_image_atomic_min",
2925 &builtin_builder::_image_prototype
, 1, atom_flags
);
2927 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2928 "__intrinsic_image_atomic_max",
2929 &builtin_builder::_image_prototype
, 1, atom_flags
);
2931 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2932 "__intrinsic_image_atomic_and",
2933 &builtin_builder::_image_prototype
, 1, atom_flags
);
2935 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2936 "__intrinsic_image_atomic_or",
2937 &builtin_builder::_image_prototype
, 1, atom_flags
);
2939 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2940 "__intrinsic_image_atomic_xor",
2941 &builtin_builder::_image_prototype
, 1, atom_flags
);
2943 add_image_function((glsl
? "imageAtomicExchange" :
2944 "__intrinsic_image_atomic_exchange"),
2945 "__intrinsic_image_atomic_exchange",
2946 &builtin_builder::_image_prototype
, 1, atom_flags
);
2948 add_image_function((glsl
? "imageAtomicCompSwap" :
2949 "__intrinsic_image_atomic_comp_swap"),
2950 "__intrinsic_image_atomic_comp_swap",
2951 &builtin_builder::_image_prototype
, 2, atom_flags
);
2953 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
2954 "__intrinsic_image_size",
2955 &builtin_builder::_image_size_prototype
, 1,
2956 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
2958 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
2959 "__intrinsic_image_samples",
2960 &builtin_builder::_image_samples_prototype
, 1,
2961 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2962 IMAGE_FUNCTION_MS_ONLY
);
2966 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2968 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2972 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2974 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2978 builtin_builder::imm(float f
, unsigned vector_elements
)
2980 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2984 builtin_builder::imm(int i
, unsigned vector_elements
)
2986 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2990 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2992 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2996 builtin_builder::imm(double d
, unsigned vector_elements
)
2998 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3002 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3004 return new(mem_ctx
) ir_constant(type
, &data
);
3007 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
3009 ir_dereference_variable
*
3010 builtin_builder::var_ref(ir_variable
*var
)
3012 return new(mem_ctx
) ir_dereference_variable(var
);
3015 ir_dereference_array
*
3016 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3018 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3021 /** Return an element of a matrix */
3023 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3025 return swizzle(array_ref(var
, column
), row
, 1);
3029 * Implementations of built-in functions:
3032 ir_function_signature
*
3033 builtin_builder::new_sig(const glsl_type
*return_type
,
3034 builtin_available_predicate avail
,
3040 ir_function_signature
*sig
=
3041 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3044 va_start(ap
, num_params
);
3045 for (int i
= 0; i
< num_params
; i
++) {
3046 plist
.push_tail(va_arg(ap
, ir_variable
*));
3050 sig
->replace_parameters(&plist
);
3054 #define MAKE_SIG(return_type, avail, ...) \
3055 ir_function_signature *sig = \
3056 new_sig(return_type, avail, __VA_ARGS__); \
3057 ir_factory body(&sig->body, mem_ctx); \
3058 sig->is_defined = true;
3060 #define MAKE_INTRINSIC(return_type, avail, ...) \
3061 ir_function_signature *sig = \
3062 new_sig(return_type, avail, __VA_ARGS__); \
3063 sig->is_intrinsic = true;
3065 ir_function_signature
*
3066 builtin_builder::unop(builtin_available_predicate avail
,
3067 ir_expression_operation opcode
,
3068 const glsl_type
*return_type
,
3069 const glsl_type
*param_type
)
3071 ir_variable
*x
= in_var(param_type
, "x");
3072 MAKE_SIG(return_type
, avail
, 1, x
);
3073 body
.emit(ret(expr(opcode
, x
)));
3077 #define UNOP(NAME, OPCODE, AVAIL) \
3078 ir_function_signature * \
3079 builtin_builder::_##NAME(const glsl_type *type) \
3081 return unop(&AVAIL, OPCODE, type, type); \
3084 #define UNOPA(NAME, OPCODE) \
3085 ir_function_signature * \
3086 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3088 return unop(avail, OPCODE, type, type); \
3091 ir_function_signature
*
3092 builtin_builder::binop(ir_expression_operation opcode
,
3093 builtin_available_predicate avail
,
3094 const glsl_type
*return_type
,
3095 const glsl_type
*param0_type
,
3096 const glsl_type
*param1_type
)
3098 ir_variable
*x
= in_var(param0_type
, "x");
3099 ir_variable
*y
= in_var(param1_type
, "y");
3100 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3101 body
.emit(ret(expr(opcode
, x
, y
)));
3105 #define BINOP(NAME, OPCODE, AVAIL) \
3106 ir_function_signature * \
3107 builtin_builder::_##NAME(const glsl_type *return_type, \
3108 const glsl_type *param0_type, \
3109 const glsl_type *param1_type) \
3111 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3115 * Angle and Trigonometry Functions @{
3118 ir_function_signature
*
3119 builtin_builder::_radians(const glsl_type
*type
)
3121 ir_variable
*degrees
= in_var(type
, "degrees");
3122 MAKE_SIG(type
, always_available
, 1, degrees
);
3123 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3127 ir_function_signature
*
3128 builtin_builder::_degrees(const glsl_type
*type
)
3130 ir_variable
*radians
= in_var(type
, "radians");
3131 MAKE_SIG(type
, always_available
, 1, radians
);
3132 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3136 UNOP(sin
, ir_unop_sin
, always_available
)
3137 UNOP(cos
, ir_unop_cos
, always_available
)
3139 ir_function_signature
*
3140 builtin_builder::_tan(const glsl_type
*type
)
3142 ir_variable
*theta
= in_var(type
, "theta");
3143 MAKE_SIG(type
, always_available
, 1, theta
);
3144 body
.emit(ret(div(sin(theta
), cos(theta
))));
3149 builtin_builder::asin_expr(ir_variable
*x
)
3153 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3156 add(imm(M_PI_4f
- 1.0f
),
3158 add(imm(0.086566724f
),
3159 mul(abs(x
), imm(-0.03102955f
))))))))));
3163 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3165 exec_list actual_params
;
3167 foreach_in_list(ir_variable
, var
, ¶ms
) {
3168 actual_params
.push_tail(var_ref(var
));
3171 ir_function_signature
*sig
=
3172 f
->exact_matching_signature(NULL
, &actual_params
);
3176 ir_dereference_variable
*deref
=
3177 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3179 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3182 ir_function_signature
*
3183 builtin_builder::_asin(const glsl_type
*type
)
3185 ir_variable
*x
= in_var(type
, "x");
3186 MAKE_SIG(type
, always_available
, 1, x
);
3188 body
.emit(ret(asin_expr(x
)));
3193 ir_function_signature
*
3194 builtin_builder::_acos(const glsl_type
*type
)
3196 ir_variable
*x
= in_var(type
, "x");
3197 MAKE_SIG(type
, always_available
, 1, x
);
3199 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
3204 ir_function_signature
*
3205 builtin_builder::_atan2(const glsl_type
*type
)
3207 ir_variable
*vec_y
= in_var(type
, "vec_y");
3208 ir_variable
*vec_x
= in_var(type
, "vec_x");
3209 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3211 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3212 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3213 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3214 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3215 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3216 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3217 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3219 /* If |x| >= 1.0e-8 * |y|: */
3221 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3223 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3225 /* Then...call atan(y/x) */
3226 do_atan(body
, glsl_type::float_type
, r
, div(y
, x
));
3228 /* ...and fix it up: */
3229 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3230 inner_if
->then_instructions
.push_tail(
3231 if_tree(gequal(y
, imm(0.0f
)),
3232 assign(r
, add(r
, imm(M_PIf
))),
3233 assign(r
, sub(r
, imm(M_PIf
)))));
3234 outer_then
.emit(inner_if
);
3237 outer_if
->else_instructions
.push_tail(
3238 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3240 body
.emit(outer_if
);
3242 body
.emit(assign(vec_result
, r
, 1 << i
));
3244 body
.emit(ret(vec_result
));
3250 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3253 * range-reduction, first step:
3255 * / y_over_x if |y_over_x| <= 1.0;
3257 * \ 1.0 / y_over_x otherwise
3259 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3260 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3266 * approximate atan by evaluating polynomial:
3268 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3269 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3270 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3272 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3273 body
.emit(assign(tmp
, mul(x
, x
)));
3274 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3276 imm(0.0536813784310406f
)),
3278 imm(0.1173503194786851f
)),
3280 imm(0.1938924977115610f
)),
3282 imm(0.3326756418091246f
)),
3284 imm(0.9999793128310355f
)),
3287 /* range-reduction fixup */
3288 body
.emit(assign(tmp
, add(tmp
,
3289 mul(b2f(greater(abs(y_over_x
),
3290 imm(1.0f
, type
->components()))),
3296 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3299 ir_function_signature
*
3300 builtin_builder::_atan(const glsl_type
*type
)
3302 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3303 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3305 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3306 do_atan(body
, type
, tmp
, y_over_x
);
3307 body
.emit(ret(tmp
));
3312 ir_function_signature
*
3313 builtin_builder::_sinh(const glsl_type
*type
)
3315 ir_variable
*x
= in_var(type
, "x");
3316 MAKE_SIG(type
, v130
, 1, x
);
3318 /* 0.5 * (e^x - e^(-x)) */
3319 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3324 ir_function_signature
*
3325 builtin_builder::_cosh(const glsl_type
*type
)
3327 ir_variable
*x
= in_var(type
, "x");
3328 MAKE_SIG(type
, v130
, 1, x
);
3330 /* 0.5 * (e^x + e^(-x)) */
3331 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3336 ir_function_signature
*
3337 builtin_builder::_tanh(const glsl_type
*type
)
3339 ir_variable
*x
= in_var(type
, "x");
3340 MAKE_SIG(type
, v130
, 1, x
);
3342 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3343 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3344 add(exp(x
), exp(neg(x
))))));
3349 ir_function_signature
*
3350 builtin_builder::_asinh(const glsl_type
*type
)
3352 ir_variable
*x
= in_var(type
, "x");
3353 MAKE_SIG(type
, v130
, 1, x
);
3355 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3360 ir_function_signature
*
3361 builtin_builder::_acosh(const glsl_type
*type
)
3363 ir_variable
*x
= in_var(type
, "x");
3364 MAKE_SIG(type
, v130
, 1, x
);
3366 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3370 ir_function_signature
*
3371 builtin_builder::_atanh(const glsl_type
*type
)
3373 ir_variable
*x
= in_var(type
, "x");
3374 MAKE_SIG(type
, v130
, 1, x
);
3376 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3377 sub(imm(1.0f
), x
))))));
3383 * Exponential Functions @{
3386 ir_function_signature
*
3387 builtin_builder::_pow(const glsl_type
*type
)
3389 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
3392 UNOP(exp
, ir_unop_exp
, always_available
)
3393 UNOP(log
, ir_unop_log
, always_available
)
3394 UNOP(exp2
, ir_unop_exp2
, always_available
)
3395 UNOP(log2
, ir_unop_log2
, always_available
)
3396 UNOPA(sqrt
, ir_unop_sqrt
)
3397 UNOPA(inversesqrt
, ir_unop_rsq
)
3401 UNOPA(abs
, ir_unop_abs
)
3402 UNOPA(sign
, ir_unop_sign
)
3403 UNOPA(floor
, ir_unop_floor
)
3404 UNOPA(trunc
, ir_unop_trunc
)
3405 UNOPA(round
, ir_unop_round_even
)
3406 UNOPA(roundEven
, ir_unop_round_even
)
3407 UNOPA(ceil
, ir_unop_ceil
)
3408 UNOPA(fract
, ir_unop_fract
)
3410 ir_function_signature
*
3411 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
3413 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
3416 ir_function_signature
*
3417 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3419 ir_variable
*x
= in_var(type
, "x");
3420 ir_variable
*i
= out_var(type
, "i");
3421 MAKE_SIG(type
, avail
, 2, x
, i
);
3423 ir_variable
*t
= body
.make_temp(type
, "t");
3424 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3425 body
.emit(assign(i
, t
));
3426 body
.emit(ret(sub(x
, t
)));
3431 ir_function_signature
*
3432 builtin_builder::_min(builtin_available_predicate avail
,
3433 const glsl_type
*x_type
, const glsl_type
*y_type
)
3435 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
3438 ir_function_signature
*
3439 builtin_builder::_max(builtin_available_predicate avail
,
3440 const glsl_type
*x_type
, const glsl_type
*y_type
)
3442 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
3445 ir_function_signature
*
3446 builtin_builder::_clamp(builtin_available_predicate avail
,
3447 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3449 ir_variable
*x
= in_var(val_type
, "x");
3450 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3451 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3452 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3454 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3459 ir_function_signature
*
3460 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3462 ir_variable
*x
= in_var(val_type
, "x");
3463 ir_variable
*y
= in_var(val_type
, "y");
3464 ir_variable
*a
= in_var(blend_type
, "a");
3465 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3467 body
.emit(ret(lrp(x
, y
, a
)));
3472 ir_function_signature
*
3473 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3474 const glsl_type
*val_type
,
3475 const glsl_type
*blend_type
)
3477 ir_variable
*x
= in_var(val_type
, "x");
3478 ir_variable
*y
= in_var(val_type
, "y");
3479 ir_variable
*a
= in_var(blend_type
, "a");
3480 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3482 /* csel matches the ternary operator in that a selector of true choses the
3483 * first argument. This differs from mix(x, y, false) which choses the
3484 * second argument (to remain consistent with the interpolating version of
3485 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3487 * To handle the behavior mismatch, reverse the x and y arguments.
3489 body
.emit(ret(csel(a
, y
, x
)));
3494 ir_function_signature
*
3495 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3497 ir_variable
*edge
= in_var(edge_type
, "edge");
3498 ir_variable
*x
= in_var(x_type
, "x");
3499 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3501 ir_variable
*t
= body
.make_temp(x_type
, "t");
3502 if (x_type
->vector_elements
== 1) {
3503 /* Both are floats */
3504 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3505 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3507 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3508 } else if (edge_type
->vector_elements
== 1) {
3509 /* x is a vector but edge is a float */
3510 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3511 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3512 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3514 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3517 /* Both are vectors */
3518 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3519 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3520 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3523 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3533 ir_function_signature
*
3534 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3536 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3537 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3538 ir_variable
*x
= in_var(x_type
, "x");
3539 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3541 /* From the GLSL 1.10 specification:
3544 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3545 * return t * t * (3 - 2 * t);
3548 ir_variable
*t
= body
.make_temp(x_type
, "t");
3549 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3550 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3552 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3557 ir_function_signature
*
3558 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3560 ir_variable
*x
= in_var(type
, "x");
3561 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3563 body
.emit(ret(nequal(x
, x
)));
3568 ir_function_signature
*
3569 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3571 ir_variable
*x
= in_var(type
, "x");
3572 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3574 ir_constant_data infinities
;
3575 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3576 switch (type
->base_type
) {
3577 case GLSL_TYPE_FLOAT
:
3578 infinities
.f
[i
] = INFINITY
;
3580 case GLSL_TYPE_DOUBLE
:
3581 infinities
.d
[i
] = INFINITY
;
3584 unreachable("unknown type");
3588 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3593 ir_function_signature
*
3594 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3596 ir_variable
*x
= in_var(type
, "x");
3597 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3598 body
.emit(ret(bitcast_f2i(x
)));
3602 ir_function_signature
*
3603 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3605 ir_variable
*x
= in_var(type
, "x");
3606 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3607 body
.emit(ret(bitcast_f2u(x
)));
3611 ir_function_signature
*
3612 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3614 ir_variable
*x
= in_var(type
, "x");
3615 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3616 body
.emit(ret(bitcast_i2f(x
)));
3620 ir_function_signature
*
3621 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3623 ir_variable
*x
= in_var(type
, "x");
3624 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3625 body
.emit(ret(bitcast_u2f(x
)));
3629 ir_function_signature
*
3630 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3632 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3633 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3634 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3638 ir_function_signature
*
3639 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3641 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3642 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3643 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3647 ir_function_signature
*
3648 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3650 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3651 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3652 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3656 ir_function_signature
*
3657 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3659 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3660 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3661 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3665 ir_function_signature
*
3666 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3668 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3669 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3670 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3674 ir_function_signature
*
3675 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3677 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3678 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3679 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3684 ir_function_signature
*
3685 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3687 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3688 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3689 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3693 ir_function_signature
*
3694 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3696 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3697 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3698 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3702 ir_function_signature
*
3703 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3705 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3706 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3707 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3711 ir_function_signature
*
3712 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3714 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3715 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3716 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3720 ir_function_signature
*
3721 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3723 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3724 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3725 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3729 ir_function_signature
*
3730 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3732 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3733 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3734 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3738 ir_function_signature
*
3739 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3741 ir_variable
*x
= in_var(type
, "x");
3742 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3744 body
.emit(ret(sqrt(dot(x
, x
))));
3749 ir_function_signature
*
3750 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3752 ir_variable
*p0
= in_var(type
, "p0");
3753 ir_variable
*p1
= in_var(type
, "p1");
3754 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3756 if (type
->vector_elements
== 1) {
3757 body
.emit(ret(abs(sub(p0
, p1
))));
3759 ir_variable
*p
= body
.make_temp(type
, "p");
3760 body
.emit(assign(p
, sub(p0
, p1
)));
3761 body
.emit(ret(sqrt(dot(p
, p
))));
3767 ir_function_signature
*
3768 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3770 if (type
->vector_elements
== 1)
3771 return binop(ir_binop_mul
, avail
, type
, type
, type
);
3773 return binop(ir_binop_dot
, avail
,
3774 type
->get_base_type(), type
, type
);
3777 ir_function_signature
*
3778 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3780 ir_variable
*a
= in_var(type
, "a");
3781 ir_variable
*b
= in_var(type
, "b");
3782 MAKE_SIG(type
, avail
, 2, a
, b
);
3784 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3785 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3787 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3788 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3793 ir_function_signature
*
3794 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3796 ir_variable
*x
= in_var(type
, "x");
3797 MAKE_SIG(type
, avail
, 1, x
);
3799 if (type
->vector_elements
== 1) {
3800 body
.emit(ret(sign(x
)));
3802 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3808 ir_function_signature
*
3809 builtin_builder::_ftransform()
3811 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3813 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3814 glsl_type::vec4_type
,
3815 var_ref(gl_ModelViewProjectionMatrix
),
3816 var_ref(gl_Vertex
))));
3818 /* FINISHME: Once the ir_expression() constructor handles type inference
3819 * for matrix operations, we can simplify this to:
3821 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3826 ir_function_signature
*
3827 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3829 ir_variable
*N
= in_var(type
, "N");
3830 ir_variable
*I
= in_var(type
, "I");
3831 ir_variable
*Nref
= in_var(type
, "Nref");
3832 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3834 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3835 ret(N
), ret(neg(N
))));
3840 ir_function_signature
*
3841 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3843 ir_variable
*I
= in_var(type
, "I");
3844 ir_variable
*N
= in_var(type
, "N");
3845 MAKE_SIG(type
, avail
, 2, I
, N
);
3847 /* I - 2 * dot(N, I) * N */
3848 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3853 ir_function_signature
*
3854 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3856 ir_variable
*I
= in_var(type
, "I");
3857 ir_variable
*N
= in_var(type
, "N");
3858 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3859 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3861 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3862 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3864 /* From the GLSL 1.10 specification:
3865 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3867 * return genType(0.0)
3869 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3871 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3872 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3873 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3874 mul(n_dot_i
, n_dot_i
)))))));
3875 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3876 ret(ir_constant::zero(mem_ctx
, type
)),
3877 ret(sub(mul(eta
, I
),
3878 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3883 ir_function_signature
*
3884 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3886 ir_variable
*x
= in_var(type
, "x");
3887 ir_variable
*y
= in_var(type
, "y");
3888 MAKE_SIG(type
, avail
, 2, x
, y
);
3890 ir_variable
*z
= body
.make_temp(type
, "z");
3891 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3892 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3899 ir_function_signature
*
3900 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3905 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3906 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3907 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3909 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3910 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3912 MAKE_SIG(type
, avail
, 2, c
, r
);
3914 ir_variable
*m
= body
.make_temp(type
, "m");
3915 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3916 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3923 ir_function_signature
*
3924 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3926 const glsl_type
*transpose_type
=
3927 glsl_type::get_instance(orig_type
->base_type
,
3928 orig_type
->matrix_columns
,
3929 orig_type
->vector_elements
);
3931 ir_variable
*m
= in_var(orig_type
, "m");
3932 MAKE_SIG(transpose_type
, avail
, 1, m
);
3934 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3935 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3936 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3937 body
.emit(assign(array_ref(t
, j
),
3938 matrix_elt(m
, i
, j
),
3947 ir_function_signature
*
3948 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3950 ir_variable
*m
= in_var(type
, "m");
3951 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3953 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3954 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3959 ir_function_signature
*
3960 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3962 ir_variable
*m
= in_var(type
, "m");
3963 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3966 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3967 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3970 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3971 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3974 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3975 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3977 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3978 mul(matrix_elt(m
, 0, 1), f2
)),
3979 mul(matrix_elt(m
, 0, 2), f3
))));
3984 ir_function_signature
*
3985 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3987 ir_variable
*m
= in_var(type
, "m");
3988 const glsl_type
*btype
= type
->get_base_type();
3989 MAKE_SIG(btype
, avail
, 1, m
);
3991 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3992 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3993 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3994 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3995 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3996 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3997 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3998 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3999 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4000 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4001 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4002 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4003 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4004 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4005 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4006 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4007 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4008 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4009 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4011 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)))));
4012 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)))));
4013 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)))));
4014 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)))));
4015 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)))));
4016 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)))));
4017 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)))));
4018 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)))));
4019 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)))));
4020 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)))));
4021 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)))));
4022 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)))));
4023 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)))));
4024 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)))));
4025 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)))));
4026 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)))));
4027 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)))));
4028 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)))));
4029 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)))));
4031 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4033 body
.emit(assign(adj_0
,
4034 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4035 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4036 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4038 body
.emit(assign(adj_0
, neg(
4039 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4040 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4041 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4043 body
.emit(assign(adj_0
,
4044 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4045 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4046 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4048 body
.emit(assign(adj_0
, neg(
4049 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4050 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4051 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4054 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4059 ir_function_signature
*
4060 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4062 ir_variable
*m
= in_var(type
, "m");
4063 MAKE_SIG(type
, avail
, 1, m
);
4065 ir_variable
*adj
= body
.make_temp(type
, "adj");
4066 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4067 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4068 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4069 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4071 ir_expression
*det
=
4072 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4073 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4075 body
.emit(ret(div(adj
, det
)));
4079 ir_function_signature
*
4080 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4082 ir_variable
*m
= in_var(type
, "m");
4083 const glsl_type
*btype
= type
->get_base_type();
4084 MAKE_SIG(type
, avail
, 1, m
);
4086 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4087 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4088 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4090 body
.emit(assign(f11_22_21_12
,
4091 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4092 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4093 body
.emit(assign(f10_22_20_12
,
4094 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4095 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4096 body
.emit(assign(f10_21_20_11
,
4097 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4098 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4100 ir_variable
*adj
= body
.make_temp(type
, "adj");
4101 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4102 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4103 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4105 body
.emit(assign(array_ref(adj
, 0), neg(
4106 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4107 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4109 body
.emit(assign(array_ref(adj
, 1),
4110 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4111 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4113 body
.emit(assign(array_ref(adj
, 2), neg(
4114 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4115 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4118 body
.emit(assign(array_ref(adj
, 0),
4119 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4120 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4122 body
.emit(assign(array_ref(adj
, 1), neg(
4123 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4124 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4126 body
.emit(assign(array_ref(adj
, 2),
4127 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4128 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4131 ir_expression
*det
=
4132 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4133 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4134 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4136 body
.emit(ret(div(adj
, det
)));
4141 ir_function_signature
*
4142 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4144 ir_variable
*m
= in_var(type
, "m");
4145 const glsl_type
*btype
= type
->get_base_type();
4146 MAKE_SIG(type
, avail
, 1, m
);
4148 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4149 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4150 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4151 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4152 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4153 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4154 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4155 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4156 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4157 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4158 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4159 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4160 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4161 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4162 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4163 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4164 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4165 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4166 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4168 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)))));
4169 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)))));
4170 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)))));
4171 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)))));
4172 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)))));
4173 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)))));
4174 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)))));
4175 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)))));
4176 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)))));
4177 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)))));
4178 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)))));
4179 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)))));
4180 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)))));
4181 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)))));
4182 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)))));
4183 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)))));
4184 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)))));
4185 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)))));
4186 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)))));
4188 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4189 body
.emit(assign(array_ref(adj
, 0),
4190 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4191 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4192 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4194 body
.emit(assign(array_ref(adj
, 1), neg(
4195 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4196 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4197 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4199 body
.emit(assign(array_ref(adj
, 2),
4200 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4201 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4202 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4204 body
.emit(assign(array_ref(adj
, 3), neg(
4205 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4206 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4207 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4210 body
.emit(assign(array_ref(adj
, 0), neg(
4211 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4212 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4213 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4215 body
.emit(assign(array_ref(adj
, 1),
4216 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4217 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4218 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4220 body
.emit(assign(array_ref(adj
, 2), neg(
4221 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4222 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4223 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4225 body
.emit(assign(array_ref(adj
, 3),
4226 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4227 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4228 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4231 body
.emit(assign(array_ref(adj
, 0),
4232 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4233 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4234 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4236 body
.emit(assign(array_ref(adj
, 1), neg(
4237 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4238 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4239 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4241 body
.emit(assign(array_ref(adj
, 2),
4242 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4243 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4244 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4246 body
.emit(assign(array_ref(adj
, 3), neg(
4247 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4248 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4249 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4252 body
.emit(assign(array_ref(adj
, 0), neg(
4253 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4254 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4255 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4257 body
.emit(assign(array_ref(adj
, 1),
4258 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4259 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4260 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4262 body
.emit(assign(array_ref(adj
, 2), neg(
4263 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4264 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4265 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4267 body
.emit(assign(array_ref(adj
, 3),
4268 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4269 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4270 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4273 ir_expression
*det
=
4274 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4275 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4276 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4277 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4279 body
.emit(ret(div(adj
, det
)));
4285 ir_function_signature
*
4286 builtin_builder::_lessThan(builtin_available_predicate avail
,
4287 const glsl_type
*type
)
4289 return binop(ir_binop_less
, avail
,
4290 glsl_type::bvec(type
->vector_elements
), type
, type
);
4293 ir_function_signature
*
4294 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4295 const glsl_type
*type
)
4297 return binop(ir_binop_lequal
, avail
,
4298 glsl_type::bvec(type
->vector_elements
), type
, type
);
4301 ir_function_signature
*
4302 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4303 const glsl_type
*type
)
4305 return binop(ir_binop_greater
, avail
,
4306 glsl_type::bvec(type
->vector_elements
), type
, type
);
4309 ir_function_signature
*
4310 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4311 const glsl_type
*type
)
4313 return binop(ir_binop_gequal
, avail
,
4314 glsl_type::bvec(type
->vector_elements
), type
, type
);
4317 ir_function_signature
*
4318 builtin_builder::_equal(builtin_available_predicate avail
,
4319 const glsl_type
*type
)
4321 return binop(ir_binop_equal
, avail
,
4322 glsl_type::bvec(type
->vector_elements
), type
, type
);
4325 ir_function_signature
*
4326 builtin_builder::_notEqual(builtin_available_predicate avail
,
4327 const glsl_type
*type
)
4329 return binop(ir_binop_nequal
, avail
,
4330 glsl_type::bvec(type
->vector_elements
), type
, type
);
4333 ir_function_signature
*
4334 builtin_builder::_any(const glsl_type
*type
)
4336 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
4339 ir_function_signature
*
4340 builtin_builder::_all(const glsl_type
*type
)
4342 ir_variable
*v
= in_var(type
, "v");
4343 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4345 switch (type
->vector_elements
) {
4347 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
4350 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4354 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4363 UNOP(not, ir_unop_logic_not
, always_available
)
4366 has_lod(const glsl_type
*sampler_type
)
4368 assert(sampler_type
->is_sampler());
4370 switch (sampler_type
->sampler_dimensionality
) {
4371 case GLSL_SAMPLER_DIM_RECT
:
4372 case GLSL_SAMPLER_DIM_BUF
:
4373 case GLSL_SAMPLER_DIM_MS
:
4380 ir_function_signature
*
4381 builtin_builder::_textureSize(builtin_available_predicate avail
,
4382 const glsl_type
*return_type
,
4383 const glsl_type
*sampler_type
)
4385 ir_variable
*s
= in_var(sampler_type
, "sampler");
4386 /* The sampler always exists; add optional lod later. */
4387 MAKE_SIG(return_type
, avail
, 1, s
);
4389 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4390 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4392 if (has_lod(sampler_type
)) {
4393 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4394 sig
->parameters
.push_tail(lod
);
4395 tex
->lod_info
.lod
= var_ref(lod
);
4397 tex
->lod_info
.lod
= imm(0u);
4400 body
.emit(ret(tex
));
4405 ir_function_signature
*
4406 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4408 ir_variable
*s
= in_var(sampler_type
, "sampler");
4409 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4411 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4412 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4413 body
.emit(ret(tex
));
4418 ir_function_signature
*
4419 builtin_builder::_texture(ir_texture_opcode opcode
,
4420 builtin_available_predicate avail
,
4421 const glsl_type
*return_type
,
4422 const glsl_type
*sampler_type
,
4423 const glsl_type
*coord_type
,
4426 ir_variable
*s
= in_var(sampler_type
, "sampler");
4427 ir_variable
*P
= in_var(coord_type
, "P");
4428 /* The sampler and coordinate always exist; add optional parameters later. */
4429 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4431 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4432 tex
->set_sampler(var_ref(s
), return_type
);
4434 const int coord_size
= sampler_type
->coordinate_components();
4436 if (coord_size
== coord_type
->vector_elements
) {
4437 tex
->coordinate
= var_ref(P
);
4439 /* The incoming coordinate also has the projector or shadow comparitor,
4440 * so we need to swizzle those away.
4442 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4445 /* The projector is always in the last component. */
4446 if (flags
& TEX_PROJECT
)
4447 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4449 if (sampler_type
->sampler_shadow
) {
4450 if (opcode
== ir_tg4
) {
4451 /* gather has refz as a separate parameter, immediately after the
4454 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4455 sig
->parameters
.push_tail(refz
);
4456 tex
->shadow_comparitor
= var_ref(refz
);
4458 /* The shadow comparitor is normally in the Z component, but a few types
4459 * have sufficiently large coordinates that it's in W.
4461 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4465 if (opcode
== ir_txl
) {
4466 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4467 sig
->parameters
.push_tail(lod
);
4468 tex
->lod_info
.lod
= var_ref(lod
);
4469 } else if (opcode
== ir_txd
) {
4470 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4471 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4472 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4473 sig
->parameters
.push_tail(dPdx
);
4474 sig
->parameters
.push_tail(dPdy
);
4475 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4476 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4479 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4480 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4481 ir_variable
*offset
=
4482 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4483 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4484 sig
->parameters
.push_tail(offset
);
4485 tex
->offset
= var_ref(offset
);
4488 if (flags
& TEX_OFFSET_ARRAY
) {
4489 ir_variable
*offsets
=
4490 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4491 "offsets", ir_var_const_in
);
4492 sig
->parameters
.push_tail(offsets
);
4493 tex
->offset
= var_ref(offsets
);
4496 if (opcode
== ir_tg4
) {
4497 if (flags
& TEX_COMPONENT
) {
4498 ir_variable
*component
=
4499 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4500 sig
->parameters
.push_tail(component
);
4501 tex
->lod_info
.component
= var_ref(component
);
4504 tex
->lod_info
.component
= imm(0);
4508 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4509 * inconsistent with both textureLodOffset and textureGradOffset.
4511 if (opcode
== ir_txb
) {
4512 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4513 sig
->parameters
.push_tail(bias
);
4514 tex
->lod_info
.bias
= var_ref(bias
);
4517 body
.emit(ret(tex
));
4522 ir_function_signature
*
4523 builtin_builder::_textureCubeArrayShadow()
4525 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4526 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4527 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4528 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4530 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4531 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4533 tex
->coordinate
= var_ref(P
);
4534 tex
->shadow_comparitor
= var_ref(compare
);
4536 body
.emit(ret(tex
));
4541 ir_function_signature
*
4542 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4543 const glsl_type
*return_type
,
4544 const glsl_type
*sampler_type
,
4545 const glsl_type
*coord_type
,
4546 const glsl_type
*offset_type
)
4548 ir_variable
*s
= in_var(sampler_type
, "sampler");
4549 ir_variable
*P
= in_var(coord_type
, "P");
4550 /* The sampler and coordinate always exist; add optional parameters later. */
4551 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4553 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4554 tex
->coordinate
= var_ref(P
);
4555 tex
->set_sampler(var_ref(s
), return_type
);
4557 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4558 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4559 sig
->parameters
.push_tail(sample
);
4560 tex
->lod_info
.sample_index
= var_ref(sample
);
4561 tex
->op
= ir_txf_ms
;
4562 } else if (has_lod(sampler_type
)) {
4563 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4564 sig
->parameters
.push_tail(lod
);
4565 tex
->lod_info
.lod
= var_ref(lod
);
4567 tex
->lod_info
.lod
= imm(0u);
4570 if (offset_type
!= NULL
) {
4571 ir_variable
*offset
=
4572 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4573 sig
->parameters
.push_tail(offset
);
4574 tex
->offset
= var_ref(offset
);
4577 body
.emit(ret(tex
));
4582 ir_function_signature
*
4583 builtin_builder::_EmitVertex()
4585 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4587 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4588 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4593 ir_function_signature
*
4594 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4595 const glsl_type
*stream_type
)
4597 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4599 * "Emit the current values of output variables to the current output
4600 * primitive on stream stream. The argument to stream must be a constant
4601 * integral expression."
4603 ir_variable
*stream
=
4604 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4606 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4608 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4613 ir_function_signature
*
4614 builtin_builder::_EndPrimitive()
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_end_primitive(stream
));
4624 ir_function_signature
*
4625 builtin_builder::_EndStreamPrimitive(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 * "Completes the current output primitive on stream stream and starts
4631 * a new one. The argument to stream must be a constant integral
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_end_primitive(var_ref(stream
)));
4644 ir_function_signature
*
4645 builtin_builder::_barrier()
4647 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4649 body
.emit(new(mem_ctx
) ir_barrier());
4653 ir_function_signature
*
4654 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4655 const glsl_type
*sampler_type
,
4656 const glsl_type
*coord_type
)
4658 ir_variable
*s
= in_var(sampler_type
, "sampler");
4659 ir_variable
*coord
= in_var(coord_type
, "coord");
4660 /* The sampler and coordinate always exist; add optional parameters later. */
4661 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4663 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4664 tex
->coordinate
= var_ref(coord
);
4665 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4667 body
.emit(ret(tex
));
4672 ir_function_signature
*
4673 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4675 ir_variable
*s
= in_var(sampler_type
, "sampler");
4676 const glsl_type
*return_type
= glsl_type::int_type
;
4677 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4679 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4680 tex
->set_sampler(var_ref(s
), return_type
);
4682 body
.emit(ret(tex
));
4687 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4688 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4689 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4690 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4691 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4692 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4694 ir_function_signature
*
4695 builtin_builder::_fwidth(const glsl_type
*type
)
4697 ir_variable
*p
= in_var(type
, "p");
4698 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4700 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4705 ir_function_signature
*
4706 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4708 ir_variable
*p
= in_var(type
, "p");
4709 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4711 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4712 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4717 ir_function_signature
*
4718 builtin_builder::_fwidthFine(const glsl_type
*type
)
4720 ir_variable
*p
= in_var(type
, "p");
4721 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4723 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4724 abs(expr(ir_unop_dFdy_fine
, p
)))));
4729 ir_function_signature
*
4730 builtin_builder::_noise1(const glsl_type
*type
)
4732 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4735 ir_function_signature
*
4736 builtin_builder::_noise2(const glsl_type
*type
)
4738 ir_variable
*p
= in_var(type
, "p");
4739 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4741 ir_constant_data b_offset
;
4742 b_offset
.f
[0] = 601.0f
;
4743 b_offset
.f
[1] = 313.0f
;
4744 b_offset
.f
[2] = 29.0f
;
4745 b_offset
.f
[3] = 277.0f
;
4747 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4748 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4749 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4750 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4751 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4752 body
.emit(assign(t
, a
, WRITEMASK_X
));
4753 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4759 ir_function_signature
*
4760 builtin_builder::_noise3(const glsl_type
*type
)
4762 ir_variable
*p
= in_var(type
, "p");
4763 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4765 ir_constant_data b_offset
;
4766 b_offset
.f
[0] = 601.0f
;
4767 b_offset
.f
[1] = 313.0f
;
4768 b_offset
.f
[2] = 29.0f
;
4769 b_offset
.f
[3] = 277.0f
;
4771 ir_constant_data c_offset
;
4772 c_offset
.f
[0] = 1559.0f
;
4773 c_offset
.f
[1] = 113.0f
;
4774 c_offset
.f
[2] = 1861.0f
;
4775 c_offset
.f
[3] = 797.0f
;
4777 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4778 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4779 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4780 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4781 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4782 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4783 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4784 body
.emit(assign(t
, a
, WRITEMASK_X
));
4785 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4786 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4792 ir_function_signature
*
4793 builtin_builder::_noise4(const glsl_type
*type
)
4795 ir_variable
*p
= in_var(type
, "p");
4796 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4798 ir_variable
*_p
= body
.make_temp(type
, "_p");
4800 ir_constant_data p_offset
;
4801 p_offset
.f
[0] = 1559.0f
;
4802 p_offset
.f
[1] = 113.0f
;
4803 p_offset
.f
[2] = 1861.0f
;
4804 p_offset
.f
[3] = 797.0f
;
4806 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4808 ir_constant_data offset
;
4809 offset
.f
[0] = 601.0f
;
4810 offset
.f
[1] = 313.0f
;
4811 offset
.f
[2] = 29.0f
;
4812 offset
.f
[3] = 277.0f
;
4814 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4815 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4816 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4817 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4818 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4819 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4820 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4821 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4822 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4823 body
.emit(assign(t
, a
, WRITEMASK_X
));
4824 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4825 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4826 body
.emit(assign(t
, d
, WRITEMASK_W
));
4832 ir_function_signature
*
4833 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4835 ir_variable
*value
= in_var(type
, "value");
4836 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4837 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4838 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4840 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4845 ir_function_signature
*
4846 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4848 ir_variable
*base
= in_var(type
, "base");
4849 ir_variable
*insert
= in_var(type
, "insert");
4850 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4851 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4852 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
4854 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4859 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
4861 ir_function_signature
*
4862 builtin_builder::_bitCount(const glsl_type
*type
)
4864 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
4865 glsl_type::ivec(type
->vector_elements
), type
);
4868 ir_function_signature
*
4869 builtin_builder::_findLSB(const glsl_type
*type
)
4871 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
4872 glsl_type::ivec(type
->vector_elements
), type
);
4875 ir_function_signature
*
4876 builtin_builder::_findMSB(const glsl_type
*type
)
4878 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
4879 glsl_type::ivec(type
->vector_elements
), type
);
4882 ir_function_signature
*
4883 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4885 ir_variable
*a
= in_var(type
, "a");
4886 ir_variable
*b
= in_var(type
, "b");
4887 ir_variable
*c
= in_var(type
, "c");
4888 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4890 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4895 ir_function_signature
*
4896 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4898 return binop(ir_binop_ldexp
, x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
, x_type
, x_type
, exp_type
);
4901 ir_function_signature
*
4902 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4904 ir_variable
*x
= in_var(x_type
, "x");
4905 ir_variable
*exponent
= out_var(exp_type
, "exp");
4906 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
4908 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
4910 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
4914 ir_function_signature
*
4915 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4917 ir_variable
*x
= in_var(x_type
, "x");
4918 ir_variable
*exponent
= out_var(exp_type
, "exp");
4919 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
4921 const unsigned vec_elem
= x_type
->vector_elements
;
4922 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4923 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4925 /* Single-precision floating-point values are stored as
4930 * An exponent shift of 23 will shift the mantissa out, leaving only the
4931 * exponent and sign bit (which itself may be zero, if the absolute value
4932 * was taken before the bitcast and shift.
4934 ir_constant
*exponent_shift
= imm(23);
4935 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4937 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4939 /* Exponent of floating-point values in the range [0.5, 1.0). */
4940 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4942 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4943 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4945 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4946 * to unsigned integers to ensure that 1 bits aren't shifted in.
4948 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
4949 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
4950 imm(0, vec_elem
)))));
4952 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
4953 body
.emit(assign(bits
, bitcast_f2u(x
)));
4954 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
4955 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
4956 imm(0u, vec_elem
)))));
4957 body
.emit(ret(bitcast_u2f(bits
)));
4962 ir_function_signature
*
4963 builtin_builder::_uaddCarry(const glsl_type
*type
)
4965 ir_variable
*x
= in_var(type
, "x");
4966 ir_variable
*y
= in_var(type
, "y");
4967 ir_variable
*carry
= out_var(type
, "carry");
4968 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
4970 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
4971 body
.emit(ret(add(x
, y
)));
4976 ir_function_signature
*
4977 builtin_builder::_usubBorrow(const glsl_type
*type
)
4979 ir_variable
*x
= in_var(type
, "x");
4980 ir_variable
*y
= in_var(type
, "y");
4981 ir_variable
*borrow
= out_var(type
, "borrow");
4982 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
4984 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4985 body
.emit(ret(sub(x
, y
)));
4991 * For both imulExtended() and umulExtended() built-ins.
4993 ir_function_signature
*
4994 builtin_builder::_mulExtended(const glsl_type
*type
)
4996 ir_variable
*x
= in_var(type
, "x");
4997 ir_variable
*y
= in_var(type
, "y");
4998 ir_variable
*msb
= out_var(type
, "msb");
4999 ir_variable
*lsb
= out_var(type
, "lsb");
5000 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
5002 body
.emit(assign(msb
, imul_high(x
, y
)));
5003 body
.emit(assign(lsb
, mul(x
, y
)));
5008 ir_function_signature
*
5009 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5011 ir_variable
*interpolant
= in_var(type
, "interpolant");
5012 interpolant
->data
.must_be_shader_input
= 1;
5013 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
5015 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5020 ir_function_signature
*
5021 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5023 ir_variable
*interpolant
= in_var(type
, "interpolant");
5024 interpolant
->data
.must_be_shader_input
= 1;
5025 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5026 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
5028 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5033 ir_function_signature
*
5034 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5036 ir_variable
*interpolant
= in_var(type
, "interpolant");
5037 interpolant
->data
.must_be_shader_input
= 1;
5038 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5039 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
5041 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5046 ir_function_signature
*
5047 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
)
5049 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5050 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
5054 ir_function_signature
*
5055 builtin_builder::_atomic_ssbo_intrinsic2(builtin_available_predicate avail
,
5056 const glsl_type
*type
)
5058 ir_variable
*atomic
= in_var(type
, "atomic");
5059 ir_variable
*data
= in_var(type
, "data");
5060 MAKE_INTRINSIC(type
, avail
, 2, atomic
, data
);
5064 ir_function_signature
*
5065 builtin_builder::_atomic_ssbo_intrinsic3(builtin_available_predicate avail
,
5066 const glsl_type
*type
)
5068 ir_variable
*atomic
= in_var(type
, "atomic");
5069 ir_variable
*data1
= in_var(type
, "data1");
5070 ir_variable
*data2
= in_var(type
, "data2");
5071 MAKE_INTRINSIC(type
, avail
, 3, atomic
, data1
, data2
);
5075 ir_function_signature
*
5076 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5077 builtin_available_predicate avail
)
5079 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5080 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5082 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5083 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5085 body
.emit(ret(retval
));
5089 ir_function_signature
*
5090 builtin_builder::_atomic_ssbo_op2(const char *intrinsic
,
5091 builtin_available_predicate avail
,
5092 const glsl_type
*type
)
5094 ir_variable
*atomic
= in_var(type
, "atomic_var");
5095 ir_variable
*data
= in_var(type
, "atomic_data");
5096 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5098 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5099 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5101 body
.emit(ret(retval
));
5105 ir_function_signature
*
5106 builtin_builder::_atomic_ssbo_op3(const char *intrinsic
,
5107 builtin_available_predicate avail
,
5108 const glsl_type
*type
)
5110 ir_variable
*atomic
= in_var(type
, "atomic_var");
5111 ir_variable
*data1
= in_var(type
, "atomic_data1");
5112 ir_variable
*data2
= in_var(type
, "atomic_data2");
5113 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5115 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5116 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5118 body
.emit(ret(retval
));
5122 ir_function_signature
*
5123 builtin_builder::_min3(const glsl_type
*type
)
5125 ir_variable
*x
= in_var(type
, "x");
5126 ir_variable
*y
= in_var(type
, "y");
5127 ir_variable
*z
= in_var(type
, "z");
5128 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5130 ir_expression
*min3
= min2(x
, min2(y
,z
));
5131 body
.emit(ret(min3
));
5136 ir_function_signature
*
5137 builtin_builder::_max3(const glsl_type
*type
)
5139 ir_variable
*x
= in_var(type
, "x");
5140 ir_variable
*y
= in_var(type
, "y");
5141 ir_variable
*z
= in_var(type
, "z");
5142 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5144 ir_expression
*max3
= max2(x
, max2(y
,z
));
5145 body
.emit(ret(max3
));
5150 ir_function_signature
*
5151 builtin_builder::_mid3(const glsl_type
*type
)
5153 ir_variable
*x
= in_var(type
, "x");
5154 ir_variable
*y
= in_var(type
, "y");
5155 ir_variable
*z
= in_var(type
, "z");
5156 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5158 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5159 body
.emit(ret(mid3
));
5164 ir_function_signature
*
5165 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5166 unsigned num_arguments
,
5169 const glsl_type
*data_type
= glsl_type::get_instance(
5170 image_type
->sampler_type
,
5171 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5173 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5174 glsl_type::void_type
: data_type
);
5176 /* Addressing arguments that are always present. */
5177 ir_variable
*image
= in_var(image_type
, "image");
5178 ir_variable
*coord
= in_var(
5179 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5181 const builtin_available_predicate avail
=
5182 (flags
& IMAGE_FUNCTION_AVAIL_ATOMIC
? shader_image_atomic
:
5183 shader_image_load_store
);
5184 ir_function_signature
*sig
= new_sig(ret_type
, avail
, 2, image
, coord
);
5186 /* Sample index for multisample images. */
5187 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5188 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5190 /* Data arguments. */
5191 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5192 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5193 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5194 ralloc_free(arg_name
);
5197 /* Set the maximal set of qualifiers allowed for this image
5198 * built-in. Function calls with arguments having fewer
5199 * qualifiers than present in the prototype are allowed by the
5200 * spec, but not with more, i.e. this will make the compiler
5201 * accept everything that needs to be accepted, and reject cases
5202 * like loads from write-only or stores to read-only images.
5204 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5205 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5206 image
->data
.image_coherent
= true;
5207 image
->data
.image_volatile
= true;
5208 image
->data
.image_restrict
= true;
5213 ir_function_signature
*
5214 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5215 unsigned /* num_arguments */,
5216 unsigned /* flags */)
5218 const glsl_type
*ret_type
;
5219 unsigned num_components
= image_type
->coordinate_components();
5221 /* From the ARB_shader_image_size extension:
5222 * "Cube images return the dimensions of one face."
5224 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5225 !image_type
->sampler_array
) {
5229 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5230 * supported by mesa.
5232 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5234 ir_variable
*image
= in_var(image_type
, "image");
5235 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5237 /* Set the maximal set of qualifiers allowed for this image
5238 * built-in. Function calls with arguments having fewer
5239 * qualifiers than present in the prototype are allowed by the
5240 * spec, but not with more, i.e. this will make the compiler
5241 * accept everything that needs to be accepted, and reject cases
5242 * like loads from write-only or stores to read-only images.
5244 image
->data
.image_read_only
= true;
5245 image
->data
.image_write_only
= true;
5246 image
->data
.image_coherent
= true;
5247 image
->data
.image_volatile
= true;
5248 image
->data
.image_restrict
= true;
5253 ir_function_signature
*
5254 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5255 unsigned /* num_arguments */,
5256 unsigned /* flags */)
5258 ir_variable
*image
= in_var(image_type
, "image");
5259 ir_function_signature
*sig
=
5260 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5262 /* Set the maximal set of qualifiers allowed for this image
5263 * built-in. Function calls with arguments having fewer
5264 * qualifiers than present in the prototype are allowed by the
5265 * spec, but not with more, i.e. this will make the compiler
5266 * accept everything that needs to be accepted, and reject cases
5267 * like loads from write-only or stores to read-only images.
5269 image
->data
.image_read_only
= true;
5270 image
->data
.image_write_only
= true;
5271 image
->data
.image_coherent
= true;
5272 image
->data
.image_volatile
= true;
5273 image
->data
.image_restrict
= true;
5278 ir_function_signature
*
5279 builtin_builder::_image(image_prototype_ctr prototype
,
5280 const glsl_type
*image_type
,
5281 const char *intrinsic_name
,
5282 unsigned num_arguments
,
5285 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5286 num_arguments
, flags
);
5288 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5289 ir_factory
body(&sig
->body
, mem_ctx
);
5290 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5292 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5293 body
.emit(call(f
, NULL
, sig
->parameters
));
5295 ir_variable
*ret_val
=
5296 body
.make_temp(sig
->return_type
, "_ret_val");
5297 body
.emit(call(f
, ret_val
, sig
->parameters
));
5298 body
.emit(ret(ret_val
));
5301 sig
->is_defined
= true;
5304 sig
->is_intrinsic
= true;
5310 ir_function_signature
*
5311 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5313 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5317 ir_function_signature
*
5318 builtin_builder::_memory_barrier(const char *intrinsic_name
,
5319 builtin_available_predicate avail
)
5321 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5322 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
5323 NULL
, sig
->parameters
));
5327 ir_function_signature
*
5328 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
5329 const glsl_type
*type
)
5331 MAKE_INTRINSIC(type
, avail
, 0);
5335 ir_function_signature
*
5336 builtin_builder::_shader_clock(builtin_available_predicate avail
,
5337 const glsl_type
*type
)
5339 MAKE_SIG(type
, avail
, 0);
5341 ir_variable
*retval
= body
.make_temp(type
, "clock_retval");
5343 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
5344 retval
, sig
->parameters
));
5345 body
.emit(ret(retval
));
5351 /******************************************************************************/
5353 /* The singleton instance of builtin_builder. */
5354 static builtin_builder builtins
;
5355 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5358 * External API (exposing the built-in module to the rest of the compiler):
5362 _mesa_glsl_initialize_builtin_functions()
5364 mtx_lock(&builtins_lock
);
5365 builtins
.initialize();
5366 mtx_unlock(&builtins_lock
);
5370 _mesa_glsl_release_builtin_functions()
5372 mtx_lock(&builtins_lock
);
5374 mtx_unlock(&builtins_lock
);
5377 ir_function_signature
*
5378 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5379 const char *name
, exec_list
*actual_parameters
)
5381 ir_function_signature
* s
;
5382 mtx_lock(&builtins_lock
);
5383 s
= builtins
.find(state
, name
, actual_parameters
);
5384 mtx_unlock(&builtins_lock
);
5389 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5392 mtx_lock(&builtins_lock
);
5393 f
= builtins
.shader
->symbols
->get_function(name
);
5394 mtx_unlock(&builtins_lock
);
5399 _mesa_glsl_get_builtin_function_shader()
5401 return builtins
.shader
;
5406 * Get the function signature for main from a shader
5408 ir_function_signature
*
5409 _mesa_get_main_function_signature(gl_shader
*sh
)
5411 ir_function
*const f
= sh
->symbols
->get_function("main");
5413 exec_list void_parameters
;
5415 /* Look for the 'void main()' signature and ensure that it's defined.
5416 * This keeps the linker from accidentally pick a shader that just
5417 * contains a prototype for main.
5419 * We don't have to check for multiple definitions of main (in multiple
5420 * shaders) because that would have already been caught above.
5422 ir_function_signature
*sig
=
5423 f
->matching_signature(NULL
, &void_parameters
, false);
5424 if ((sig
!= NULL
) && sig
->is_defined
) {