2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * \file builtin_functions.cpp
27 * Support for GLSL built-in functions.
29 * This file is split into several main components:
31 * 1. Availability predicates
33 * A series of small functions that check whether the current shader
34 * supports the version/extensions required to expose a built-in.
36 * 2. Core builtin_builder class functionality
38 * 3. Lists of built-in functions
40 * The builtin_builder::create_builtins() function contains lists of all
41 * built-in function signatures, where they're available, what types they
44 * 4. Implementations of built-in function signatures
46 * A series of functions which create ir_function_signatures and emit IR
47 * via ir_builder to implement them.
51 * A few functions the rest of the compiler can use to interact with the
52 * built-in function module. For example, searching for a built-in by
53 * name and parameters.
58 #include "main/core.h" /* for struct gl_shader */
59 #include "main/shaderobj.h"
60 #include "ir_builder.h"
61 #include "glsl_parser_extras.h"
62 #include "program/prog_instruction.h"
65 #define M_PIf ((float) M_PI)
66 #define M_PI_2f ((float) M_PI_2)
67 #define M_PI_4f ((float) M_PI_4)
69 using namespace ir_builder
;
72 * Availability predicates:
76 always_available(const _mesa_glsl_parse_state
*)
82 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
84 return state
->stage
== MESA_SHADER_VERTEX
&&
85 state
->language_version
<= 130 &&
90 fs_only(const _mesa_glsl_parse_state
*state
)
92 return state
->stage
== MESA_SHADER_FRAGMENT
;
96 gs_only(const _mesa_glsl_parse_state
*state
)
98 return state
->stage
== MESA_SHADER_GEOMETRY
;
102 v110(const _mesa_glsl_parse_state
*state
)
104 return !state
->es_shader
;
108 v110_fs_only(const _mesa_glsl_parse_state
*state
)
110 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
114 v120(const _mesa_glsl_parse_state
*state
)
116 return state
->is_version(120, 300);
120 v130(const _mesa_glsl_parse_state
*state
)
122 return state
->is_version(130, 300);
126 v130_fs_only(const _mesa_glsl_parse_state
*state
)
128 return state
->is_version(130, 300) &&
129 state
->stage
== MESA_SHADER_FRAGMENT
;
133 v140(const _mesa_glsl_parse_state
*state
)
135 return state
->is_version(140, 0);
139 v400_fs_only(const _mesa_glsl_parse_state
*state
)
141 return state
->is_version(400, 0) &&
142 state
->stage
== MESA_SHADER_FRAGMENT
;
146 es31(const _mesa_glsl_parse_state
*state
)
148 return state
->is_version(0, 310);
152 texture_rectangle(const _mesa_glsl_parse_state
*state
)
154 return state
->ARB_texture_rectangle_enable
;
158 texture_external(const _mesa_glsl_parse_state
*state
)
160 return state
->OES_EGL_image_external_enable
;
163 /** True if texturing functions with explicit LOD are allowed. */
165 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
167 /* Texturing functions with "Lod" in their name exist:
168 * - In the vertex shader stage (for all languages)
169 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
170 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
172 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
173 * don't need to explicitly check state->es_shader.
175 return state
->stage
== MESA_SHADER_VERTEX
||
176 state
->is_version(130, 300) ||
177 state
->ARB_shader_texture_lod_enable
;
181 v110_lod(const _mesa_glsl_parse_state
*state
)
183 return !state
->es_shader
&& lod_exists_in_stage(state
);
187 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
189 return state
->ARB_shader_texture_lod_enable
;
193 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
195 return state
->ARB_shader_texture_lod_enable
&&
196 state
->ARB_texture_rectangle_enable
;
200 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
202 return state
->is_version(330, 300) ||
203 state
->ARB_shader_bit_encoding_enable
||
204 state
->ARB_gpu_shader5_enable
;
208 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
210 return state
->is_version(450, 310) ||
211 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
215 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
217 return state
->ARB_shading_language_packing_enable
||
218 state
->is_version(420, 300);
222 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
224 return state
->ARB_shading_language_packing_enable
||
225 state
->ARB_gpu_shader5_enable
||
226 state
->is_version(400, 300);
230 gpu_shader5(const _mesa_glsl_parse_state
*state
)
232 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
236 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
238 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
242 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
244 return state
->ARB_shading_language_packing_enable
||
245 state
->ARB_gpu_shader5_enable
||
246 state
->is_version(400, 310);
250 fs_gpu_shader5(const _mesa_glsl_parse_state
*state
)
252 return state
->stage
== MESA_SHADER_FRAGMENT
&&
253 (state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
);
258 texture_array_lod(const _mesa_glsl_parse_state
*state
)
260 return lod_exists_in_stage(state
) &&
261 state
->EXT_texture_array_enable
;
265 fs_texture_array(const _mesa_glsl_parse_state
*state
)
267 return state
->stage
== MESA_SHADER_FRAGMENT
&&
268 state
->EXT_texture_array_enable
;
272 texture_array(const _mesa_glsl_parse_state
*state
)
274 return state
->EXT_texture_array_enable
;
278 texture_multisample(const _mesa_glsl_parse_state
*state
)
280 return state
->is_version(150, 310) ||
281 state
->ARB_texture_multisample_enable
;
285 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
287 return state
->is_version(150, 320) ||
288 state
->ARB_texture_multisample_enable
||
289 state
->OES_texture_storage_multisample_2d_array_enable
;
293 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
295 return texture_multisample(state
) &&
296 state
->EXT_shader_samples_identical_enable
;
300 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
302 return texture_multisample_array(state
) &&
303 state
->EXT_shader_samples_identical_enable
;
307 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
309 return state
->stage
== MESA_SHADER_FRAGMENT
&&
310 (state
->is_version(400, 0) ||
311 state
->ARB_texture_cube_map_array_enable
);
315 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
317 return state
->is_version(400, 0) ||
318 state
->ARB_texture_cube_map_array_enable
;
322 texture_query_levels(const _mesa_glsl_parse_state
*state
)
324 return state
->is_version(430, 0) ||
325 state
->ARB_texture_query_levels_enable
;
329 texture_query_lod(const _mesa_glsl_parse_state
*state
)
331 return state
->stage
== MESA_SHADER_FRAGMENT
&&
332 state
->ARB_texture_query_lod_enable
;
336 texture_gather(const _mesa_glsl_parse_state
*state
)
338 return state
->is_version(400, 0) ||
339 state
->ARB_texture_gather_enable
||
340 state
->ARB_gpu_shader5_enable
;
344 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
346 return state
->is_version(400, 310) ||
347 state
->ARB_texture_gather_enable
||
348 state
->ARB_gpu_shader5_enable
;
351 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
352 * used for relaxation of const offset requirements.
355 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
357 return !state
->is_version(400, 0) &&
358 !state
->ARB_gpu_shader5_enable
&&
359 (state
->ARB_texture_gather_enable
||
360 state
->is_version(0, 310));
363 /* Desktop GL or OES_standard_derivatives + fragment shader only */
365 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
367 return state
->stage
== MESA_SHADER_FRAGMENT
&&
368 (state
->is_version(110, 300) ||
369 state
->OES_standard_derivatives_enable
);
373 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
375 return state
->stage
== MESA_SHADER_FRAGMENT
&&
376 (state
->is_version(450, 0) ||
377 state
->ARB_derivative_control_enable
);
381 tex1d_lod(const _mesa_glsl_parse_state
*state
)
383 return !state
->es_shader
&& lod_exists_in_stage(state
);
386 /** True if sampler3D exists */
388 tex3d(const _mesa_glsl_parse_state
*state
)
390 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
391 * OES_texture_3D extension, and in GLSL ES 3.00.
393 return !state
->es_shader
||
394 state
->OES_texture_3D_enable
||
395 state
->language_version
>= 300;
399 fs_tex3d(const _mesa_glsl_parse_state
*state
)
401 return state
->stage
== MESA_SHADER_FRAGMENT
&&
402 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
406 tex3d_lod(const _mesa_glsl_parse_state
*state
)
408 return tex3d(state
) && lod_exists_in_stage(state
);
412 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
414 return state
->has_atomic_counters();
418 shader_clock(const _mesa_glsl_parse_state
*state
)
420 return state
->ARB_shader_clock_enable
;
424 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
426 return state
->has_shader_storage_buffer_objects();
430 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
432 return state
->AMD_shader_trinary_minmax_enable
;
436 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
438 return (state
->is_version(420, 310) ||
439 state
->ARB_shader_image_load_store_enable
);
443 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
445 return (state
->is_version(420, 0) ||
446 state
->ARB_shader_image_load_store_enable
);
450 shader_image_size(const _mesa_glsl_parse_state
*state
)
452 return state
->is_version(430, 310) ||
453 state
->ARB_shader_image_size_enable
;
457 shader_samples(const _mesa_glsl_parse_state
*state
)
459 return state
->is_version(450, 0) ||
460 state
->ARB_shader_texture_image_samples_enable
;
464 gs_streams(const _mesa_glsl_parse_state
*state
)
466 return gpu_shader5(state
) && gs_only(state
);
470 fp64(const _mesa_glsl_parse_state
*state
)
472 return state
->has_double();
476 compute_shader(const _mesa_glsl_parse_state
*state
)
478 return state
->stage
== MESA_SHADER_COMPUTE
;
482 barrier_supported(const _mesa_glsl_parse_state
*state
)
484 return compute_shader(state
) ||
485 state
->stage
== MESA_SHADER_TESS_CTRL
;
490 /******************************************************************************/
495 * builtin_builder: A singleton object representing the core of the built-in
498 * It generates IR for every built-in function signature, and organizes them
501 class builtin_builder
{
508 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
509 const char *name
, exec_list
*actual_parameters
);
512 * A shader to hold all the built-in signatures; created by this module.
514 * This includes signatures for every built-in, regardless of version or
515 * enabled extensions. The availability predicate associated with each
516 * signature allows matching_signature() to filter out the irrelevant ones.
523 /** Global variables used by built-in functions. */
524 ir_variable
*gl_ModelViewProjectionMatrix
;
525 ir_variable
*gl_Vertex
;
527 void create_shader();
528 void create_intrinsics();
529 void create_builtins();
532 * IR builder helpers:
534 * These convenience functions assist in emitting IR, but don't necessarily
535 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
538 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
539 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
540 ir_constant
*imm(float f
, unsigned vector_elements
=1);
541 ir_constant
*imm(int i
, unsigned vector_elements
=1);
542 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
543 ir_constant
*imm(double d
, unsigned vector_elements
=1);
544 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
545 ir_dereference_variable
*var_ref(ir_variable
*var
);
546 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
547 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
549 ir_expression
*asin_expr(ir_variable
*x
);
550 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
553 * Call function \param f with parameters specified as the linked
554 * list \param params of \c ir_variable objects. \param ret should
555 * point to the ir_variable that will hold the function return
556 * value, or be \c NULL if the function has void return type.
558 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
560 /** Create a new function and add the given signatures. */
561 void add_function(const char *name
, ...);
563 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
564 unsigned num_arguments
,
567 enum image_function_flags
{
568 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
569 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
570 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
571 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
572 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
573 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
574 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
575 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
579 * Create a new image built-in function for all known image types.
580 * \p flags is a bitfield of \c image_function_flags flags.
582 void add_image_function(const char *name
,
583 const char *intrinsic_name
,
584 image_prototype_ctr prototype
,
585 unsigned num_arguments
,
589 * Create new functions for all known image built-ins and types.
590 * If \p glsl is \c true, use the GLSL built-in names and emit code
591 * to call into the actual compiler intrinsic. If \p glsl is
592 * false, emit a function prototype with no body for each image
595 void add_image_functions(bool glsl
);
597 ir_function_signature
*new_sig(const glsl_type
*return_type
,
598 builtin_available_predicate avail
,
599 int num_params
, ...);
602 * Function signature generators:
605 ir_function_signature
*unop(builtin_available_predicate avail
,
606 ir_expression_operation opcode
,
607 const glsl_type
*return_type
,
608 const glsl_type
*param_type
);
609 ir_function_signature
*binop(builtin_available_predicate avail
,
610 ir_expression_operation opcode
,
611 const glsl_type
*return_type
,
612 const glsl_type
*param0_type
,
613 const glsl_type
*param1_type
);
615 #define B0(X) ir_function_signature *_##X();
616 #define B1(X) ir_function_signature *_##X(const glsl_type *);
617 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
618 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
619 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
620 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
657 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
658 const glsl_type
*val_type
,
659 const glsl_type
*blend_type
);
668 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
669 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
670 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
671 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
672 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
673 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
674 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
675 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
676 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
677 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
678 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
679 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
692 BA1(determinant_mat2
);
693 BA1(determinant_mat3
);
694 BA1(determinant_mat4
);
702 BA1(greaterThanEqual
);
711 /** Flags to _texture() */
712 #define TEX_PROJECT 1
714 #define TEX_COMPONENT 4
715 #define TEX_OFFSET_NONCONST 8
716 #define TEX_OFFSET_ARRAY 16
718 ir_function_signature
*_texture(ir_texture_opcode opcode
,
719 builtin_available_predicate avail
,
720 const glsl_type
*return_type
,
721 const glsl_type
*sampler_type
,
722 const glsl_type
*coord_type
,
724 B0(textureCubeArrayShadow
);
725 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
726 const glsl_type
*return_type
,
727 const glsl_type
*sampler_type
,
728 const glsl_type
*coord_type
,
729 const glsl_type
*offset_type
= NULL
);
733 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
734 const glsl_type
*stream_type
);
735 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
736 const glsl_type
*stream_type
);
739 BA2(textureQueryLod
);
740 B1(textureQueryLevels
);
741 BA2(textureSamplesIdentical
);
769 B1(interpolateAtCentroid
)
770 B1(interpolateAtOffset
)
771 B1(interpolateAtSample
)
773 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
);
774 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
775 builtin_available_predicate avail
);
777 ir_function_signature
*_atomic_ssbo_intrinsic2(builtin_available_predicate avail
,
778 const glsl_type
*type
);
779 ir_function_signature
*_atomic_ssbo_op2(const char *intrinsic
,
780 builtin_available_predicate avail
,
781 const glsl_type
*type
);
782 ir_function_signature
*_atomic_ssbo_intrinsic3(builtin_available_predicate avail
,
783 const glsl_type
*type
);
784 ir_function_signature
*_atomic_ssbo_op3(const char *intrinsic
,
785 builtin_available_predicate avail
,
786 const glsl_type
*type
);
792 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
793 unsigned num_arguments
,
795 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
796 unsigned num_arguments
,
798 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
799 unsigned num_arguments
,
801 ir_function_signature
*_image(image_prototype_ctr prototype
,
802 const glsl_type
*image_type
,
803 const char *intrinsic_name
,
804 unsigned num_arguments
,
807 ir_function_signature
*_memory_barrier_intrinsic(
808 builtin_available_predicate avail
);
809 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
810 builtin_available_predicate avail
);
812 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
813 const glsl_type
*type
);
814 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
815 const glsl_type
*type
);
826 } /* anonymous namespace */
829 * Core builtin_builder functionality:
832 builtin_builder::builtin_builder()
834 gl_ModelViewProjectionMatrix(NULL
),
840 builtin_builder::~builtin_builder()
842 ralloc_free(mem_ctx
);
845 ir_function_signature
*
846 builtin_builder::find(_mesa_glsl_parse_state
*state
,
847 const char *name
, exec_list
*actual_parameters
)
849 /* The shader currently being compiled requested a built-in function;
850 * it needs to link against builtin_builder::shader in order to get them.
852 * Even if we don't find a matching signature, we still need to do this so
853 * that the "no matching signature" error will list potential candidates
854 * from the available built-ins.
856 state
->uses_builtin_functions
= true;
858 ir_function
*f
= shader
->symbols
->get_function(name
);
862 ir_function_signature
*sig
=
863 f
->matching_signature(state
, actual_parameters
, true);
871 builtin_builder::initialize()
873 /* If already initialized, don't do it again. */
877 mem_ctx
= ralloc_context(NULL
);
884 builtin_builder::release()
886 ralloc_free(mem_ctx
);
894 builtin_builder::create_shader()
896 /* The target doesn't actually matter. There's no target for generic
897 * GLSL utility code that could be linked against any stage, so just
898 * arbitrarily pick GL_VERTEX_SHADER.
900 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
901 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
903 gl_ModelViewProjectionMatrix
=
904 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
905 "gl_ModelViewProjectionMatrix",
908 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
910 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
911 shader
->symbols
->add_variable(gl_Vertex
);
917 * Create ir_function and ir_function_signature objects for each
921 builtin_builder::create_intrinsics()
923 add_function("__intrinsic_atomic_read",
924 _atomic_counter_intrinsic(shader_atomic_counters
),
926 add_function("__intrinsic_atomic_increment",
927 _atomic_counter_intrinsic(shader_atomic_counters
),
929 add_function("__intrinsic_atomic_predecrement",
930 _atomic_counter_intrinsic(shader_atomic_counters
),
933 add_function("__intrinsic_ssbo_atomic_add",
934 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
935 glsl_type::uint_type
),
936 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
937 glsl_type::int_type
),
939 add_function("__intrinsic_ssbo_atomic_min",
940 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
941 glsl_type::uint_type
),
942 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
943 glsl_type::int_type
),
945 add_function("__intrinsic_ssbo_atomic_max",
946 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
947 glsl_type::uint_type
),
948 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
949 glsl_type::int_type
),
951 add_function("__intrinsic_ssbo_atomic_and",
952 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
953 glsl_type::uint_type
),
954 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
955 glsl_type::int_type
),
957 add_function("__intrinsic_ssbo_atomic_or",
958 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
959 glsl_type::uint_type
),
960 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
961 glsl_type::int_type
),
963 add_function("__intrinsic_ssbo_atomic_xor",
964 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
965 glsl_type::uint_type
),
966 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
967 glsl_type::int_type
),
969 add_function("__intrinsic_ssbo_atomic_exchange",
970 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
971 glsl_type::uint_type
),
972 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
973 glsl_type::int_type
),
975 add_function("__intrinsic_ssbo_atomic_comp_swap",
976 _atomic_ssbo_intrinsic3(shader_storage_buffer_object
,
977 glsl_type::uint_type
),
978 _atomic_ssbo_intrinsic3(shader_storage_buffer_object
,
979 glsl_type::int_type
),
982 add_image_functions(false);
984 add_function("__intrinsic_memory_barrier",
985 _memory_barrier_intrinsic(shader_image_load_store
),
987 add_function("__intrinsic_group_memory_barrier",
988 _memory_barrier_intrinsic(compute_shader
),
990 add_function("__intrinsic_memory_barrier_atomic_counter",
991 _memory_barrier_intrinsic(compute_shader
),
993 add_function("__intrinsic_memory_barrier_buffer",
994 _memory_barrier_intrinsic(compute_shader
),
996 add_function("__intrinsic_memory_barrier_image",
997 _memory_barrier_intrinsic(compute_shader
),
999 add_function("__intrinsic_memory_barrier_shared",
1000 _memory_barrier_intrinsic(compute_shader
),
1003 add_function("__intrinsic_shader_clock",
1004 _shader_clock_intrinsic(shader_clock
,
1005 glsl_type::uvec2_type
),
1010 * Create ir_function and ir_function_signature objects for each built-in.
1012 * Contains a list of every available built-in.
1015 builtin_builder::create_builtins()
1018 add_function(#NAME, \
1019 _##NAME(glsl_type::float_type), \
1020 _##NAME(glsl_type::vec2_type), \
1021 _##NAME(glsl_type::vec3_type), \
1022 _##NAME(glsl_type::vec4_type), \
1026 add_function(#NAME, \
1027 _##NAME(always_available, glsl_type::float_type), \
1028 _##NAME(always_available, glsl_type::vec2_type), \
1029 _##NAME(always_available, glsl_type::vec3_type), \
1030 _##NAME(always_available, glsl_type::vec4_type), \
1031 _##NAME(fp64, glsl_type::double_type), \
1032 _##NAME(fp64, glsl_type::dvec2_type), \
1033 _##NAME(fp64, glsl_type::dvec3_type), \
1034 _##NAME(fp64, glsl_type::dvec4_type), \
1037 #define FD130(NAME) \
1038 add_function(#NAME, \
1039 _##NAME(v130, glsl_type::float_type), \
1040 _##NAME(v130, glsl_type::vec2_type), \
1041 _##NAME(v130, glsl_type::vec3_type), \
1042 _##NAME(v130, glsl_type::vec4_type), \
1043 _##NAME(fp64, glsl_type::double_type), \
1044 _##NAME(fp64, glsl_type::dvec2_type), \
1045 _##NAME(fp64, glsl_type::dvec3_type), \
1046 _##NAME(fp64, glsl_type::dvec4_type), \
1049 #define FDGS5(NAME) \
1050 add_function(#NAME, \
1051 _##NAME(gpu_shader5, glsl_type::float_type), \
1052 _##NAME(gpu_shader5, glsl_type::vec2_type), \
1053 _##NAME(gpu_shader5, glsl_type::vec3_type), \
1054 _##NAME(gpu_shader5, glsl_type::vec4_type), \
1055 _##NAME(fp64, glsl_type::double_type), \
1056 _##NAME(fp64, glsl_type::dvec2_type), \
1057 _##NAME(fp64, glsl_type::dvec3_type), \
1058 _##NAME(fp64, glsl_type::dvec4_type), \
1062 add_function(#NAME, \
1063 _##NAME(glsl_type::float_type), \
1064 _##NAME(glsl_type::vec2_type), \
1065 _##NAME(glsl_type::vec3_type), \
1066 _##NAME(glsl_type::vec4_type), \
1067 _##NAME(glsl_type::int_type), \
1068 _##NAME(glsl_type::ivec2_type), \
1069 _##NAME(glsl_type::ivec3_type), \
1070 _##NAME(glsl_type::ivec4_type), \
1074 add_function(#NAME, \
1075 _##NAME(always_available, glsl_type::float_type), \
1076 _##NAME(always_available, glsl_type::vec2_type), \
1077 _##NAME(always_available, glsl_type::vec3_type), \
1078 _##NAME(always_available, glsl_type::vec4_type), \
1079 _##NAME(always_available, glsl_type::int_type), \
1080 _##NAME(always_available, glsl_type::ivec2_type), \
1081 _##NAME(always_available, glsl_type::ivec3_type), \
1082 _##NAME(always_available, glsl_type::ivec4_type), \
1083 _##NAME(fp64, glsl_type::double_type), \
1084 _##NAME(fp64, glsl_type::dvec2_type), \
1085 _##NAME(fp64, glsl_type::dvec3_type), \
1086 _##NAME(fp64, glsl_type::dvec4_type), \
1089 #define FIUD(NAME) \
1090 add_function(#NAME, \
1091 _##NAME(always_available, glsl_type::float_type), \
1092 _##NAME(always_available, glsl_type::vec2_type), \
1093 _##NAME(always_available, glsl_type::vec3_type), \
1094 _##NAME(always_available, glsl_type::vec4_type), \
1096 _##NAME(always_available, glsl_type::int_type), \
1097 _##NAME(always_available, glsl_type::ivec2_type), \
1098 _##NAME(always_available, glsl_type::ivec3_type), \
1099 _##NAME(always_available, glsl_type::ivec4_type), \
1101 _##NAME(v130, glsl_type::uint_type), \
1102 _##NAME(v130, glsl_type::uvec2_type), \
1103 _##NAME(v130, glsl_type::uvec3_type), \
1104 _##NAME(v130, glsl_type::uvec4_type), \
1105 _##NAME(fp64, glsl_type::double_type), \
1106 _##NAME(fp64, glsl_type::dvec2_type), \
1107 _##NAME(fp64, glsl_type::dvec3_type), \
1108 _##NAME(fp64, glsl_type::dvec4_type), \
1112 add_function(#NAME, \
1113 _##NAME(glsl_type::int_type), \
1114 _##NAME(glsl_type::ivec2_type), \
1115 _##NAME(glsl_type::ivec3_type), \
1116 _##NAME(glsl_type::ivec4_type), \
1118 _##NAME(glsl_type::uint_type), \
1119 _##NAME(glsl_type::uvec2_type), \
1120 _##NAME(glsl_type::uvec3_type), \
1121 _##NAME(glsl_type::uvec4_type), \
1124 #define FIUBD(NAME) \
1125 add_function(#NAME, \
1126 _##NAME(always_available, glsl_type::float_type), \
1127 _##NAME(always_available, glsl_type::vec2_type), \
1128 _##NAME(always_available, glsl_type::vec3_type), \
1129 _##NAME(always_available, glsl_type::vec4_type), \
1131 _##NAME(always_available, glsl_type::int_type), \
1132 _##NAME(always_available, glsl_type::ivec2_type), \
1133 _##NAME(always_available, glsl_type::ivec3_type), \
1134 _##NAME(always_available, glsl_type::ivec4_type), \
1136 _##NAME(v130, glsl_type::uint_type), \
1137 _##NAME(v130, glsl_type::uvec2_type), \
1138 _##NAME(v130, glsl_type::uvec3_type), \
1139 _##NAME(v130, glsl_type::uvec4_type), \
1141 _##NAME(always_available, glsl_type::bool_type), \
1142 _##NAME(always_available, glsl_type::bvec2_type), \
1143 _##NAME(always_available, glsl_type::bvec3_type), \
1144 _##NAME(always_available, glsl_type::bvec4_type), \
1146 _##NAME(fp64, glsl_type::double_type), \
1147 _##NAME(fp64, glsl_type::dvec2_type), \
1148 _##NAME(fp64, glsl_type::dvec3_type), \
1149 _##NAME(fp64, glsl_type::dvec4_type), \
1152 #define FIUD2_MIXED(NAME) \
1153 add_function(#NAME, \
1154 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1155 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1156 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1157 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1159 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1160 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1161 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1163 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1164 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1165 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1166 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1168 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1169 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1170 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1172 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1173 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1174 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1175 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1177 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1178 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1179 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1181 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1182 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1183 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1184 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1185 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1186 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1187 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1198 add_function("atan",
1199 _atan(glsl_type::float_type
),
1200 _atan(glsl_type::vec2_type
),
1201 _atan(glsl_type::vec3_type
),
1202 _atan(glsl_type::vec4_type
),
1203 _atan2(glsl_type::float_type
),
1204 _atan2(glsl_type::vec2_type
),
1205 _atan2(glsl_type::vec3_type
),
1206 _atan2(glsl_type::vec4_type
),
1232 _mod(glsl_type::float_type
, glsl_type::float_type
),
1233 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
1234 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
1235 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
1237 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
1238 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
1239 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
1241 _mod(glsl_type::double_type
, glsl_type::double_type
),
1242 _mod(glsl_type::dvec2_type
, glsl_type::double_type
),
1243 _mod(glsl_type::dvec3_type
, glsl_type::double_type
),
1244 _mod(glsl_type::dvec4_type
, glsl_type::double_type
),
1246 _mod(glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1247 _mod(glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1248 _mod(glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1258 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1259 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1260 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1261 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1263 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1264 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1265 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1267 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1268 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1269 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1270 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1272 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1273 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1274 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1276 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1277 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1278 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1279 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1281 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1282 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1283 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1284 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1286 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1287 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1288 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1289 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1291 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1292 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1293 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1294 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1296 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1297 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1298 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1299 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1302 add_function("step",
1303 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1304 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1305 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1306 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1308 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1309 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1310 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1311 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1312 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1313 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1314 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1316 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1317 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1318 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1321 add_function("smoothstep",
1322 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1323 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1324 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1325 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1327 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1328 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1329 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1330 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1331 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1332 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1333 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1335 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1336 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1337 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1345 add_function("intBitsToFloat",
1346 _intBitsToFloat(glsl_type::int_type
),
1347 _intBitsToFloat(glsl_type::ivec2_type
),
1348 _intBitsToFloat(glsl_type::ivec3_type
),
1349 _intBitsToFloat(glsl_type::ivec4_type
),
1351 add_function("uintBitsToFloat",
1352 _uintBitsToFloat(glsl_type::uint_type
),
1353 _uintBitsToFloat(glsl_type::uvec2_type
),
1354 _uintBitsToFloat(glsl_type::uvec3_type
),
1355 _uintBitsToFloat(glsl_type::uvec4_type
),
1358 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1359 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1360 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1361 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1362 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1363 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1364 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1365 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1366 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1367 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1368 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1369 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1376 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1377 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1380 add_function("ftransform", _ftransform(), NULL
);
1385 add_function("matrixCompMult",
1386 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1387 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1388 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1389 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1390 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1391 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1392 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1393 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1394 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1395 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1396 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1397 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1398 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1399 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1400 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1401 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1402 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1403 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1405 add_function("outerProduct",
1406 _outerProduct(v120
, glsl_type::mat2_type
),
1407 _outerProduct(v120
, glsl_type::mat3_type
),
1408 _outerProduct(v120
, glsl_type::mat4_type
),
1409 _outerProduct(v120
, glsl_type::mat2x3_type
),
1410 _outerProduct(v120
, glsl_type::mat2x4_type
),
1411 _outerProduct(v120
, glsl_type::mat3x2_type
),
1412 _outerProduct(v120
, glsl_type::mat3x4_type
),
1413 _outerProduct(v120
, glsl_type::mat4x2_type
),
1414 _outerProduct(v120
, glsl_type::mat4x3_type
),
1415 _outerProduct(fp64
, glsl_type::dmat2_type
),
1416 _outerProduct(fp64
, glsl_type::dmat3_type
),
1417 _outerProduct(fp64
, glsl_type::dmat4_type
),
1418 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1419 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1420 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1421 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1422 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1423 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1425 add_function("determinant",
1426 _determinant_mat2(v120
, glsl_type::mat2_type
),
1427 _determinant_mat3(v120
, glsl_type::mat3_type
),
1428 _determinant_mat4(v120
, glsl_type::mat4_type
),
1429 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1430 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1431 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1434 add_function("inverse",
1435 _inverse_mat2(v120
, glsl_type::mat2_type
),
1436 _inverse_mat3(v120
, glsl_type::mat3_type
),
1437 _inverse_mat4(v120
, glsl_type::mat4_type
),
1438 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1439 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1440 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1442 add_function("transpose",
1443 _transpose(v120
, glsl_type::mat2_type
),
1444 _transpose(v120
, glsl_type::mat3_type
),
1445 _transpose(v120
, glsl_type::mat4_type
),
1446 _transpose(v120
, glsl_type::mat2x3_type
),
1447 _transpose(v120
, glsl_type::mat2x4_type
),
1448 _transpose(v120
, glsl_type::mat3x2_type
),
1449 _transpose(v120
, glsl_type::mat3x4_type
),
1450 _transpose(v120
, glsl_type::mat4x2_type
),
1451 _transpose(v120
, glsl_type::mat4x3_type
),
1452 _transpose(fp64
, glsl_type::dmat2_type
),
1453 _transpose(fp64
, glsl_type::dmat3_type
),
1454 _transpose(fp64
, glsl_type::dmat4_type
),
1455 _transpose(fp64
, glsl_type::dmat2x3_type
),
1456 _transpose(fp64
, glsl_type::dmat2x4_type
),
1457 _transpose(fp64
, glsl_type::dmat3x2_type
),
1458 _transpose(fp64
, glsl_type::dmat3x4_type
),
1459 _transpose(fp64
, glsl_type::dmat4x2_type
),
1460 _transpose(fp64
, glsl_type::dmat4x3_type
),
1465 FIUD(greaterThanEqual
)
1470 _any(glsl_type::bvec2_type
),
1471 _any(glsl_type::bvec3_type
),
1472 _any(glsl_type::bvec4_type
),
1476 _all(glsl_type::bvec2_type
),
1477 _all(glsl_type::bvec3_type
),
1478 _all(glsl_type::bvec4_type
),
1482 _not(glsl_type::bvec2_type
),
1483 _not(glsl_type::bvec3_type
),
1484 _not(glsl_type::bvec4_type
),
1487 add_function("textureSize",
1488 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1489 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1490 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1492 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1493 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1494 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1496 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1497 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1498 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1500 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1501 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1502 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1504 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1505 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1506 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1508 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1509 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1510 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1511 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1512 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1513 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1515 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1516 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1518 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1519 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1520 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1521 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1523 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1524 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1525 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1526 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1528 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1529 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1530 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1531 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1532 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1533 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1535 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1536 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1537 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1540 add_function("textureSamples",
1541 _textureSamples(glsl_type::sampler2DMS_type
),
1542 _textureSamples(glsl_type::isampler2DMS_type
),
1543 _textureSamples(glsl_type::usampler2DMS_type
),
1545 _textureSamples(glsl_type::sampler2DMSArray_type
),
1546 _textureSamples(glsl_type::isampler2DMSArray_type
),
1547 _textureSamples(glsl_type::usampler2DMSArray_type
),
1550 add_function("texture",
1551 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1552 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1553 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1555 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1556 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1557 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1559 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1560 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1561 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1563 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1564 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1565 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1567 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1568 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1569 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1571 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1572 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1573 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1575 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1576 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1577 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1579 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1580 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1581 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1583 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1584 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1585 /* samplerCubeArrayShadow is special; it has an extra parameter
1586 * for the shadow comparitor since there is no vec5 type.
1588 _textureCubeArrayShadow(),
1590 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1591 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1592 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1594 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1596 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1597 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1598 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1600 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1601 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1602 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1604 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1605 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1606 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1608 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1609 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1610 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1612 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1613 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1614 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1616 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1617 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1618 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1620 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1621 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1622 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1624 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1625 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1626 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1628 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1631 add_function("textureLod",
1632 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1633 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1634 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1636 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1637 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1638 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1640 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1641 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1642 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1644 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1645 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1646 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1648 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1649 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1651 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1652 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1653 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1655 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1656 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1657 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1659 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1660 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1661 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1663 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1666 add_function("textureOffset",
1667 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1668 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1669 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1671 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1672 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1673 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1675 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1676 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1677 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1679 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1680 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1681 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1683 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1685 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1686 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1688 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1689 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1690 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1692 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1693 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1694 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1696 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1698 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1699 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1700 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1702 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1703 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1704 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1706 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1707 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1708 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1710 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1711 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1713 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1714 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1715 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1717 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1718 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1719 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1721 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1724 add_function("textureProj",
1725 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1726 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1727 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1728 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1729 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1730 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1732 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1733 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1734 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1735 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1736 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1737 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1739 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1740 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1741 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1743 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1744 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1746 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1747 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1748 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1749 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1750 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1751 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1753 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1755 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1756 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1757 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1758 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1759 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1760 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1762 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1763 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1764 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1765 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1766 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1767 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1769 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1770 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1771 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1773 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1774 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1777 add_function("texelFetch",
1778 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1779 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1780 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1782 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1783 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1784 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1786 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1787 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1788 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1790 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1791 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1792 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1794 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1795 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1796 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1798 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1799 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1800 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1802 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1803 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1804 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1806 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1807 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1808 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1810 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1811 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1812 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1815 add_function("texelFetchOffset",
1816 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1817 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1818 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1820 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1821 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1822 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1824 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1825 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1826 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1828 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1829 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1830 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1832 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1833 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1834 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1836 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1837 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1838 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1842 add_function("textureProjOffset",
1843 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1844 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1845 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1846 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1847 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1848 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1850 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1851 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1852 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1853 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1854 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1855 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1857 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1858 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1859 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1861 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1862 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1864 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1865 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1866 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1867 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1868 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1869 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1871 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1873 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1874 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1875 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1876 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1877 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1878 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1880 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1881 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1882 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1883 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1884 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1885 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1887 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1888 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1889 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1891 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1892 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1895 add_function("textureLodOffset",
1896 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1897 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1898 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1900 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1901 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1902 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1904 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1905 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1906 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1908 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1909 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1911 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1912 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1913 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1915 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1916 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1917 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1919 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1922 add_function("textureProjLod",
1923 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1924 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1925 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1926 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1927 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1928 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1930 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1931 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1932 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1933 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1934 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1935 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1937 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1938 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1939 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1941 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1942 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1945 add_function("textureProjLodOffset",
1946 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1947 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1948 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1949 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1950 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1951 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1953 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1954 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1955 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1956 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1957 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1958 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1960 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1961 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1962 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1964 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1965 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1968 add_function("textureGrad",
1969 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1970 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1971 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1973 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1974 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1975 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1977 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1978 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1979 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1981 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1982 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1983 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1985 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1986 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1987 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1989 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1991 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1992 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1993 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1995 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1996 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1997 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1999 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2000 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2001 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2003 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2004 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2005 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2007 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2008 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2011 add_function("textureGradOffset",
2012 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2013 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2014 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2016 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2017 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2018 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2020 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2021 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2022 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2024 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2025 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2026 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2028 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2030 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2031 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2033 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2034 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2035 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2037 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2038 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2039 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2041 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2042 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2045 add_function("textureProjGrad",
2046 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2047 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2048 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2049 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2050 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2051 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2053 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2054 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2055 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2056 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2057 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2058 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2060 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2061 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2062 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2064 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2065 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2066 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2067 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2068 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2069 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2071 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2073 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2074 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2077 add_function("textureProjGradOffset",
2078 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2079 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2080 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2081 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2082 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2083 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2085 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2086 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2087 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2088 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2089 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2090 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2092 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2093 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2094 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2096 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2097 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2098 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2099 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2100 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2101 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2103 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2105 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2106 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2109 add_function("EmitVertex", _EmitVertex(), NULL
);
2110 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2111 add_function("EmitStreamVertex",
2112 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2113 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2115 add_function("EndStreamPrimitive",
2116 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2117 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2119 add_function("barrier", _barrier(), NULL
);
2121 add_function("textureQueryLOD",
2122 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2123 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2124 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2126 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2127 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2128 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2130 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2131 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2132 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2134 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2135 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2136 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2138 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2139 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2140 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2142 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2143 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2144 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2146 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2147 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2148 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2150 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2151 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2152 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2153 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2154 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2155 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2158 add_function("textureQueryLod",
2159 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2160 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2161 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2163 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2164 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2165 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2167 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2168 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2169 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2171 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2172 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2173 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2175 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2176 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2177 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2179 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2180 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2181 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2183 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2184 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2185 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2187 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2188 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2189 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2190 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2191 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2192 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2195 add_function("textureQueryLevels",
2196 _textureQueryLevels(glsl_type::sampler1D_type
),
2197 _textureQueryLevels(glsl_type::sampler2D_type
),
2198 _textureQueryLevels(glsl_type::sampler3D_type
),
2199 _textureQueryLevels(glsl_type::samplerCube_type
),
2200 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2201 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2202 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2203 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2204 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2205 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2206 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2207 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2208 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2210 _textureQueryLevels(glsl_type::isampler1D_type
),
2211 _textureQueryLevels(glsl_type::isampler2D_type
),
2212 _textureQueryLevels(glsl_type::isampler3D_type
),
2213 _textureQueryLevels(glsl_type::isamplerCube_type
),
2214 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2215 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2216 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2218 _textureQueryLevels(glsl_type::usampler1D_type
),
2219 _textureQueryLevels(glsl_type::usampler2D_type
),
2220 _textureQueryLevels(glsl_type::usampler3D_type
),
2221 _textureQueryLevels(glsl_type::usamplerCube_type
),
2222 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2223 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2224 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2228 add_function("textureSamplesIdenticalEXT",
2229 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2230 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2231 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2233 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2234 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2235 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2238 add_function("texture1D",
2239 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2240 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2243 add_function("texture1DArray",
2244 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2245 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2248 add_function("texture1DProj",
2249 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2250 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2251 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2252 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2255 add_function("texture1DLod",
2256 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2259 add_function("texture1DArrayLod",
2260 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2263 add_function("texture1DProjLod",
2264 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2265 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2268 add_function("texture2D",
2269 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2270 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2271 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2274 add_function("texture2DArray",
2275 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2276 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2279 add_function("texture2DProj",
2280 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2281 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2282 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2283 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2284 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2285 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2288 add_function("texture2DLod",
2289 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2292 add_function("texture2DArrayLod",
2293 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2296 add_function("texture2DProjLod",
2297 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2298 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2301 add_function("texture3D",
2302 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2303 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2306 add_function("texture3DProj",
2307 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2308 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2311 add_function("texture3DLod",
2312 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2315 add_function("texture3DProjLod",
2316 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2319 add_function("textureCube",
2320 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2321 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2324 add_function("textureCubeLod",
2325 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2328 add_function("texture2DRect",
2329 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2332 add_function("texture2DRectProj",
2333 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2334 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2337 add_function("shadow1D",
2338 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2339 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2342 add_function("shadow1DArray",
2343 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2344 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2347 add_function("shadow2D",
2348 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2349 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2352 add_function("shadow2DArray",
2353 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2354 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2357 add_function("shadow1DProj",
2358 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2359 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2362 add_function("shadow2DProj",
2363 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2364 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2367 add_function("shadow1DLod",
2368 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2371 add_function("shadow2DLod",
2372 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2375 add_function("shadow1DArrayLod",
2376 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2379 add_function("shadow1DProjLod",
2380 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2383 add_function("shadow2DProjLod",
2384 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2387 add_function("shadow2DRect",
2388 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2391 add_function("shadow2DRectProj",
2392 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2395 add_function("texture1DGradARB",
2396 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2399 add_function("texture1DProjGradARB",
2400 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2401 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2404 add_function("texture2DGradARB",
2405 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2408 add_function("texture2DProjGradARB",
2409 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2410 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2413 add_function("texture3DGradARB",
2414 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2417 add_function("texture3DProjGradARB",
2418 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2421 add_function("textureCubeGradARB",
2422 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2425 add_function("shadow1DGradARB",
2426 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2429 add_function("shadow1DProjGradARB",
2430 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2433 add_function("shadow2DGradARB",
2434 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2437 add_function("shadow2DProjGradARB",
2438 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2441 add_function("texture2DRectGradARB",
2442 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2445 add_function("texture2DRectProjGradARB",
2446 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2447 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2450 add_function("shadow2DRectGradARB",
2451 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2454 add_function("shadow2DRectProjGradARB",
2455 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2458 add_function("textureGather",
2459 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2460 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2461 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2463 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2464 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2465 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2467 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2468 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2469 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2471 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2472 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2473 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2475 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2476 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2477 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2479 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2480 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2481 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2483 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2484 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2485 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2487 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2488 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2489 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2491 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2492 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2493 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2495 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2496 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2497 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2499 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2500 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2501 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2502 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2503 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2506 add_function("textureGatherOffset",
2507 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2508 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2509 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2511 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2512 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2513 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2515 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2516 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2517 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2519 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2520 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2521 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2523 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2524 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2525 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2527 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2528 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2529 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2531 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2532 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2533 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2535 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2536 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2537 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2539 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2540 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2541 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2543 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2544 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2545 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2547 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2548 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2549 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2551 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2552 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2555 add_function("textureGatherOffsets",
2556 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2557 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2558 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2560 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2561 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2562 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2564 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2565 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2566 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2568 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2569 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2570 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2572 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2573 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2574 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2576 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2577 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2578 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2580 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2581 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2582 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2607 add_function("ldexp",
2608 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2609 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2610 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2611 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2612 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2613 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2614 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2615 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2618 add_function("frexp",
2619 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2620 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2621 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2622 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2623 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2624 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2625 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2626 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2628 add_function("uaddCarry",
2629 _uaddCarry(glsl_type::uint_type
),
2630 _uaddCarry(glsl_type::uvec2_type
),
2631 _uaddCarry(glsl_type::uvec3_type
),
2632 _uaddCarry(glsl_type::uvec4_type
),
2634 add_function("usubBorrow",
2635 _usubBorrow(glsl_type::uint_type
),
2636 _usubBorrow(glsl_type::uvec2_type
),
2637 _usubBorrow(glsl_type::uvec3_type
),
2638 _usubBorrow(glsl_type::uvec4_type
),
2640 add_function("imulExtended",
2641 _mulExtended(glsl_type::int_type
),
2642 _mulExtended(glsl_type::ivec2_type
),
2643 _mulExtended(glsl_type::ivec3_type
),
2644 _mulExtended(glsl_type::ivec4_type
),
2646 add_function("umulExtended",
2647 _mulExtended(glsl_type::uint_type
),
2648 _mulExtended(glsl_type::uvec2_type
),
2649 _mulExtended(glsl_type::uvec3_type
),
2650 _mulExtended(glsl_type::uvec4_type
),
2652 add_function("interpolateAtCentroid",
2653 _interpolateAtCentroid(glsl_type::float_type
),
2654 _interpolateAtCentroid(glsl_type::vec2_type
),
2655 _interpolateAtCentroid(glsl_type::vec3_type
),
2656 _interpolateAtCentroid(glsl_type::vec4_type
),
2658 add_function("interpolateAtOffset",
2659 _interpolateAtOffset(glsl_type::float_type
),
2660 _interpolateAtOffset(glsl_type::vec2_type
),
2661 _interpolateAtOffset(glsl_type::vec3_type
),
2662 _interpolateAtOffset(glsl_type::vec4_type
),
2664 add_function("interpolateAtSample",
2665 _interpolateAtSample(glsl_type::float_type
),
2666 _interpolateAtSample(glsl_type::vec2_type
),
2667 _interpolateAtSample(glsl_type::vec3_type
),
2668 _interpolateAtSample(glsl_type::vec4_type
),
2671 add_function("atomicCounter",
2672 _atomic_counter_op("__intrinsic_atomic_read",
2673 shader_atomic_counters
),
2675 add_function("atomicCounterIncrement",
2676 _atomic_counter_op("__intrinsic_atomic_increment",
2677 shader_atomic_counters
),
2679 add_function("atomicCounterDecrement",
2680 _atomic_counter_op("__intrinsic_atomic_predecrement",
2681 shader_atomic_counters
),
2684 add_function("atomicAdd",
2685 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_add",
2686 shader_storage_buffer_object
,
2687 glsl_type::uint_type
),
2688 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_add",
2689 shader_storage_buffer_object
,
2690 glsl_type::int_type
),
2692 add_function("atomicMin",
2693 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_min",
2694 shader_storage_buffer_object
,
2695 glsl_type::uint_type
),
2696 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_min",
2697 shader_storage_buffer_object
,
2698 glsl_type::int_type
),
2700 add_function("atomicMax",
2701 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_max",
2702 shader_storage_buffer_object
,
2703 glsl_type::uint_type
),
2704 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_max",
2705 shader_storage_buffer_object
,
2706 glsl_type::int_type
),
2708 add_function("atomicAnd",
2709 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_and",
2710 shader_storage_buffer_object
,
2711 glsl_type::uint_type
),
2712 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_and",
2713 shader_storage_buffer_object
,
2714 glsl_type::int_type
),
2716 add_function("atomicOr",
2717 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_or",
2718 shader_storage_buffer_object
,
2719 glsl_type::uint_type
),
2720 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_or",
2721 shader_storage_buffer_object
,
2722 glsl_type::int_type
),
2724 add_function("atomicXor",
2725 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_xor",
2726 shader_storage_buffer_object
,
2727 glsl_type::uint_type
),
2728 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_xor",
2729 shader_storage_buffer_object
,
2730 glsl_type::int_type
),
2732 add_function("atomicExchange",
2733 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_exchange",
2734 shader_storage_buffer_object
,
2735 glsl_type::uint_type
),
2736 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_exchange",
2737 shader_storage_buffer_object
,
2738 glsl_type::int_type
),
2740 add_function("atomicCompSwap",
2741 _atomic_ssbo_op3("__intrinsic_ssbo_atomic_comp_swap",
2742 shader_storage_buffer_object
,
2743 glsl_type::uint_type
),
2744 _atomic_ssbo_op3("__intrinsic_ssbo_atomic_comp_swap",
2745 shader_storage_buffer_object
,
2746 glsl_type::int_type
),
2749 add_function("min3",
2750 _min3(glsl_type::float_type
),
2751 _min3(glsl_type::vec2_type
),
2752 _min3(glsl_type::vec3_type
),
2753 _min3(glsl_type::vec4_type
),
2755 _min3(glsl_type::int_type
),
2756 _min3(glsl_type::ivec2_type
),
2757 _min3(glsl_type::ivec3_type
),
2758 _min3(glsl_type::ivec4_type
),
2760 _min3(glsl_type::uint_type
),
2761 _min3(glsl_type::uvec2_type
),
2762 _min3(glsl_type::uvec3_type
),
2763 _min3(glsl_type::uvec4_type
),
2766 add_function("max3",
2767 _max3(glsl_type::float_type
),
2768 _max3(glsl_type::vec2_type
),
2769 _max3(glsl_type::vec3_type
),
2770 _max3(glsl_type::vec4_type
),
2772 _max3(glsl_type::int_type
),
2773 _max3(glsl_type::ivec2_type
),
2774 _max3(glsl_type::ivec3_type
),
2775 _max3(glsl_type::ivec4_type
),
2777 _max3(glsl_type::uint_type
),
2778 _max3(glsl_type::uvec2_type
),
2779 _max3(glsl_type::uvec3_type
),
2780 _max3(glsl_type::uvec4_type
),
2783 add_function("mid3",
2784 _mid3(glsl_type::float_type
),
2785 _mid3(glsl_type::vec2_type
),
2786 _mid3(glsl_type::vec3_type
),
2787 _mid3(glsl_type::vec4_type
),
2789 _mid3(glsl_type::int_type
),
2790 _mid3(glsl_type::ivec2_type
),
2791 _mid3(glsl_type::ivec3_type
),
2792 _mid3(glsl_type::ivec4_type
),
2794 _mid3(glsl_type::uint_type
),
2795 _mid3(glsl_type::uvec2_type
),
2796 _mid3(glsl_type::uvec3_type
),
2797 _mid3(glsl_type::uvec4_type
),
2800 add_image_functions(true);
2802 add_function("memoryBarrier",
2803 _memory_barrier("__intrinsic_memory_barrier",
2804 shader_image_load_store
),
2806 add_function("groupMemoryBarrier",
2807 _memory_barrier("__intrinsic_group_memory_barrier",
2810 add_function("memoryBarrierAtomicCounter",
2811 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
2814 add_function("memoryBarrierBuffer",
2815 _memory_barrier("__intrinsic_memory_barrier_buffer",
2818 add_function("memoryBarrierImage",
2819 _memory_barrier("__intrinsic_memory_barrier_image",
2822 add_function("memoryBarrierShared",
2823 _memory_barrier("__intrinsic_memory_barrier_shared",
2827 add_function("clock2x32ARB",
2828 _shader_clock(shader_clock
,
2829 glsl_type::uvec2_type
),
2840 builtin_builder::add_function(const char *name
, ...)
2844 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2848 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2854 stuff
.push_tail(sig
);
2855 validate_ir_tree(&stuff
);
2858 f
->add_signature(sig
);
2862 shader
->symbols
->add_function(f
);
2866 builtin_builder::add_image_function(const char *name
,
2867 const char *intrinsic_name
,
2868 image_prototype_ctr prototype
,
2869 unsigned num_arguments
,
2872 static const glsl_type
*const types
[] = {
2873 glsl_type::image1D_type
,
2874 glsl_type::image2D_type
,
2875 glsl_type::image3D_type
,
2876 glsl_type::image2DRect_type
,
2877 glsl_type::imageCube_type
,
2878 glsl_type::imageBuffer_type
,
2879 glsl_type::image1DArray_type
,
2880 glsl_type::image2DArray_type
,
2881 glsl_type::imageCubeArray_type
,
2882 glsl_type::image2DMS_type
,
2883 glsl_type::image2DMSArray_type
,
2884 glsl_type::iimage1D_type
,
2885 glsl_type::iimage2D_type
,
2886 glsl_type::iimage3D_type
,
2887 glsl_type::iimage2DRect_type
,
2888 glsl_type::iimageCube_type
,
2889 glsl_type::iimageBuffer_type
,
2890 glsl_type::iimage1DArray_type
,
2891 glsl_type::iimage2DArray_type
,
2892 glsl_type::iimageCubeArray_type
,
2893 glsl_type::iimage2DMS_type
,
2894 glsl_type::iimage2DMSArray_type
,
2895 glsl_type::uimage1D_type
,
2896 glsl_type::uimage2D_type
,
2897 glsl_type::uimage3D_type
,
2898 glsl_type::uimage2DRect_type
,
2899 glsl_type::uimageCube_type
,
2900 glsl_type::uimageBuffer_type
,
2901 glsl_type::uimage1DArray_type
,
2902 glsl_type::uimage2DArray_type
,
2903 glsl_type::uimageCubeArray_type
,
2904 glsl_type::uimage2DMS_type
,
2905 glsl_type::uimage2DMSArray_type
2908 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2910 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2911 if ((types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2912 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
2913 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
2914 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
2915 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
2916 num_arguments
, flags
));
2919 shader
->symbols
->add_function(f
);
2923 builtin_builder::add_image_functions(bool glsl
)
2925 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2927 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2928 "__intrinsic_image_load",
2929 &builtin_builder::_image_prototype
, 0,
2930 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2931 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2932 IMAGE_FUNCTION_READ_ONLY
));
2934 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2935 "__intrinsic_image_store",
2936 &builtin_builder::_image_prototype
, 1,
2937 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2938 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2939 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2940 IMAGE_FUNCTION_WRITE_ONLY
));
2942 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
2944 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2945 "__intrinsic_image_atomic_add",
2946 &builtin_builder::_image_prototype
, 1, atom_flags
);
2948 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2949 "__intrinsic_image_atomic_min",
2950 &builtin_builder::_image_prototype
, 1, atom_flags
);
2952 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2953 "__intrinsic_image_atomic_max",
2954 &builtin_builder::_image_prototype
, 1, atom_flags
);
2956 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2957 "__intrinsic_image_atomic_and",
2958 &builtin_builder::_image_prototype
, 1, atom_flags
);
2960 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2961 "__intrinsic_image_atomic_or",
2962 &builtin_builder::_image_prototype
, 1, atom_flags
);
2964 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2965 "__intrinsic_image_atomic_xor",
2966 &builtin_builder::_image_prototype
, 1, atom_flags
);
2968 add_image_function((glsl
? "imageAtomicExchange" :
2969 "__intrinsic_image_atomic_exchange"),
2970 "__intrinsic_image_atomic_exchange",
2971 &builtin_builder::_image_prototype
, 1, atom_flags
);
2973 add_image_function((glsl
? "imageAtomicCompSwap" :
2974 "__intrinsic_image_atomic_comp_swap"),
2975 "__intrinsic_image_atomic_comp_swap",
2976 &builtin_builder::_image_prototype
, 2, atom_flags
);
2978 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
2979 "__intrinsic_image_size",
2980 &builtin_builder::_image_size_prototype
, 1,
2981 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
2983 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
2984 "__intrinsic_image_samples",
2985 &builtin_builder::_image_samples_prototype
, 1,
2986 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2987 IMAGE_FUNCTION_MS_ONLY
);
2991 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2993 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2997 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2999 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3003 builtin_builder::imm(float f
, unsigned vector_elements
)
3005 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3009 builtin_builder::imm(int i
, unsigned vector_elements
)
3011 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3015 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3017 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3021 builtin_builder::imm(double d
, unsigned vector_elements
)
3023 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3027 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3029 return new(mem_ctx
) ir_constant(type
, &data
);
3032 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
3034 ir_dereference_variable
*
3035 builtin_builder::var_ref(ir_variable
*var
)
3037 return new(mem_ctx
) ir_dereference_variable(var
);
3040 ir_dereference_array
*
3041 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3043 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3046 /** Return an element of a matrix */
3048 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3050 return swizzle(array_ref(var
, column
), row
, 1);
3054 * Implementations of built-in functions:
3057 ir_function_signature
*
3058 builtin_builder::new_sig(const glsl_type
*return_type
,
3059 builtin_available_predicate avail
,
3065 ir_function_signature
*sig
=
3066 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3069 va_start(ap
, num_params
);
3070 for (int i
= 0; i
< num_params
; i
++) {
3071 plist
.push_tail(va_arg(ap
, ir_variable
*));
3075 sig
->replace_parameters(&plist
);
3079 #define MAKE_SIG(return_type, avail, ...) \
3080 ir_function_signature *sig = \
3081 new_sig(return_type, avail, __VA_ARGS__); \
3082 ir_factory body(&sig->body, mem_ctx); \
3083 sig->is_defined = true;
3085 #define MAKE_INTRINSIC(return_type, avail, ...) \
3086 ir_function_signature *sig = \
3087 new_sig(return_type, avail, __VA_ARGS__); \
3088 sig->is_intrinsic = true;
3090 ir_function_signature
*
3091 builtin_builder::unop(builtin_available_predicate avail
,
3092 ir_expression_operation opcode
,
3093 const glsl_type
*return_type
,
3094 const glsl_type
*param_type
)
3096 ir_variable
*x
= in_var(param_type
, "x");
3097 MAKE_SIG(return_type
, avail
, 1, x
);
3098 body
.emit(ret(expr(opcode
, x
)));
3102 #define UNOP(NAME, OPCODE, AVAIL) \
3103 ir_function_signature * \
3104 builtin_builder::_##NAME(const glsl_type *type) \
3106 return unop(&AVAIL, OPCODE, type, type); \
3109 #define UNOPA(NAME, OPCODE) \
3110 ir_function_signature * \
3111 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3113 return unop(avail, OPCODE, type, type); \
3116 ir_function_signature
*
3117 builtin_builder::binop(builtin_available_predicate avail
,
3118 ir_expression_operation opcode
,
3119 const glsl_type
*return_type
,
3120 const glsl_type
*param0_type
,
3121 const glsl_type
*param1_type
)
3123 ir_variable
*x
= in_var(param0_type
, "x");
3124 ir_variable
*y
= in_var(param1_type
, "y");
3125 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3126 body
.emit(ret(expr(opcode
, x
, y
)));
3130 #define BINOP(NAME, OPCODE, AVAIL) \
3131 ir_function_signature * \
3132 builtin_builder::_##NAME(const glsl_type *return_type, \
3133 const glsl_type *param0_type, \
3134 const glsl_type *param1_type) \
3136 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3140 * Angle and Trigonometry Functions @{
3143 ir_function_signature
*
3144 builtin_builder::_radians(const glsl_type
*type
)
3146 ir_variable
*degrees
= in_var(type
, "degrees");
3147 MAKE_SIG(type
, always_available
, 1, degrees
);
3148 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3152 ir_function_signature
*
3153 builtin_builder::_degrees(const glsl_type
*type
)
3155 ir_variable
*radians
= in_var(type
, "radians");
3156 MAKE_SIG(type
, always_available
, 1, radians
);
3157 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3161 UNOP(sin
, ir_unop_sin
, always_available
)
3162 UNOP(cos
, ir_unop_cos
, always_available
)
3164 ir_function_signature
*
3165 builtin_builder::_tan(const glsl_type
*type
)
3167 ir_variable
*theta
= in_var(type
, "theta");
3168 MAKE_SIG(type
, always_available
, 1, theta
);
3169 body
.emit(ret(div(sin(theta
), cos(theta
))));
3174 builtin_builder::asin_expr(ir_variable
*x
)
3178 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3181 add(imm(M_PI_4f
- 1.0f
),
3183 add(imm(0.086566724f
),
3184 mul(abs(x
), imm(-0.03102955f
))))))))));
3188 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3190 exec_list actual_params
;
3192 foreach_in_list(ir_variable
, var
, ¶ms
) {
3193 actual_params
.push_tail(var_ref(var
));
3196 ir_function_signature
*sig
=
3197 f
->exact_matching_signature(NULL
, &actual_params
);
3201 ir_dereference_variable
*deref
=
3202 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3204 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3207 ir_function_signature
*
3208 builtin_builder::_asin(const glsl_type
*type
)
3210 ir_variable
*x
= in_var(type
, "x");
3211 MAKE_SIG(type
, always_available
, 1, x
);
3213 body
.emit(ret(asin_expr(x
)));
3218 ir_function_signature
*
3219 builtin_builder::_acos(const glsl_type
*type
)
3221 ir_variable
*x
= in_var(type
, "x");
3222 MAKE_SIG(type
, always_available
, 1, x
);
3224 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
3229 ir_function_signature
*
3230 builtin_builder::_atan2(const glsl_type
*type
)
3232 ir_variable
*vec_y
= in_var(type
, "vec_y");
3233 ir_variable
*vec_x
= in_var(type
, "vec_x");
3234 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3236 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3237 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3238 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3239 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3240 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3241 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3242 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3244 /* If |x| >= 1.0e-8 * |y|: */
3246 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3248 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3250 /* Then...call atan(y/x) */
3251 do_atan(body
, glsl_type::float_type
, r
, div(y
, x
));
3253 /* ...and fix it up: */
3254 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3255 inner_if
->then_instructions
.push_tail(
3256 if_tree(gequal(y
, imm(0.0f
)),
3257 assign(r
, add(r
, imm(M_PIf
))),
3258 assign(r
, sub(r
, imm(M_PIf
)))));
3259 outer_then
.emit(inner_if
);
3262 outer_if
->else_instructions
.push_tail(
3263 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3265 body
.emit(outer_if
);
3267 body
.emit(assign(vec_result
, r
, 1 << i
));
3269 body
.emit(ret(vec_result
));
3275 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3278 * range-reduction, first step:
3280 * / y_over_x if |y_over_x| <= 1.0;
3282 * \ 1.0 / y_over_x otherwise
3284 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3285 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3291 * approximate atan by evaluating polynomial:
3293 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3294 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3295 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3297 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3298 body
.emit(assign(tmp
, mul(x
, x
)));
3299 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3301 imm(0.0536813784310406f
)),
3303 imm(0.1173503194786851f
)),
3305 imm(0.1938924977115610f
)),
3307 imm(0.3326756418091246f
)),
3309 imm(0.9999793128310355f
)),
3312 /* range-reduction fixup */
3313 body
.emit(assign(tmp
, add(tmp
,
3314 mul(b2f(greater(abs(y_over_x
),
3315 imm(1.0f
, type
->components()))),
3321 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3324 ir_function_signature
*
3325 builtin_builder::_atan(const glsl_type
*type
)
3327 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3328 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3330 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3331 do_atan(body
, type
, tmp
, y_over_x
);
3332 body
.emit(ret(tmp
));
3337 ir_function_signature
*
3338 builtin_builder::_sinh(const glsl_type
*type
)
3340 ir_variable
*x
= in_var(type
, "x");
3341 MAKE_SIG(type
, v130
, 1, x
);
3343 /* 0.5 * (e^x - e^(-x)) */
3344 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3349 ir_function_signature
*
3350 builtin_builder::_cosh(const glsl_type
*type
)
3352 ir_variable
*x
= in_var(type
, "x");
3353 MAKE_SIG(type
, v130
, 1, x
);
3355 /* 0.5 * (e^x + e^(-x)) */
3356 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3361 ir_function_signature
*
3362 builtin_builder::_tanh(const glsl_type
*type
)
3364 ir_variable
*x
= in_var(type
, "x");
3365 MAKE_SIG(type
, v130
, 1, x
);
3367 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3368 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3369 add(exp(x
), exp(neg(x
))))));
3374 ir_function_signature
*
3375 builtin_builder::_asinh(const glsl_type
*type
)
3377 ir_variable
*x
= in_var(type
, "x");
3378 MAKE_SIG(type
, v130
, 1, x
);
3380 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3385 ir_function_signature
*
3386 builtin_builder::_acosh(const glsl_type
*type
)
3388 ir_variable
*x
= in_var(type
, "x");
3389 MAKE_SIG(type
, v130
, 1, x
);
3391 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3395 ir_function_signature
*
3396 builtin_builder::_atanh(const glsl_type
*type
)
3398 ir_variable
*x
= in_var(type
, "x");
3399 MAKE_SIG(type
, v130
, 1, x
);
3401 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3402 sub(imm(1.0f
), x
))))));
3408 * Exponential Functions @{
3411 ir_function_signature
*
3412 builtin_builder::_pow(const glsl_type
*type
)
3414 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
3417 UNOP(exp
, ir_unop_exp
, always_available
)
3418 UNOP(log
, ir_unop_log
, always_available
)
3419 UNOP(exp2
, ir_unop_exp2
, always_available
)
3420 UNOP(log2
, ir_unop_log2
, always_available
)
3421 UNOPA(sqrt
, ir_unop_sqrt
)
3422 UNOPA(inversesqrt
, ir_unop_rsq
)
3426 UNOPA(abs
, ir_unop_abs
)
3427 UNOPA(sign
, ir_unop_sign
)
3428 UNOPA(floor
, ir_unop_floor
)
3429 UNOPA(trunc
, ir_unop_trunc
)
3430 UNOPA(round
, ir_unop_round_even
)
3431 UNOPA(roundEven
, ir_unop_round_even
)
3432 UNOPA(ceil
, ir_unop_ceil
)
3433 UNOPA(fract
, ir_unop_fract
)
3435 ir_function_signature
*
3436 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
3438 return binop(always_available
, ir_binop_mod
, x_type
, x_type
, y_type
);
3441 ir_function_signature
*
3442 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3444 ir_variable
*x
= in_var(type
, "x");
3445 ir_variable
*i
= out_var(type
, "i");
3446 MAKE_SIG(type
, avail
, 2, x
, i
);
3448 ir_variable
*t
= body
.make_temp(type
, "t");
3449 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3450 body
.emit(assign(i
, t
));
3451 body
.emit(ret(sub(x
, t
)));
3456 ir_function_signature
*
3457 builtin_builder::_min(builtin_available_predicate avail
,
3458 const glsl_type
*x_type
, const glsl_type
*y_type
)
3460 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
3463 ir_function_signature
*
3464 builtin_builder::_max(builtin_available_predicate avail
,
3465 const glsl_type
*x_type
, const glsl_type
*y_type
)
3467 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
3470 ir_function_signature
*
3471 builtin_builder::_clamp(builtin_available_predicate avail
,
3472 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3474 ir_variable
*x
= in_var(val_type
, "x");
3475 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3476 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3477 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3479 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3484 ir_function_signature
*
3485 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3487 ir_variable
*x
= in_var(val_type
, "x");
3488 ir_variable
*y
= in_var(val_type
, "y");
3489 ir_variable
*a
= in_var(blend_type
, "a");
3490 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3492 body
.emit(ret(lrp(x
, y
, a
)));
3497 ir_function_signature
*
3498 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3499 const glsl_type
*val_type
,
3500 const glsl_type
*blend_type
)
3502 ir_variable
*x
= in_var(val_type
, "x");
3503 ir_variable
*y
= in_var(val_type
, "y");
3504 ir_variable
*a
= in_var(blend_type
, "a");
3505 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3507 /* csel matches the ternary operator in that a selector of true choses the
3508 * first argument. This differs from mix(x, y, false) which choses the
3509 * second argument (to remain consistent with the interpolating version of
3510 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3512 * To handle the behavior mismatch, reverse the x and y arguments.
3514 body
.emit(ret(csel(a
, y
, x
)));
3519 ir_function_signature
*
3520 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3522 ir_variable
*edge
= in_var(edge_type
, "edge");
3523 ir_variable
*x
= in_var(x_type
, "x");
3524 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3526 ir_variable
*t
= body
.make_temp(x_type
, "t");
3527 if (x_type
->vector_elements
== 1) {
3528 /* Both are floats */
3529 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3530 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3532 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3533 } else if (edge_type
->vector_elements
== 1) {
3534 /* x is a vector but edge is a float */
3535 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3536 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3537 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3539 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3542 /* Both are vectors */
3543 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3544 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3545 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3548 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3558 ir_function_signature
*
3559 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3561 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3562 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3563 ir_variable
*x
= in_var(x_type
, "x");
3564 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3566 /* From the GLSL 1.10 specification:
3569 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3570 * return t * t * (3 - 2 * t);
3573 ir_variable
*t
= body
.make_temp(x_type
, "t");
3574 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3575 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3577 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3582 ir_function_signature
*
3583 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3585 ir_variable
*x
= in_var(type
, "x");
3586 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3588 body
.emit(ret(nequal(x
, x
)));
3593 ir_function_signature
*
3594 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3596 ir_variable
*x
= in_var(type
, "x");
3597 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3599 ir_constant_data infinities
;
3600 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3601 switch (type
->base_type
) {
3602 case GLSL_TYPE_FLOAT
:
3603 infinities
.f
[i
] = INFINITY
;
3605 case GLSL_TYPE_DOUBLE
:
3606 infinities
.d
[i
] = INFINITY
;
3609 unreachable("unknown type");
3613 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3618 ir_function_signature
*
3619 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3621 ir_variable
*x
= in_var(type
, "x");
3622 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3623 body
.emit(ret(bitcast_f2i(x
)));
3627 ir_function_signature
*
3628 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3630 ir_variable
*x
= in_var(type
, "x");
3631 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3632 body
.emit(ret(bitcast_f2u(x
)));
3636 ir_function_signature
*
3637 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3639 ir_variable
*x
= in_var(type
, "x");
3640 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3641 body
.emit(ret(bitcast_i2f(x
)));
3645 ir_function_signature
*
3646 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3648 ir_variable
*x
= in_var(type
, "x");
3649 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3650 body
.emit(ret(bitcast_u2f(x
)));
3654 ir_function_signature
*
3655 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3657 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3658 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3659 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3663 ir_function_signature
*
3664 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3666 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3667 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3668 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3672 ir_function_signature
*
3673 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3675 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3676 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3677 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3681 ir_function_signature
*
3682 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3684 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3685 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3686 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3690 ir_function_signature
*
3691 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3693 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3694 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3695 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3699 ir_function_signature
*
3700 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3702 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3703 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3704 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3709 ir_function_signature
*
3710 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3712 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3713 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3714 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3718 ir_function_signature
*
3719 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3721 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3722 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3723 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3727 ir_function_signature
*
3728 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3730 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3731 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3732 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3736 ir_function_signature
*
3737 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3739 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3740 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3741 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3745 ir_function_signature
*
3746 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3748 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3749 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3750 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3754 ir_function_signature
*
3755 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3757 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3758 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3759 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3763 ir_function_signature
*
3764 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3766 ir_variable
*x
= in_var(type
, "x");
3767 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3769 body
.emit(ret(sqrt(dot(x
, x
))));
3774 ir_function_signature
*
3775 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3777 ir_variable
*p0
= in_var(type
, "p0");
3778 ir_variable
*p1
= in_var(type
, "p1");
3779 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3781 if (type
->vector_elements
== 1) {
3782 body
.emit(ret(abs(sub(p0
, p1
))));
3784 ir_variable
*p
= body
.make_temp(type
, "p");
3785 body
.emit(assign(p
, sub(p0
, p1
)));
3786 body
.emit(ret(sqrt(dot(p
, p
))));
3792 ir_function_signature
*
3793 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3795 if (type
->vector_elements
== 1)
3796 return binop(avail
, ir_binop_mul
, type
, type
, type
);
3798 return binop(avail
, ir_binop_dot
,
3799 type
->get_base_type(), type
, type
);
3802 ir_function_signature
*
3803 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3805 ir_variable
*a
= in_var(type
, "a");
3806 ir_variable
*b
= in_var(type
, "b");
3807 MAKE_SIG(type
, avail
, 2, a
, b
);
3809 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3810 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3812 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3813 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3818 ir_function_signature
*
3819 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3821 ir_variable
*x
= in_var(type
, "x");
3822 MAKE_SIG(type
, avail
, 1, x
);
3824 if (type
->vector_elements
== 1) {
3825 body
.emit(ret(sign(x
)));
3827 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3833 ir_function_signature
*
3834 builtin_builder::_ftransform()
3836 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3838 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3839 glsl_type::vec4_type
,
3840 var_ref(gl_ModelViewProjectionMatrix
),
3841 var_ref(gl_Vertex
))));
3843 /* FINISHME: Once the ir_expression() constructor handles type inference
3844 * for matrix operations, we can simplify this to:
3846 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3851 ir_function_signature
*
3852 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3854 ir_variable
*N
= in_var(type
, "N");
3855 ir_variable
*I
= in_var(type
, "I");
3856 ir_variable
*Nref
= in_var(type
, "Nref");
3857 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3859 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3860 ret(N
), ret(neg(N
))));
3865 ir_function_signature
*
3866 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3868 ir_variable
*I
= in_var(type
, "I");
3869 ir_variable
*N
= in_var(type
, "N");
3870 MAKE_SIG(type
, avail
, 2, I
, N
);
3872 /* I - 2 * dot(N, I) * N */
3873 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3878 ir_function_signature
*
3879 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3881 ir_variable
*I
= in_var(type
, "I");
3882 ir_variable
*N
= in_var(type
, "N");
3883 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3884 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3886 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3887 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3889 /* From the GLSL 1.10 specification:
3890 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3892 * return genType(0.0)
3894 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3896 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3897 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3898 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3899 mul(n_dot_i
, n_dot_i
)))))));
3900 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3901 ret(ir_constant::zero(mem_ctx
, type
)),
3902 ret(sub(mul(eta
, I
),
3903 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3908 ir_function_signature
*
3909 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3911 ir_variable
*x
= in_var(type
, "x");
3912 ir_variable
*y
= in_var(type
, "y");
3913 MAKE_SIG(type
, avail
, 2, x
, y
);
3915 ir_variable
*z
= body
.make_temp(type
, "z");
3916 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3917 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3924 ir_function_signature
*
3925 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3930 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3931 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3932 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3934 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3935 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3937 MAKE_SIG(type
, avail
, 2, c
, r
);
3939 ir_variable
*m
= body
.make_temp(type
, "m");
3940 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3941 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3948 ir_function_signature
*
3949 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3951 const glsl_type
*transpose_type
=
3952 glsl_type::get_instance(orig_type
->base_type
,
3953 orig_type
->matrix_columns
,
3954 orig_type
->vector_elements
);
3956 ir_variable
*m
= in_var(orig_type
, "m");
3957 MAKE_SIG(transpose_type
, avail
, 1, m
);
3959 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3960 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3961 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3962 body
.emit(assign(array_ref(t
, j
),
3963 matrix_elt(m
, i
, j
),
3972 ir_function_signature
*
3973 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3975 ir_variable
*m
= in_var(type
, "m");
3976 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3978 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3979 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3984 ir_function_signature
*
3985 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3987 ir_variable
*m
= in_var(type
, "m");
3988 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3991 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3992 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3995 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3996 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3999 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4000 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4002 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4003 mul(matrix_elt(m
, 0, 1), f2
)),
4004 mul(matrix_elt(m
, 0, 2), f3
))));
4009 ir_function_signature
*
4010 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4012 ir_variable
*m
= in_var(type
, "m");
4013 const glsl_type
*btype
= type
->get_base_type();
4014 MAKE_SIG(btype
, avail
, 1, m
);
4016 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4017 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4018 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4019 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4020 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4021 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4022 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4023 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4024 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4025 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4026 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4027 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4028 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4029 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4030 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4031 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4032 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4033 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4034 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4036 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)))));
4037 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)))));
4038 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)))));
4039 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)))));
4040 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)))));
4041 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)))));
4042 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)))));
4043 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)))));
4044 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)))));
4045 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)))));
4046 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)))));
4047 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)))));
4048 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)))));
4049 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)))));
4050 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)))));
4051 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)))));
4052 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)))));
4053 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)))));
4054 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)))));
4056 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4058 body
.emit(assign(adj_0
,
4059 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4060 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4061 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4063 body
.emit(assign(adj_0
, neg(
4064 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4065 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4066 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4068 body
.emit(assign(adj_0
,
4069 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4070 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4071 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4073 body
.emit(assign(adj_0
, neg(
4074 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4075 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4076 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4079 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4084 ir_function_signature
*
4085 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4087 ir_variable
*m
= in_var(type
, "m");
4088 MAKE_SIG(type
, avail
, 1, m
);
4090 ir_variable
*adj
= body
.make_temp(type
, "adj");
4091 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4092 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4093 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4094 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4096 ir_expression
*det
=
4097 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4098 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4100 body
.emit(ret(div(adj
, det
)));
4104 ir_function_signature
*
4105 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4107 ir_variable
*m
= in_var(type
, "m");
4108 const glsl_type
*btype
= type
->get_base_type();
4109 MAKE_SIG(type
, avail
, 1, m
);
4111 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4112 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4113 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4115 body
.emit(assign(f11_22_21_12
,
4116 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4117 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4118 body
.emit(assign(f10_22_20_12
,
4119 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4120 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4121 body
.emit(assign(f10_21_20_11
,
4122 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4123 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4125 ir_variable
*adj
= body
.make_temp(type
, "adj");
4126 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4127 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4128 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4130 body
.emit(assign(array_ref(adj
, 0), neg(
4131 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4132 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4134 body
.emit(assign(array_ref(adj
, 1),
4135 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4136 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4138 body
.emit(assign(array_ref(adj
, 2), neg(
4139 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4140 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4143 body
.emit(assign(array_ref(adj
, 0),
4144 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4145 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4147 body
.emit(assign(array_ref(adj
, 1), neg(
4148 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4149 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4151 body
.emit(assign(array_ref(adj
, 2),
4152 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4153 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4156 ir_expression
*det
=
4157 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4158 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4159 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4161 body
.emit(ret(div(adj
, det
)));
4166 ir_function_signature
*
4167 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4169 ir_variable
*m
= in_var(type
, "m");
4170 const glsl_type
*btype
= type
->get_base_type();
4171 MAKE_SIG(type
, avail
, 1, m
);
4173 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4174 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4175 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4176 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4177 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4178 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4179 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4180 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4181 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4182 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4183 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4184 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4185 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4186 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4187 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4188 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4189 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4190 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4191 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4193 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)))));
4194 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)))));
4195 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)))));
4196 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)))));
4197 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)))));
4198 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)))));
4199 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)))));
4200 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)))));
4201 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)))));
4202 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)))));
4203 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)))));
4204 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)))));
4205 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)))));
4206 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)))));
4207 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)))));
4208 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)))));
4209 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)))));
4210 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)))));
4211 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)))));
4213 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4214 body
.emit(assign(array_ref(adj
, 0),
4215 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4216 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4217 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4219 body
.emit(assign(array_ref(adj
, 1), neg(
4220 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4221 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4222 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4224 body
.emit(assign(array_ref(adj
, 2),
4225 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4226 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4227 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4229 body
.emit(assign(array_ref(adj
, 3), neg(
4230 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4231 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4232 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4235 body
.emit(assign(array_ref(adj
, 0), neg(
4236 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4237 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4238 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4240 body
.emit(assign(array_ref(adj
, 1),
4241 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4242 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4243 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4245 body
.emit(assign(array_ref(adj
, 2), neg(
4246 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4247 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4248 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4250 body
.emit(assign(array_ref(adj
, 3),
4251 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4252 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4253 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4256 body
.emit(assign(array_ref(adj
, 0),
4257 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4258 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4259 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4261 body
.emit(assign(array_ref(adj
, 1), neg(
4262 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4263 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4264 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4266 body
.emit(assign(array_ref(adj
, 2),
4267 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4268 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4269 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4271 body
.emit(assign(array_ref(adj
, 3), neg(
4272 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4273 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4274 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4277 body
.emit(assign(array_ref(adj
, 0), neg(
4278 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4279 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4280 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4282 body
.emit(assign(array_ref(adj
, 1),
4283 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4284 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4285 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4287 body
.emit(assign(array_ref(adj
, 2), neg(
4288 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4289 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4290 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4292 body
.emit(assign(array_ref(adj
, 3),
4293 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4294 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4295 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4298 ir_expression
*det
=
4299 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4300 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4301 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4302 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4304 body
.emit(ret(div(adj
, det
)));
4310 ir_function_signature
*
4311 builtin_builder::_lessThan(builtin_available_predicate avail
,
4312 const glsl_type
*type
)
4314 return binop(avail
, ir_binop_less
,
4315 glsl_type::bvec(type
->vector_elements
), type
, type
);
4318 ir_function_signature
*
4319 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4320 const glsl_type
*type
)
4322 return binop(avail
, ir_binop_lequal
,
4323 glsl_type::bvec(type
->vector_elements
), type
, type
);
4326 ir_function_signature
*
4327 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4328 const glsl_type
*type
)
4330 return binop(avail
, ir_binop_greater
,
4331 glsl_type::bvec(type
->vector_elements
), type
, type
);
4334 ir_function_signature
*
4335 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4336 const glsl_type
*type
)
4338 return binop(avail
, ir_binop_gequal
,
4339 glsl_type::bvec(type
->vector_elements
), type
, type
);
4342 ir_function_signature
*
4343 builtin_builder::_equal(builtin_available_predicate avail
,
4344 const glsl_type
*type
)
4346 return binop(avail
, ir_binop_equal
,
4347 glsl_type::bvec(type
->vector_elements
), type
, type
);
4350 ir_function_signature
*
4351 builtin_builder::_notEqual(builtin_available_predicate avail
,
4352 const glsl_type
*type
)
4354 return binop(avail
, ir_binop_nequal
,
4355 glsl_type::bvec(type
->vector_elements
), type
, type
);
4358 ir_function_signature
*
4359 builtin_builder::_any(const glsl_type
*type
)
4361 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
4364 ir_function_signature
*
4365 builtin_builder::_all(const glsl_type
*type
)
4367 ir_variable
*v
= in_var(type
, "v");
4368 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4370 switch (type
->vector_elements
) {
4372 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
4375 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4379 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4388 UNOP(not, ir_unop_logic_not
, always_available
)
4391 has_lod(const glsl_type
*sampler_type
)
4393 assert(sampler_type
->is_sampler());
4395 switch (sampler_type
->sampler_dimensionality
) {
4396 case GLSL_SAMPLER_DIM_RECT
:
4397 case GLSL_SAMPLER_DIM_BUF
:
4398 case GLSL_SAMPLER_DIM_MS
:
4405 ir_function_signature
*
4406 builtin_builder::_textureSize(builtin_available_predicate avail
,
4407 const glsl_type
*return_type
,
4408 const glsl_type
*sampler_type
)
4410 ir_variable
*s
= in_var(sampler_type
, "sampler");
4411 /* The sampler always exists; add optional lod later. */
4412 MAKE_SIG(return_type
, avail
, 1, s
);
4414 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4415 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4417 if (has_lod(sampler_type
)) {
4418 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4419 sig
->parameters
.push_tail(lod
);
4420 tex
->lod_info
.lod
= var_ref(lod
);
4422 tex
->lod_info
.lod
= imm(0u);
4425 body
.emit(ret(tex
));
4430 ir_function_signature
*
4431 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4433 ir_variable
*s
= in_var(sampler_type
, "sampler");
4434 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4436 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4437 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4438 body
.emit(ret(tex
));
4443 ir_function_signature
*
4444 builtin_builder::_texture(ir_texture_opcode opcode
,
4445 builtin_available_predicate avail
,
4446 const glsl_type
*return_type
,
4447 const glsl_type
*sampler_type
,
4448 const glsl_type
*coord_type
,
4451 ir_variable
*s
= in_var(sampler_type
, "sampler");
4452 ir_variable
*P
= in_var(coord_type
, "P");
4453 /* The sampler and coordinate always exist; add optional parameters later. */
4454 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4456 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4457 tex
->set_sampler(var_ref(s
), return_type
);
4459 const int coord_size
= sampler_type
->coordinate_components();
4461 if (coord_size
== coord_type
->vector_elements
) {
4462 tex
->coordinate
= var_ref(P
);
4464 /* The incoming coordinate also has the projector or shadow comparitor,
4465 * so we need to swizzle those away.
4467 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4470 /* The projector is always in the last component. */
4471 if (flags
& TEX_PROJECT
)
4472 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4474 if (sampler_type
->sampler_shadow
) {
4475 if (opcode
== ir_tg4
) {
4476 /* gather has refz as a separate parameter, immediately after the
4479 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4480 sig
->parameters
.push_tail(refz
);
4481 tex
->shadow_comparitor
= var_ref(refz
);
4483 /* The shadow comparitor is normally in the Z component, but a few types
4484 * have sufficiently large coordinates that it's in W.
4486 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4490 if (opcode
== ir_txl
) {
4491 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4492 sig
->parameters
.push_tail(lod
);
4493 tex
->lod_info
.lod
= var_ref(lod
);
4494 } else if (opcode
== ir_txd
) {
4495 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4496 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4497 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4498 sig
->parameters
.push_tail(dPdx
);
4499 sig
->parameters
.push_tail(dPdy
);
4500 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4501 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4504 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4505 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4506 ir_variable
*offset
=
4507 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4508 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4509 sig
->parameters
.push_tail(offset
);
4510 tex
->offset
= var_ref(offset
);
4513 if (flags
& TEX_OFFSET_ARRAY
) {
4514 ir_variable
*offsets
=
4515 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4516 "offsets", ir_var_const_in
);
4517 sig
->parameters
.push_tail(offsets
);
4518 tex
->offset
= var_ref(offsets
);
4521 if (opcode
== ir_tg4
) {
4522 if (flags
& TEX_COMPONENT
) {
4523 ir_variable
*component
=
4524 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4525 sig
->parameters
.push_tail(component
);
4526 tex
->lod_info
.component
= var_ref(component
);
4529 tex
->lod_info
.component
= imm(0);
4533 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4534 * inconsistent with both textureLodOffset and textureGradOffset.
4536 if (opcode
== ir_txb
) {
4537 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4538 sig
->parameters
.push_tail(bias
);
4539 tex
->lod_info
.bias
= var_ref(bias
);
4542 body
.emit(ret(tex
));
4547 ir_function_signature
*
4548 builtin_builder::_textureCubeArrayShadow()
4550 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4551 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4552 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4553 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4555 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4556 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4558 tex
->coordinate
= var_ref(P
);
4559 tex
->shadow_comparitor
= var_ref(compare
);
4561 body
.emit(ret(tex
));
4566 ir_function_signature
*
4567 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4568 const glsl_type
*return_type
,
4569 const glsl_type
*sampler_type
,
4570 const glsl_type
*coord_type
,
4571 const glsl_type
*offset_type
)
4573 ir_variable
*s
= in_var(sampler_type
, "sampler");
4574 ir_variable
*P
= in_var(coord_type
, "P");
4575 /* The sampler and coordinate always exist; add optional parameters later. */
4576 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4578 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4579 tex
->coordinate
= var_ref(P
);
4580 tex
->set_sampler(var_ref(s
), return_type
);
4582 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4583 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4584 sig
->parameters
.push_tail(sample
);
4585 tex
->lod_info
.sample_index
= var_ref(sample
);
4586 tex
->op
= ir_txf_ms
;
4587 } else if (has_lod(sampler_type
)) {
4588 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4589 sig
->parameters
.push_tail(lod
);
4590 tex
->lod_info
.lod
= var_ref(lod
);
4592 tex
->lod_info
.lod
= imm(0u);
4595 if (offset_type
!= NULL
) {
4596 ir_variable
*offset
=
4597 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4598 sig
->parameters
.push_tail(offset
);
4599 tex
->offset
= var_ref(offset
);
4602 body
.emit(ret(tex
));
4607 ir_function_signature
*
4608 builtin_builder::_EmitVertex()
4610 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4612 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4613 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4618 ir_function_signature
*
4619 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4620 const glsl_type
*stream_type
)
4622 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4624 * "Emit the current values of output variables to the current output
4625 * primitive on stream stream. The argument to stream must be a constant
4626 * integral expression."
4628 ir_variable
*stream
=
4629 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4631 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4633 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4638 ir_function_signature
*
4639 builtin_builder::_EndPrimitive()
4641 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4643 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4644 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4649 ir_function_signature
*
4650 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4651 const glsl_type
*stream_type
)
4653 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4655 * "Completes the current output primitive on stream stream and starts
4656 * a new one. The argument to stream must be a constant integral
4659 ir_variable
*stream
=
4660 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4662 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4664 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4669 ir_function_signature
*
4670 builtin_builder::_barrier()
4672 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4674 body
.emit(new(mem_ctx
) ir_barrier());
4678 ir_function_signature
*
4679 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4680 const glsl_type
*sampler_type
,
4681 const glsl_type
*coord_type
)
4683 ir_variable
*s
= in_var(sampler_type
, "sampler");
4684 ir_variable
*coord
= in_var(coord_type
, "coord");
4685 /* The sampler and coordinate always exist; add optional parameters later. */
4686 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4688 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4689 tex
->coordinate
= var_ref(coord
);
4690 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4692 body
.emit(ret(tex
));
4697 ir_function_signature
*
4698 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4700 ir_variable
*s
= in_var(sampler_type
, "sampler");
4701 const glsl_type
*return_type
= glsl_type::int_type
;
4702 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4704 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4705 tex
->set_sampler(var_ref(s
), return_type
);
4707 body
.emit(ret(tex
));
4712 ir_function_signature
*
4713 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
4714 const glsl_type
*sampler_type
,
4715 const glsl_type
*coord_type
)
4717 ir_variable
*s
= in_var(sampler_type
, "sampler");
4718 ir_variable
*P
= in_var(coord_type
, "P");
4719 const glsl_type
*return_type
= glsl_type::bool_type
;
4720 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4722 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
4723 tex
->coordinate
= var_ref(P
);
4724 tex
->set_sampler(var_ref(s
), return_type
);
4726 body
.emit(ret(tex
));
4731 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4732 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4733 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4734 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4735 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4736 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4738 ir_function_signature
*
4739 builtin_builder::_fwidth(const glsl_type
*type
)
4741 ir_variable
*p
= in_var(type
, "p");
4742 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4744 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4749 ir_function_signature
*
4750 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4752 ir_variable
*p
= in_var(type
, "p");
4753 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4755 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4756 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4761 ir_function_signature
*
4762 builtin_builder::_fwidthFine(const glsl_type
*type
)
4764 ir_variable
*p
= in_var(type
, "p");
4765 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4767 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4768 abs(expr(ir_unop_dFdy_fine
, p
)))));
4773 ir_function_signature
*
4774 builtin_builder::_noise1(const glsl_type
*type
)
4776 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4779 ir_function_signature
*
4780 builtin_builder::_noise2(const glsl_type
*type
)
4782 ir_variable
*p
= in_var(type
, "p");
4783 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4785 ir_constant_data b_offset
;
4786 b_offset
.f
[0] = 601.0f
;
4787 b_offset
.f
[1] = 313.0f
;
4788 b_offset
.f
[2] = 29.0f
;
4789 b_offset
.f
[3] = 277.0f
;
4791 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4792 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4793 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4794 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4795 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4796 body
.emit(assign(t
, a
, WRITEMASK_X
));
4797 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4803 ir_function_signature
*
4804 builtin_builder::_noise3(const glsl_type
*type
)
4806 ir_variable
*p
= in_var(type
, "p");
4807 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4809 ir_constant_data b_offset
;
4810 b_offset
.f
[0] = 601.0f
;
4811 b_offset
.f
[1] = 313.0f
;
4812 b_offset
.f
[2] = 29.0f
;
4813 b_offset
.f
[3] = 277.0f
;
4815 ir_constant_data c_offset
;
4816 c_offset
.f
[0] = 1559.0f
;
4817 c_offset
.f
[1] = 113.0f
;
4818 c_offset
.f
[2] = 1861.0f
;
4819 c_offset
.f
[3] = 797.0f
;
4821 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4822 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4823 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4824 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4825 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4826 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4827 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4828 body
.emit(assign(t
, a
, WRITEMASK_X
));
4829 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4830 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4836 ir_function_signature
*
4837 builtin_builder::_noise4(const glsl_type
*type
)
4839 ir_variable
*p
= in_var(type
, "p");
4840 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4842 ir_variable
*_p
= body
.make_temp(type
, "_p");
4844 ir_constant_data p_offset
;
4845 p_offset
.f
[0] = 1559.0f
;
4846 p_offset
.f
[1] = 113.0f
;
4847 p_offset
.f
[2] = 1861.0f
;
4848 p_offset
.f
[3] = 797.0f
;
4850 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4852 ir_constant_data offset
;
4853 offset
.f
[0] = 601.0f
;
4854 offset
.f
[1] = 313.0f
;
4855 offset
.f
[2] = 29.0f
;
4856 offset
.f
[3] = 277.0f
;
4858 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4859 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4860 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4861 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4862 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4863 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4864 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4865 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4866 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4867 body
.emit(assign(t
, a
, WRITEMASK_X
));
4868 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4869 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4870 body
.emit(assign(t
, d
, WRITEMASK_W
));
4876 ir_function_signature
*
4877 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4879 ir_variable
*value
= in_var(type
, "value");
4880 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4881 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4882 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4884 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4889 ir_function_signature
*
4890 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4892 ir_variable
*base
= in_var(type
, "base");
4893 ir_variable
*insert
= in_var(type
, "insert");
4894 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4895 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4896 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
4898 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4903 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
4905 ir_function_signature
*
4906 builtin_builder::_bitCount(const glsl_type
*type
)
4908 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
4909 glsl_type::ivec(type
->vector_elements
), type
);
4912 ir_function_signature
*
4913 builtin_builder::_findLSB(const glsl_type
*type
)
4915 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
4916 glsl_type::ivec(type
->vector_elements
), type
);
4919 ir_function_signature
*
4920 builtin_builder::_findMSB(const glsl_type
*type
)
4922 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
4923 glsl_type::ivec(type
->vector_elements
), type
);
4926 ir_function_signature
*
4927 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4929 ir_variable
*a
= in_var(type
, "a");
4930 ir_variable
*b
= in_var(type
, "b");
4931 ir_variable
*c
= in_var(type
, "c");
4932 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4934 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4939 ir_function_signature
*
4940 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4942 return binop(x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
,
4943 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
4946 ir_function_signature
*
4947 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4949 ir_variable
*x
= in_var(x_type
, "x");
4950 ir_variable
*exponent
= out_var(exp_type
, "exp");
4951 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
4953 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
4955 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
4959 ir_function_signature
*
4960 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4962 ir_variable
*x
= in_var(x_type
, "x");
4963 ir_variable
*exponent
= out_var(exp_type
, "exp");
4964 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
4966 const unsigned vec_elem
= x_type
->vector_elements
;
4967 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4968 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4970 /* Single-precision floating-point values are stored as
4975 * An exponent shift of 23 will shift the mantissa out, leaving only the
4976 * exponent and sign bit (which itself may be zero, if the absolute value
4977 * was taken before the bitcast and shift.
4979 ir_constant
*exponent_shift
= imm(23);
4980 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4982 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4984 /* Exponent of floating-point values in the range [0.5, 1.0). */
4985 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4987 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4988 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4990 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4991 * to unsigned integers to ensure that 1 bits aren't shifted in.
4993 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
4994 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
4995 imm(0, vec_elem
)))));
4997 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
4998 body
.emit(assign(bits
, bitcast_f2u(x
)));
4999 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5000 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5001 imm(0u, vec_elem
)))));
5002 body
.emit(ret(bitcast_u2f(bits
)));
5007 ir_function_signature
*
5008 builtin_builder::_uaddCarry(const glsl_type
*type
)
5010 ir_variable
*x
= in_var(type
, "x");
5011 ir_variable
*y
= in_var(type
, "y");
5012 ir_variable
*carry
= out_var(type
, "carry");
5013 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
5015 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5016 body
.emit(ret(add(x
, y
)));
5021 ir_function_signature
*
5022 builtin_builder::_usubBorrow(const glsl_type
*type
)
5024 ir_variable
*x
= in_var(type
, "x");
5025 ir_variable
*y
= in_var(type
, "y");
5026 ir_variable
*borrow
= out_var(type
, "borrow");
5027 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
5029 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5030 body
.emit(ret(sub(x
, y
)));
5036 * For both imulExtended() and umulExtended() built-ins.
5038 ir_function_signature
*
5039 builtin_builder::_mulExtended(const glsl_type
*type
)
5041 ir_variable
*x
= in_var(type
, "x");
5042 ir_variable
*y
= in_var(type
, "y");
5043 ir_variable
*msb
= out_var(type
, "msb");
5044 ir_variable
*lsb
= out_var(type
, "lsb");
5045 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
5047 body
.emit(assign(msb
, imul_high(x
, y
)));
5048 body
.emit(assign(lsb
, mul(x
, y
)));
5053 ir_function_signature
*
5054 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5056 ir_variable
*interpolant
= in_var(type
, "interpolant");
5057 interpolant
->data
.must_be_shader_input
= 1;
5058 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
5060 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5065 ir_function_signature
*
5066 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5068 ir_variable
*interpolant
= in_var(type
, "interpolant");
5069 interpolant
->data
.must_be_shader_input
= 1;
5070 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5071 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
5073 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5078 ir_function_signature
*
5079 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5081 ir_variable
*interpolant
= in_var(type
, "interpolant");
5082 interpolant
->data
.must_be_shader_input
= 1;
5083 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5084 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
5086 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5091 ir_function_signature
*
5092 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
)
5094 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5095 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
5099 ir_function_signature
*
5100 builtin_builder::_atomic_ssbo_intrinsic2(builtin_available_predicate avail
,
5101 const glsl_type
*type
)
5103 ir_variable
*atomic
= in_var(type
, "atomic");
5104 ir_variable
*data
= in_var(type
, "data");
5105 MAKE_INTRINSIC(type
, avail
, 2, atomic
, data
);
5109 ir_function_signature
*
5110 builtin_builder::_atomic_ssbo_intrinsic3(builtin_available_predicate avail
,
5111 const glsl_type
*type
)
5113 ir_variable
*atomic
= in_var(type
, "atomic");
5114 ir_variable
*data1
= in_var(type
, "data1");
5115 ir_variable
*data2
= in_var(type
, "data2");
5116 MAKE_INTRINSIC(type
, avail
, 3, atomic
, data1
, data2
);
5120 ir_function_signature
*
5121 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5122 builtin_available_predicate avail
)
5124 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5125 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5127 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5128 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5130 body
.emit(ret(retval
));
5134 ir_function_signature
*
5135 builtin_builder::_atomic_ssbo_op2(const char *intrinsic
,
5136 builtin_available_predicate avail
,
5137 const glsl_type
*type
)
5139 ir_variable
*atomic
= in_var(type
, "atomic_var");
5140 ir_variable
*data
= in_var(type
, "atomic_data");
5141 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5143 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5144 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5146 body
.emit(ret(retval
));
5150 ir_function_signature
*
5151 builtin_builder::_atomic_ssbo_op3(const char *intrinsic
,
5152 builtin_available_predicate avail
,
5153 const glsl_type
*type
)
5155 ir_variable
*atomic
= in_var(type
, "atomic_var");
5156 ir_variable
*data1
= in_var(type
, "atomic_data1");
5157 ir_variable
*data2
= in_var(type
, "atomic_data2");
5158 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5160 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5161 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5163 body
.emit(ret(retval
));
5167 ir_function_signature
*
5168 builtin_builder::_min3(const glsl_type
*type
)
5170 ir_variable
*x
= in_var(type
, "x");
5171 ir_variable
*y
= in_var(type
, "y");
5172 ir_variable
*z
= in_var(type
, "z");
5173 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5175 ir_expression
*min3
= min2(x
, min2(y
,z
));
5176 body
.emit(ret(min3
));
5181 ir_function_signature
*
5182 builtin_builder::_max3(const glsl_type
*type
)
5184 ir_variable
*x
= in_var(type
, "x");
5185 ir_variable
*y
= in_var(type
, "y");
5186 ir_variable
*z
= in_var(type
, "z");
5187 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5189 ir_expression
*max3
= max2(x
, max2(y
,z
));
5190 body
.emit(ret(max3
));
5195 ir_function_signature
*
5196 builtin_builder::_mid3(const glsl_type
*type
)
5198 ir_variable
*x
= in_var(type
, "x");
5199 ir_variable
*y
= in_var(type
, "y");
5200 ir_variable
*z
= in_var(type
, "z");
5201 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5203 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5204 body
.emit(ret(mid3
));
5209 ir_function_signature
*
5210 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5211 unsigned num_arguments
,
5214 const glsl_type
*data_type
= glsl_type::get_instance(
5215 image_type
->sampler_type
,
5216 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5218 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5219 glsl_type::void_type
: data_type
);
5221 /* Addressing arguments that are always present. */
5222 ir_variable
*image
= in_var(image_type
, "image");
5223 ir_variable
*coord
= in_var(
5224 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5226 const builtin_available_predicate avail
=
5227 (flags
& IMAGE_FUNCTION_AVAIL_ATOMIC
? shader_image_atomic
:
5228 shader_image_load_store
);
5229 ir_function_signature
*sig
= new_sig(ret_type
, avail
, 2, image
, coord
);
5231 /* Sample index for multisample images. */
5232 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5233 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5235 /* Data arguments. */
5236 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5237 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5238 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5239 ralloc_free(arg_name
);
5242 /* Set the maximal set of qualifiers allowed for this image
5243 * built-in. Function calls with arguments having fewer
5244 * qualifiers than present in the prototype are allowed by the
5245 * spec, but not with more, i.e. this will make the compiler
5246 * accept everything that needs to be accepted, and reject cases
5247 * like loads from write-only or stores to read-only images.
5249 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5250 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5251 image
->data
.image_coherent
= true;
5252 image
->data
.image_volatile
= true;
5253 image
->data
.image_restrict
= true;
5258 ir_function_signature
*
5259 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5260 unsigned /* num_arguments */,
5261 unsigned /* flags */)
5263 const glsl_type
*ret_type
;
5264 unsigned num_components
= image_type
->coordinate_components();
5266 /* From the ARB_shader_image_size extension:
5267 * "Cube images return the dimensions of one face."
5269 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5270 !image_type
->sampler_array
) {
5274 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5275 * supported by mesa.
5277 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5279 ir_variable
*image
= in_var(image_type
, "image");
5280 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5282 /* Set the maximal set of qualifiers allowed for this image
5283 * built-in. Function calls with arguments having fewer
5284 * qualifiers than present in the prototype are allowed by the
5285 * spec, but not with more, i.e. this will make the compiler
5286 * accept everything that needs to be accepted, and reject cases
5287 * like loads from write-only or stores to read-only images.
5289 image
->data
.image_read_only
= true;
5290 image
->data
.image_write_only
= true;
5291 image
->data
.image_coherent
= true;
5292 image
->data
.image_volatile
= true;
5293 image
->data
.image_restrict
= true;
5298 ir_function_signature
*
5299 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5300 unsigned /* num_arguments */,
5301 unsigned /* flags */)
5303 ir_variable
*image
= in_var(image_type
, "image");
5304 ir_function_signature
*sig
=
5305 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5307 /* Set the maximal set of qualifiers allowed for this image
5308 * built-in. Function calls with arguments having fewer
5309 * qualifiers than present in the prototype are allowed by the
5310 * spec, but not with more, i.e. this will make the compiler
5311 * accept everything that needs to be accepted, and reject cases
5312 * like loads from write-only or stores to read-only images.
5314 image
->data
.image_read_only
= true;
5315 image
->data
.image_write_only
= true;
5316 image
->data
.image_coherent
= true;
5317 image
->data
.image_volatile
= true;
5318 image
->data
.image_restrict
= true;
5323 ir_function_signature
*
5324 builtin_builder::_image(image_prototype_ctr prototype
,
5325 const glsl_type
*image_type
,
5326 const char *intrinsic_name
,
5327 unsigned num_arguments
,
5330 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5331 num_arguments
, flags
);
5333 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5334 ir_factory
body(&sig
->body
, mem_ctx
);
5335 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5337 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5338 body
.emit(call(f
, NULL
, sig
->parameters
));
5340 ir_variable
*ret_val
=
5341 body
.make_temp(sig
->return_type
, "_ret_val");
5342 body
.emit(call(f
, ret_val
, sig
->parameters
));
5343 body
.emit(ret(ret_val
));
5346 sig
->is_defined
= true;
5349 sig
->is_intrinsic
= true;
5355 ir_function_signature
*
5356 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5358 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5362 ir_function_signature
*
5363 builtin_builder::_memory_barrier(const char *intrinsic_name
,
5364 builtin_available_predicate avail
)
5366 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5367 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
5368 NULL
, sig
->parameters
));
5372 ir_function_signature
*
5373 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
5374 const glsl_type
*type
)
5376 MAKE_INTRINSIC(type
, avail
, 0);
5380 ir_function_signature
*
5381 builtin_builder::_shader_clock(builtin_available_predicate avail
,
5382 const glsl_type
*type
)
5384 MAKE_SIG(type
, avail
, 0);
5386 ir_variable
*retval
= body
.make_temp(type
, "clock_retval");
5388 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
5389 retval
, sig
->parameters
));
5390 body
.emit(ret(retval
));
5396 /******************************************************************************/
5398 /* The singleton instance of builtin_builder. */
5399 static builtin_builder builtins
;
5400 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5403 * External API (exposing the built-in module to the rest of the compiler):
5407 _mesa_glsl_initialize_builtin_functions()
5409 mtx_lock(&builtins_lock
);
5410 builtins
.initialize();
5411 mtx_unlock(&builtins_lock
);
5415 _mesa_glsl_release_builtin_functions()
5417 mtx_lock(&builtins_lock
);
5419 mtx_unlock(&builtins_lock
);
5422 ir_function_signature
*
5423 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5424 const char *name
, exec_list
*actual_parameters
)
5426 ir_function_signature
* s
;
5427 mtx_lock(&builtins_lock
);
5428 s
= builtins
.find(state
, name
, actual_parameters
);
5429 mtx_unlock(&builtins_lock
);
5434 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5437 mtx_lock(&builtins_lock
);
5438 f
= builtins
.shader
->symbols
->get_function(name
);
5439 mtx_unlock(&builtins_lock
);
5444 _mesa_glsl_get_builtin_function_shader()
5446 return builtins
.shader
;
5451 * Get the function signature for main from a shader
5453 ir_function_signature
*
5454 _mesa_get_main_function_signature(gl_shader
*sh
)
5456 ir_function
*const f
= sh
->symbols
->get_function("main");
5458 exec_list void_parameters
;
5460 /* Look for the 'void main()' signature and ensure that it's defined.
5461 * This keeps the linker from accidentally pick a shader that just
5462 * contains a prototype for main.
5464 * We don't have to check for multiple definitions of main (in multiple
5465 * shaders) because that would have already been caught above.
5467 ir_function_signature
*sig
=
5468 f
->matching_signature(NULL
, &void_parameters
, false);
5469 if ((sig
!= NULL
) && sig
->is_defined
) {